[TASK] Replace Space Indent into Tab indent (CGL Cleanup)
[Packages/TYPO3.CMS.git] / typo3 / class.browse_links.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Displays the page/file tree for browsing database records or files.
29 * Used from TCEFORMS an other elements
30 * In other words: This is the ELEMENT BROWSER!
31 *
32 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
33 * XHTML compliant
34 *
35 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
36 */
37
38
39 // Include classes
40 require_once (PATH_typo3.'/class.db_list.inc');
41 require_once (PATH_typo3.'/class.db_list_extra.inc');
42
43
44
45
46 /**
47 * Local version of the record list.
48 *
49 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
50 * @package TYPO3
51 * @subpackage core
52 */
53 class TBE_browser_recordList extends localRecordList {
54 var $thisScript = 'browse_links.php';
55
56 /*
57 * Table name of the field pointing to this element browser
58 *
59 * @var string
60 */
61 protected $relatingTable;
62
63 /*
64 * Field name of the field pointing to this element browser
65 *
66 * @var string
67 */
68 protected $relatingField;
69
70 /**
71 * Initializes the script path
72 *
73 * @return void
74 */
75 function __construct() {
76 parent::__construct();
77 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
78 }
79
80 /**
81 * Creates the URL for links
82 *
83 * @param mixed If not blank string, this is used instead of $this->id as the id value.
84 * @param string If this is "-1" then $this->table is used, otherwise the value of the input variable.
85 * @param string Commalist of fields NOT to pass as parameters (currently "sortField" and "sortRev")
86 * @return string Query-string for URL
87 */
88 function listURL($altId='',$table=-1,$exclList='') {
89 return $this->thisScript.
90 '?id='.(strcmp($altId,'')?$altId:$this->id).
91 '&table='.rawurlencode($table==-1?$this->table:$table).
92 ($this->thumbs?'&imagemode='.$this->thumbs:'').
93 ($this->searchString?'&search_field='.rawurlencode($this->searchString):'').
94 ($this->searchLevels?'&search_levels='.rawurlencode($this->searchLevels):'').
95 ((!$exclList || !t3lib_div::inList($exclList,'sortField')) && $this->sortField?'&sortField='.rawurlencode($this->sortField):'').
96 ((!$exclList || !t3lib_div::inList($exclList,'sortRev')) && $this->sortRev?'&sortRev='.rawurlencode($this->sortRev):'').
97 // extra:
98 $this->ext_addP()
99 ;
100 }
101
102 /**
103 * Returns additional, local GET parameters to include in the links of the record list.
104 *
105 * @return string
106 */
107 function ext_addP() {
108 $str = '&act='.$GLOBALS['SOBE']->browser->act.
109 '&mode='.$GLOBALS['SOBE']->browser->mode.
110 '&expandPage='.$GLOBALS['SOBE']->browser->expandPage.
111 '&bparams='.rawurlencode($GLOBALS['SOBE']->browser->bparams);
112 return $str;
113 }
114
115 /**
116 * Returns the title (based on $code) of a record (from table $table) with the proper link around (that is for "pages"-records a link to the level of that record...)
117 *
118 * @param string Table name
119 * @param integer UID (not used here)
120 * @param string Title string
121 * @param array Records array (from table name)
122 * @return string
123 */
124 function linkWrapItems($table,$uid,$code,$row) {
125 if (!$code) {
126 $code = '<i>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</i>';
127 } else {
128 $code = t3lib_BEfunc::getRecordTitlePrep($code, $this->fixedL);
129 }
130
131 $title = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
132 $ficon = t3lib_iconWorks::getIcon($table,$row);
133 $aOnClick = "return insertElement('".$table."', '".$row['uid']."', 'db', ".t3lib_div::quoteJSvalue($title).", '', '', '".$ficon."');";
134 $ATag = '<a href="#" onclick="'.$aOnClick.'">';
135 $ATag_alt = substr($ATag,0,-4).',\'\',1);">';
136 $ATag_e = '</a>';
137
138 return $ATag.
139 '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') .
140 ' title="' . $GLOBALS['LANG']->getLL('addToList', 1) . '" alt="" />' .
141 $ATag_e.
142 $ATag_alt.
143 $code.
144 $ATag_e;
145 }
146
147
148 /**
149 * Check if all row listing conditions are fulfilled.
150 *
151 * @param string $table string Table name
152 * @param array $row array Record
153 * @return bool True, if all conditions are fulfilled.
154 */
155 protected function isRowListingConditionFulfilled($table, $row) {
156
157 $returnValue = TRUE;
158
159 if ($this->relatingField && $this->relatingTable) {
160 $tcaFieldConfig = $GLOBALS['TCA'][$this->relatingTable]['columns'][$this->relatingField]['config'];
161
162 if (is_array($tcaFieldConfig['filter'])) {
163 foreach ($tcaFieldConfig['filter'] as $filter) {
164 if (!$filter['userFunc']) {
165 continue;
166 }
167
168 $parameters = $filter['parameters']?$filter['parameters']:array();
169 $parameters['values'] = array($table.'_'.$row['uid']);
170 $parameters['tcaFieldConfig'] = $tcaFieldConfig;
171 $valueArray = t3lib_div::callUserFunction($filter['userFunc'], $parameters, $this);
172
173 if (count($valueArray) === 0) {
174 $returnValue = FALSE;
175 }
176 }
177 }
178 }
179 return $returnValue;
180 }
181
182
183 /**
184 * Set which pointing field (in the TCEForm) we are currently rendering the element browser for
185 *
186 * @param string $tableName Table name
187 * @param string $fieldName Field name
188 */
189 public function setRelatingTableAndField($tableName, $fieldName) {
190 global $TCA;
191
192 // Check validity of the input data and load TCA
193 if (isset($TCA[$tableName])) {
194 $this->relatingTable = $tableName;
195 t3lib_div::loadTCA($tableName);
196 if ($fieldName && isset($TCA[$tableName]['columns'][$fieldName])) {
197 $this->relatingField = $fieldName;
198 }
199 }
200 }
201
202
203 /**
204 * Local version that sets allFields to TRUE to support userFieldSelect
205 *
206 * @return void
207 * @see fieldSelectBox
208 */
209 function generateList() {
210 $this->allFields = TRUE;
211 parent::generateList();
212 }
213 }
214
215
216
217
218
219
220 /**
221 * Class which generates the page tree
222 *
223 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
224 * @package TYPO3
225 * @subpackage core
226 */
227 class localPageTree extends t3lib_browseTree {
228
229 /**
230 * whether the page ID should be shown next to the title, activate through userTSconfig (options.pageTree.showPageIdWithTitle)
231 * @boolean
232 */
233 public $ext_showPageId = FALSE;
234
235 /**
236 * Constructor. Just calling init()
237 *
238 * @return void
239 */
240 function __construct() {
241 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
242
243 $this->init();
244
245 $this->clause = ' AND doktype!=' . t3lib_pageSelect::DOKTYPE_RECYCLER . $this->clause;
246 }
247
248 /**
249 * Wrapping the title in a link, if applicable.
250 *
251 * @param string Title, (must be ready for output, that means it must be htmlspecialchars()'ed).
252 * @param array The record
253 * @param boolean (Ignore)
254 * @return string Wrapping title string.
255 */
256 function wrapTitle($title,$v,$ext_pArrPages='') {
257 if ($this->ext_isLinkable($v['doktype'],$v['uid'])) {
258 $aOnClick = "return link_typo3Page('".$v['uid']."');";
259 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
260 } else {
261 return '<span style="color: #666666;">'.$title.'</span>';
262 }
263 }
264
265 /**
266 * Create the page navigation tree in HTML
267 *
268 * @param array Tree array
269 * @return string HTML output.
270 */
271 function printTree($treeArr='') {
272 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
273 if (!is_array($treeArr)) $treeArr=$this->tree;
274
275 $out='';
276 $c=0;
277
278 foreach($treeArr as $k => $v) {
279 $c++;
280 $bgColorClass = ($c+1)%2 ? 'bgColor' : 'bgColor-10';
281 if ($GLOBALS['SOBE']->browser->curUrlInfo['act']=='page' && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']==$v['row']['uid'] && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']) {
282 $arrCol='<td><img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
283 $bgColorClass='bgColor4';
284 } else {
285 $arrCol='<td></td>';
286 }
287
288 $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandPage='.$v['row']['uid'].'\');';
289 $cEbullet = $this->ext_isLinkable($v['row']['doktype'],$v['row']['uid']) ?
290 '<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/ol/arrowbullet.gif','width="18" height="16"').' alt="" /></a>' :
291 '';
292 $out.='
293 <tr class="'.$bgColorClass.'">
294 <td nowrap="nowrap"'.($v['row']['_CSSCLASS'] ? ' class="'.$v['row']['_CSSCLASS'].'"' : '').'>'.
295 $v['HTML'].
296 $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$this->ext_pArrPages).
297 '</td>'.
298 $arrCol.
299 '<td>'.$cEbullet.'</td>
300 </tr>';
301 }
302 $out='
303
304
305 <!--
306 Navigation Page Tree:
307 -->
308 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
309 '.$out.'
310 </table>';
311 return $out;
312 }
313
314 /**
315 * Returns TRUE if a doktype can be linked.
316 *
317 * @param integer Doktype value to test
318 * @param integer uid to test.
319 * @return boolean
320 */
321 function ext_isLinkable($doktype,$uid) {
322 if ($uid && $doktype<199) {
323 return TRUE;
324 }
325 }
326
327 /**
328 * Wrap the plus/minus icon in a link
329 *
330 * @param string HTML string to wrap, probably an image tag.
331 * @param string Command for 'PM' get var
332 * @param boolean If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
333 * @return string Link-wrapped input string
334 */
335 function PM_ATagWrap($icon,$cmd,$bMark='') {
336 if ($bMark) {
337 $anchor = '#'.$bMark;
338 $name=' name="'.$bMark.'"';
339 }
340 $aOnClick = "return jumpToUrl('".$this->thisScript.'?PM='.$cmd."','".$anchor."');";
341
342 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
343 }
344
345 /**
346 * Wrapping the image tag, $icon, for the row, $row
347 *
348 * @param string The image tag for the icon
349 * @param array The row for the current element
350 * @return string The processed icon input value.
351 */
352 function wrapIcon($icon, $row) {
353 $content = $this->addTagAttributes($icon, ' title="id=' . $row['uid'] . '"');
354 if ($this->ext_showPageId) {
355 $content .= '[' . $row['uid'] . ']&nbsp;';
356 }
357 return $content;
358 }
359 }
360
361
362
363
364
365
366
367
368 /**
369 * Page tree for the RTE - totally the same, no changes needed. (Just for the sake of beauty - or confusion... :-)
370 *
371 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
372 * @package TYPO3
373 * @subpackage core
374 */
375 class rtePageTree extends localPageTree {
376 }
377
378
379
380
381
382
383
384
385 /**
386 * For TBE record browser
387 *
388 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
389 * @package TYPO3
390 * @subpackage core
391 */
392 class TBE_PageTree extends localPageTree {
393
394 /**
395 * Returns TRUE if a doktype can be linked (which is always the case here).
396 *
397 * @param integer Doktype value to test
398 * @param integer uid to test.
399 * @return boolean
400 */
401 function ext_isLinkable($doktype,$uid) {
402 return TRUE;
403 }
404
405 /**
406 * Wrapping the title in a link, if applicable.
407 *
408 * @param string Title, ready for output.
409 * @param array The record
410 * @param boolean If set, pages clicked will return immediately, otherwise reload page.
411 * @return string Wrapping title string.
412 */
413 function wrapTitle($title,$v,$ext_pArrPages) {
414 if ($ext_pArrPages) {
415 $ficon=t3lib_iconWorks::getIcon('pages',$v);
416 $onClick = "return insertElement('pages', '".$v['uid']."', 'db', ".t3lib_div::quoteJSvalue($v['title']).", '', '', '".$ficon."','',1);";
417 } else {
418 $onClick = htmlspecialchars('return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandPage='.$v['uid'].'\');');
419 }
420 return '<a href="#" onclick="'.$onClick.'">'.$title.'</a>';
421 }
422 }
423
424
425
426
427
428
429
430
431 /**
432 * Base extension class which generates the folder tree.
433 * Used directly by the RTE.
434 * also used for the linkpicker on files
435 *
436 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
437 * @package TYPO3
438 * @subpackage core
439 */
440 class localFolderTree extends t3lib_folderTree {
441 var $ext_IconMode=1;
442
443
444 /**
445 * Initializes the script path
446 *
447 * @return void
448 */
449 function __construct() {
450 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
451 parent::__construct();
452 }
453
454 /**
455 * Wrapping the title in a link, if applicable.
456 *
457 * @param string $title Title, ready for output.
458 * @param t3lib_file_Folder $folderObject The "record"
459 * @return string Wrapping title string.
460 */
461 function wrapTitle($title, t3lib_file_Folder $folderObject) {
462 if ($this->ext_isLinkable($folderObject)) {
463 $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandFolder='.rawurlencode($folderObject->getCombinedIdentifier()).'\');';
464 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
465 } else {
466 return '<span class="typo3-dimmed">'.$title.'</span>';
467 }
468 }
469
470 /**
471 * Returns TRUE if the input "record" contains a folder which can be linked.
472 *
473 * @param t3lib_file_Folder $folderObject Object with information about the folder element. Contains keys like title, uid, path, _title
474 * @return boolean TRUE is returned if the path is found in the web-part of the server and is NOT a recycler or temp folder
475 */
476 function ext_isLinkable(t3lib_file_Folder $folderObject) {
477 if (!$folderObject->getStorage()->isPublic() || strstr($folderObject->getIdentifier(), '_recycler_') || strstr($folderObject->getIdentifier(), '_temp_')) {
478 return FALSE;
479 } else {
480 return TRUE;
481 }
482 }
483
484 /**
485 * Wrap the plus/minus icon in a link
486 *
487 * @param string HTML string to wrap, probably an image tag.
488 * @param string Command for 'PM' get var
489 * @param boolean If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
490 * @return string Link-wrapped input string
491 * @access private
492 */
493 function PM_ATagWrap($icon,$cmd,$bMark='') {
494 if ($bMark) {
495 $anchor = '#'.$bMark;
496 $name=' name="'.$bMark.'"';
497 }
498 $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?PM='.$cmd.'\',\''.$anchor.'\');';
499 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
500 }
501 }
502
503
504
505
506
507
508 /**
509 * Folder tree for the RTE - totally the same, no changes needed. (Just for the sake of beauty - or confusion... :-)
510 *
511 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
512 * @package TYPO3
513 * @subpackage core
514 */
515 class rteFolderTree extends localFolderTree {
516 }
517
518
519
520
521
522
523
524 /**
525 * For TBE File Browser
526 *
527 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
528 * @package TYPO3
529 * @subpackage core
530 */
531 class TBE_FolderTree extends localFolderTree {
532 var $ext_noTempRecyclerDirs=0; // If file-drag mode is set, temp and recycler folders are filtered out.
533
534 /**
535 * Returns TRUE if the input "record" contains a folder which can be linked.
536 *
537 * @param t3lib_file_Folder $folderObject object with information about the folder element. Contains keys like title, uid, path, _title
538 * @return boolean TRUE is returned if the path is NOT a recycler or temp folder AND if ->ext_noTempRecyclerDirs is not set.
539 */
540 function ext_isLinkable($folderObject) {
541 if ($this->ext_noTempRecyclerDirs && (substr($folderObject->getIdentifier(), -7)=='_temp_/' || substr($folderObject->getIdentifier(),-11)=='_recycler_/')) {
542 return FALSE;
543 } else {
544 return TRUE;
545 }
546 }
547
548 /**
549 * Wrapping the title in a link, if applicable.
550 *
551 * @param string $title Title, ready for output.
552 * @param t3lib_file_Folder $folderObject The folderObject 'record'
553 * @return string Wrapping title string.
554 */
555 function wrapTitle($title, $folderObject) {
556 if ($this->ext_isLinkable($folderObject)) {
557 $aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode.'&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier()) . '\');';
558 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
559 } else {
560 return '<span class="typo3-dimmed">' . $title . '</span>';
561 }
562 }
563 }
564
565
566
567
568
569 /**
570 * class for the Element Browser window.
571 *
572 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
573 * @package TYPO3
574 * @subpackage core
575 */
576 class browse_links {
577
578 // Internal, static:
579 var $siteURL; // Current site URL (Frontend)
580 var $thisScript; // the script to link to
581 var $thisConfig; // RTE specific TSconfig
582 var $setTarget; // Target (RTE specific)
583 var $setClass; // CSS Class (RTE specific)
584 var $setTitle; // title (RTE specific)
585 var $doc; // Backend template object
586 var $elements = array(); // Holds information about files
587
588 // GPvars: (Input variables from outside)
589 /**
590 * The mode determines the main kind of output from the element browser.
591 * There are these options for values: rte, db, file, filedrag, wizard.
592 * "rte" will show the link selector for the Rich Text Editor (see main_rte())
593 * "db" will allow you to browse for pages or records in the page tree (for TCEforms, see main_db())
594 * "file"/"filedrag" will allow you to browse for files or folders in the folder mounts (for TCEforms, main_file())
595 * "wizard" will allow you to browse for links (like "rte") which are passed back to TCEforms (see main_rte(1))
596 *
597 * @see main()
598 */
599 var $mode;
600
601 /**
602 * Link selector action.
603 * page,file,url,mail,spec are allowed values.
604 * These are only important with the link selector function and in that case they switch between the various menu options.
605 */
606 var $act;
607
608 /**
609 * When you click a page title/expand icon to see the content of a certain page, this value will contain that value (the ID of the expanded page). If the value is NOT set, then it will be restored from the module session data (see main(), mode="db")
610 */
611 var $expandPage;
612
613 /**
614 * When you click a folder name/expand icon to see the content of a certain file folder, this value will contain that value (the path of the expanded file folder). If the value is NOT set, then it will be restored from the module session data (see main(), mode="file"/"filedrag"). Example value: "/www/htdocs/typo3/32/3dsplm/fileadmin/css/"
615 */
616 var $expandFolder;
617
618 /**
619 * the folder object of a parent folder that was selected
620 * @param t3lib_file_Folder
621 */
622 protected $selectedFolder;
623
624 /**
625 * TYPO3 Element Browser, wizard mode parameters. There is a heap of parameters there, better debug() them out if you need something... :-)
626 */
627 var $P;
628
629 /**
630 * Active with TYPO3 Element Browser: Contains the name of the form field for which this window opens - thus allows us to make references back to the main window in which the form is.
631 * Example value: "data[pages][39][bodytext]|||tt_content|" or "data[tt_content][NEW3fba56fde763d][image]|||gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai|"
632 *
633 * Values:
634 * 0: form field name reference, eg. "data[tt_content][123][image]"
635 * 1: htlmArea RTE parameters: editorNo:contentTypo3Language:contentTypo3Charset
636 * 2: RTE config parameters: RTEtsConfigParams
637 * 3: allowed types. Eg. "tt_content" or "gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai"
638 * 4: IRRE uniqueness: target level object-id to perform actions/checks on, eg. "data[79][tt_address][1][<field>][<foreign_table>]"
639 * 5: IRRE uniqueness: name of function in opener window that checks if element is already used, eg. "inline.checkUniqueElement"
640 * 6: IRRE uniqueness: name of function in opener window that performs some additional(!) action, eg. "inline.setUniqueElement"
641 * 7: IRRE uniqueness: name of function in opener window that performs action instead of using addElement/insertElement, eg. "inline.importElement"
642 *
643 * $pArr = explode('|',$this->bparams);
644 * $formFieldName = $pArr[0];
645 * $allowedTablesOrFileTypes = $pArr[3];
646 */
647 var $bparams;
648
649 /**
650 * Used with the Rich Text Editor.
651 * Example value: "tt_content:NEW3fba58c969f5c:bodytext:23:text:23:"
652 */
653 var $RTEtsConfigParams;
654
655
656
657
658 /**
659 * Plus/Minus icon value. Used by the tree class to open/close notes on the trees.
660 */
661 var $PM;
662
663 /**
664 * Pointer, used when browsing a long list of records etc.
665 */
666 var $pointer;
667
668
669
670
671 /**
672 * Used with the link selector: Contains the GET input information about the CURRENT link in the RTE/TCEform field. This consists of "href", "target" and "title" keys. This information is passed around in links.
673 */
674 var $curUrlArray;
675
676 /**
677 * Used with the link selector: Contains a processed version of the input values from curUrlInfo. This is splitted into pageid, content element id, label value etc. This is used for the internal processing of that information.
678 */
679 var $curUrlInfo;
680
681 /**
682 * array which holds hook objects (initialised in init() )
683 */
684 protected $hookObjects = array();
685
686
687 /**
688 * object for t3lib_basicFileFunctions
689 */
690 public $fileProcessor;
691
692 /**
693 * Constructor:
694 * Initializes a lot of variables, setting JavaScript functions in header etc.
695 *
696 * @return void
697 */
698 function init() {
699 // Main GPvars:
700 $this->pointer = t3lib_div::_GP('pointer');
701 $this->bparams = t3lib_div::_GP('bparams');
702 $this->P = t3lib_div::_GP('P');
703 $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
704 $this->expandPage = t3lib_div::_GP('expandPage');
705 $this->expandFolder = t3lib_div::_GP('expandFolder');
706 $this->PM = t3lib_div::_GP('PM');
707
708 // Find "mode"
709 $this->mode = t3lib_div::_GP('mode');
710 if (!$this->mode) {
711 $this->mode = 'rte';
712 }
713 // Creating backend template object:
714 $this->doc = t3lib_div::makeInstance('template');
715 $this->doc->backPath = $GLOBALS['BACK_PATH'];
716 // Load the Prototype library and browse_links.js
717 $this->doc->getPageRenderer()->loadPrototype();
718 $this->doc->loadJavascriptLib('js/browse_links.js');
719 $this->doc->loadJavascriptLib('js/tree.js');
720
721 // init hook objects:
722 $this->hookObjects = array();
723 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'])) {
724 foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'] as $classData) {
725 $processObject = t3lib_div::getUserObj($classData);
726
727 if(!($processObject instanceof t3lib_browseLinksHook)) {
728 throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195039394);
729 }
730
731 $parameters = array();
732 $processObject->init($this, $parameters);
733 $this->hookObjects[] = $processObject;
734 }
735 }
736
737 // Site URL
738 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL'); // Current site url
739
740 // the script to link to
741 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
742
743 // init fileProcessor
744 $this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
745 $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
746
747
748 // CurrentUrl - the current link url must be passed around if it exists
749 if ($this->mode == 'wizard') {
750 $currentValues = t3lib_div::trimExplode(LF, trim($this->P['currentValue']));
751 if (count($currentValues) > 0) {
752 $currentValue = array_pop($currentValues);
753 } else {
754 $currentValue = '';
755 }
756
757 $currentLinkParts = t3lib_div::unQuoteFilenames($currentValue, TRUE);
758
759 $initialCurUrlArray = array (
760 'href' => $currentLinkParts[0],
761 'target' => $currentLinkParts[1],
762 'class' => $currentLinkParts[2],
763 'title' => $currentLinkParts[3],
764 'params' => $currentLinkParts[4]
765 );
766
767 $this->curUrlArray = (is_array(t3lib_div::_GP('curUrl'))) ?
768 array_merge($initialCurUrlArray, t3lib_div::_GP('curUrl')) :
769 $initialCurUrlArray;
770
771 // additional fields for page links
772 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendUrlArray']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendUrlArray'])) {
773 $_params = array(
774 'conf' => &$conf,
775 'linkParts' => $currentLinkParts
776 );
777 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendUrlArray'] as $objRef) {
778 $processor = &t3lib_div::getUserObj($objRef);
779 $processor->extendUrlArray( $_params, $this);
780 }
781 }
782
783 $this->curUrlInfo = $this->parseCurUrl($this->siteURL.'?id='.$this->curUrlArray['href'], $this->siteURL);
784 if ($this->curUrlInfo['pageid'] == 0 && $this->curUrlArray['href']) { // pageid == 0 means that this is not an internal (page) link
785 // check if there is the FAL API
786 if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], 'file:')) {
787 $this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'], $this->siteURL);
788 $currentLinkParts[0] = rawurldecode(substr($this->curUrlArray['href'], 5)); // remove the "file:" prefix
789
790 // check if this is a link to a file
791 } elseif (file_exists(PATH_site.rawurldecode($this->curUrlArray['href']))) {
792 if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], PATH_site)) {
793 $currentLinkParts[0] = substr($this->curUrlArray['href'], strlen(PATH_site));
794 }
795 $this->curUrlInfo = $this->parseCurUrl($this->siteURL.$this->curUrlArray['href'], $this->siteURL);
796 } elseif (strstr($this->curUrlArray['href'], '@')) { // check for email link
797 if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], 'mailto:')) {
798 $currentLinkParts[0] = substr($this->curUrlArray['href'], 7);
799 }
800 $this->curUrlInfo = $this->parseCurUrl('mailto:'.$this->curUrlArray['href'], $this->siteURL);
801 } else { // nothing of the above. this is an external link
802 if(strpos($this->curUrlArray['href'], '://') === FALSE) {
803 $currentLinkParts[0] = 'http://' . $this->curUrlArray['href'];
804 }
805 $this->curUrlInfo = $this->parseCurUrl($currentLinkParts[0], $this->siteURL);
806 }
807 } elseif (!$this->curUrlArray['href']) {
808 $this->curUrlInfo = array();
809 $this->act = 'page';
810 } else {
811 $this->curUrlInfo = $this->parseCurUrl($this->siteURL.'?id='.$this->curUrlArray['href'], $this->siteURL);
812 }
813 } else {
814 $this->curUrlArray = t3lib_div::_GP('curUrl');
815 if ($this->curUrlArray['all']) {
816 $this->curUrlArray=t3lib_div::get_tag_attributes($this->curUrlArray['all']);
817 }
818 $this->curUrlInfo=$this->parseCurUrl($this->curUrlArray['href'],$this->siteURL);
819 }
820
821 // Determine nature of current url:
822 $this->act=t3lib_div::_GP('act');
823 if (!$this->act) {
824 $this->act=$this->curUrlInfo['act'];
825 }
826
827 // Rich Text Editor specific configuration:
828 $addPassOnParams='';
829 if ((string)$this->mode == 'rte') {
830 $RTEtsConfigParts = explode(':',$this->RTEtsConfigParams);
831 $addPassOnParams.='&RTEtsConfigParams='.rawurlencode($this->RTEtsConfigParams);
832 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
833 $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
834 }
835
836 // Initializing the target value (RTE)
837 $this->setTarget = ($this->curUrlArray['target'] != '-') ? rawurlencode($this->curUrlArray['target']) : '';
838 if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target'])) {
839 $this->setTarget=$this->thisConfig['defaultLinkTarget'];
840 }
841
842 // Initializing the class value (RTE)
843 $this->setClass = ($this->curUrlArray['class'] != '-') ? rawurlencode($this->curUrlArray['class']) : '';
844
845 // Initializing the title value (RTE)
846
847 $this->setTitle = ($this->curUrlArray['title'] != '-') ? rawurlencode($this->curUrlArray['title']) : '';
848 // Initializing the params value
849 $this->setParams = ($this->curUrlArray['params'] != '-') ? rawurlencode($this->curUrlArray['params']) : '';
850
851 // BEGIN accumulation of header JavaScript:
852 $JScode = '
853 // This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
854 var add_href="'.($this->curUrlArray['href']?'&curUrl[href]='.rawurlencode($this->curUrlArray['href']):'').'";
855 var add_target="'.($this->setTarget?'&curUrl[target]='.rawurlencode($this->setTarget):'').'";
856 var add_class="'.($this->setClass ? '&curUrl[class]='.rawurlencode($this->setClass) : '').'";
857 var add_title="'.($this->setTitle?'&curUrl[title]='.rawurlencode($this->setTitle):'').'";
858 var add_params="'.($this->bparams?'&bparams='.rawurlencode($this->bparams):'').'";
859
860 var cur_href="' . ($this->curUrlArray['href'] ? rawurlencode($this->curUrlArray['href']) : '') . '";
861 var cur_target="'.($this->setTarget?$this->setTarget:'').'";
862 var cur_class = "' . ($this->setClass ? $this->setClass : '') . '";
863 var cur_title="'.($this->setTitle?$this->setTitle:'').'";
864 var cur_params="' . ($this->setParams ? $this->setParams : '') . '";
865
866 function browse_links_setTarget(target) { //
867 cur_target=target;
868 add_target="&curUrl[target]="+escape(target);
869 }
870 function browse_links_setClass(cssClass) { //
871 cur_class = cssClass;
872 add_class = "&curUrl[class]=" + escape(cssClass);
873 }
874 function browse_links_setTitle(title) { //
875 cur_title=title;
876 add_title="&curUrl[title]="+escape(title);
877 }
878 function browse_links_setValue(value) { //
879 cur_href=value;
880 add_href="&curUrl[href]="+value;
881 }
882 function browse_links_setParams(params) { //
883 cur_params=params;
884 add_params="&curUrl[params]="+escape(params);
885 }
886 ';
887
888 if ($this->mode == 'wizard') { // Functions used, if the link selector is in wizard mode (= TCEforms fields)
889 if (!$this->areFieldChangeFunctionsValid() && !$this->areFieldChangeFunctionsValid(TRUE)) {
890 $this->P['fieldChangeFunc'] = array();
891 }
892 unset($this->P['fieldChangeFunc']['alert']);
893 $update='';
894 foreach ($this->P['fieldChangeFunc'] as $k => $v) {
895 $update.= '
896 window.opener.'.$v;
897 }
898
899 $P2=array();
900 $P2['itemName']=$this->P['itemName'];
901 $P2['formName']=$this->P['formName'];
902 $P2['fieldChangeFunc']=$this->P['fieldChangeFunc'];
903 $P2['fieldChangeFuncHash'] = t3lib_div::hmac(serialize($this->P['fieldChangeFunc']));
904 $P2['params']['allowedExtensions']=$this->P['params']['allowedExtensions'];
905 $P2['params']['blindLinkOptions']=$this->P['params']['blindLinkOptions'];
906 $P2['params']['blindLinkFields'] = $this->P['params']['blindLinkFields'];
907 $addPassOnParams.=t3lib_div::implodeArrayForUrl('P',$P2);
908
909 $JScode.='
910 function link_typo3Page(id,anchor) { //
911 updateValueInMainForm(id + (anchor ? anchor : ""));
912 close();
913 return false;
914 }
915 function link_folder(folder) { //
916 updateValueInMainForm(folder);
917 close();
918 return false;
919 }
920 function link_current() { //
921 if (cur_href!="http://" && cur_href!="mailto:") {
922 returnBeforeCleaned = cur_href;
923 if (returnBeforeCleaned.substr(0, 7) == "http://") {
924 returnToMainFormValue = returnBeforeCleaned.substr(7);
925 } else if (returnBeforeCleaned.substr(0, 7) == "mailto:") {
926 if (returnBeforeCleaned.substr(0, 14) == "mailto:mailto:") {
927 returnToMainFormValue = returnBeforeCleaned.substr(14);
928 } else {
929 returnToMainFormValue = returnBeforeCleaned.substr(7);
930 }
931 } else {
932 returnToMainFormValue = returnBeforeCleaned;
933 }
934 updateValueInMainForm(returnToMainFormValue);
935 close();
936 }
937 return false;
938 }
939 function checkReference() { //
940 if (window.opener && window.opener.document && window.opener.document.'.$this->P['formName'].' && window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"] ) {
941 return window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"];
942 } else {
943 close();
944 }
945 }
946 function updateValueInMainForm(input) { //
947 var field = checkReference();
948 if (field) {
949 if (cur_target == "" && (cur_class != "" || cur_title != "" || cur_params != "")) {
950 cur_target = "-";
951 }
952 if (cur_class == "" && (cur_title != "" || cur_params != "")) {
953 cur_class = "-";
954 }
955 cur_class = cur_class.replace(/[\'\"]/g, "");
956 if (cur_class.indexOf(" ") != -1) {
957 cur_class = "\"" + cur_class + "\"";
958 }
959 if (cur_title == "" && cur_params != "") {
960 cur_title = "-";
961 }
962 cur_title = cur_title.replace(/(^\")|(\"$)/g, "");
963 if (cur_title.indexOf(" ") != -1) {
964 cur_title = "\"" + cur_title + "\"";
965 }
966 if (cur_params) {
967 cur_params = cur_params.replace(/\bid\=.*?(\&|$)/, "");
968 }
969 input = input + " " + cur_target + " " + cur_class + " " + cur_title + " " + cur_params;
970 if(field.value && field.className.search(/textarea/) != -1) {
971 field.value += "\n" + input;
972 } else {
973 field.value = input;
974 }
975 '.$update.'
976 }
977 }
978 ';
979 } else { // Functions used, if the link selector is in RTE mode:
980 $JScode.='
981 function link_typo3Page(id,anchor) { //
982 var theLink = \''.$this->siteURL.'?id=\'+id+(anchor?anchor:"");
983 self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
984 return false;
985 }
986 function link_folder(folder) { //
987 var theLink = \''.$this->siteURL.'\'+folder;
988 self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
989 return false;
990 }
991 function link_spec(theLink) { //
992 self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
993 return false;
994 }
995 function link_current() { //
996 if (cur_href!="http://" && cur_href!="mailto:") {
997 self.parent.parent.renderPopup_addLink(cur_href, cur_target, cur_class, cur_title);
998 }
999 return false;
1000 }
1001 ';
1002 }
1003
1004 // General "jumpToUrl" function:
1005 $JScode.='
1006 function jumpToUrl(URL,anchor) { //
1007 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
1008 var add_mode = URL.indexOf("mode=")==-1 ? "&mode='.$this->mode.'" : "";
1009 var theLocation = URL + add_act + add_mode + add_href + add_target + add_class + add_title + add_params'.($addPassOnParams?'+"'.$addPassOnParams.'"':'').'+(anchor?anchor:"");
1010 window.location.href = theLocation;
1011 return false;
1012 }
1013 ';
1014
1015
1016 /**
1017 * Splits parts of $this->bparams
1018 * @see $bparams
1019 */
1020 $pArr = explode('|',$this->bparams);
1021
1022 // This is JavaScript especially for the TBE Element Browser!
1023 $formFieldName = 'data['.$pArr[0].']['.$pArr[1].']['.$pArr[2].']';
1024
1025 // insertElement - Call check function (e.g. for uniqueness handling):
1026 if ($pArr[4] && $pArr[5]) {
1027 $JScodeCheck = '
1028 // Call a check function in the opener window (e.g. for uniqueness handling):
1029 if (parent.window.opener) {
1030 var res = parent.window.opener.'.$pArr[5].'("'.addslashes($pArr[4]).'",table,uid,type);
1031 if (!res.passed) {
1032 if (res.message) alert(res.message);
1033 performAction = false;
1034 }
1035 } else {
1036 alert("Error - reference to main window is not set properly!");
1037 parent.close();
1038 }
1039 ';
1040 }
1041 // insertElement - Call helper function:
1042 if ($pArr[4] && $pArr[6]) {
1043 $JScodeHelper = '
1044 // Call helper function to manage data in the opener window:
1045 if (parent.window.opener) {
1046 parent.window.opener.'.$pArr[6].'("'.addslashes($pArr[4]).'",table,uid,type,"'.addslashes($pArr[0]).'");
1047 } else {
1048 alert("Error - reference to main window is not set properly!");
1049 parent.close();
1050 }
1051 ';
1052 }
1053 // insertElement - perform action commands:
1054 if ($pArr[4] && $pArr[7]) {
1055 // Call user defined action function:
1056 $JScodeAction = '
1057 if (parent.window.opener) {
1058 parent.window.opener.'.$pArr[7].'("'.addslashes($pArr[4]).'",table,uid,type);
1059 if (close) { focusOpenerAndClose(close); }
1060 } else {
1061 alert("Error - reference to main window is not set properly!");
1062 if (close) { parent.close(); }
1063 }
1064 ';
1065 $JScodeActionMultiple = '
1066 // Call helper function to manage data in the opener window:
1067 if (parent.window.opener) {
1068 parent.window.opener.' . $pArr[7] . 'Multiple("' . addslashes($pArr[4]) . '",table,uid,type,"' . addslashes($pArr[0]) . '");
1069 } else {
1070 alert("Error - reference to main window is not set properly!");
1071 parent.close();
1072 }
1073 ';
1074 } elseif ($pArr[0] && !$pArr[1] && !$pArr[2]) {
1075 $JScodeAction = '
1076 addElement(filename,table+"_"+uid,fp,close);
1077 ';
1078 } else {
1079 $JScodeAction = '
1080 if (setReferences()) {
1081 parent.window.opener.group_change("add","'.$pArr[0].'","'.$pArr[1].'","'.$pArr[2].'",elRef,targetDoc);
1082 } else {
1083 alert("Error - reference to main window is not set properly!");
1084 }
1085 focusOpenerAndClose(close);
1086 ';
1087 }
1088
1089 $JScode.='
1090 var elRef="";
1091 var targetDoc="";
1092
1093 function launchView(url) { //
1094 var thePreviewWindow="";
1095 thePreviewWindow = window.open("'.$GLOBALS['BACK_PATH'].'show_item.php?table="+url,"ShowItem","height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
1096 if (thePreviewWindow && thePreviewWindow.focus) {
1097 thePreviewWindow.focus();
1098 }
1099 }
1100 function setReferences() { //
1101 if (parent.window.opener && parent.window.opener.content && parent.window.opener.content.document.editform && parent.window.opener.content.document.editform["'.$formFieldName.'"]) {
1102 targetDoc = parent.window.opener.content.document;
1103 elRef = targetDoc.editform["'.$formFieldName.'"];
1104 return true;
1105 } else {
1106 return false;
1107 }
1108 }
1109 function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close) { //
1110 var performAction = true;
1111 '.$JScodeCheck.'
1112 // Call performing function and finish this action:
1113 if (performAction) {
1114 '.$JScodeHelper.$JScodeAction.'
1115 }
1116 return false;
1117 }
1118 function insertMultiple(table, uid) {
1119 var type = "";
1120 ' . $JScodeActionMultiple . '
1121 return false;
1122 }
1123 function addElement(elName,elValue,altElValue,close) { //
1124 if (parent.window.opener && parent.window.opener.setFormValueFromBrowseWin) {
1125 parent.window.opener.setFormValueFromBrowseWin("'.$pArr[0].'",altElValue?altElValue:elValue,elName);
1126 focusOpenerAndClose(close);
1127 } else {
1128 alert("Error - reference to main window is not set properly!");
1129 parent.close();
1130 }
1131 }
1132 function focusOpenerAndClose(close) { //
1133 BrowseLinks.focusOpenerAndClose(close);
1134 }
1135 ';
1136
1137 // extends JavaScript code
1138 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendJScode']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendJScode'])) {
1139 $_params = array(
1140 'conf' => &$conf,
1141 'wizardUpdate' => $update,
1142 'addPassOnParams' => $addPassOnParams
1143 );
1144 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendJScode'] as $objRef) {
1145 $processor = &t3lib_div::getUserObj($objRef);
1146 $JScode .= $processor->extendJScode( $_params, $this);
1147 }
1148 }
1149
1150 // Finally, add the accumulated JavaScript to the template object:
1151 $this->doc->JScode.= $this->doc->wrapScriptTags($JScode);
1152
1153 // Debugging:
1154 if (FALSE) debug(array(
1155 'pointer' => $this->pointer,
1156 'act' => $this->act,
1157 'mode' => $this->mode,
1158 'curUrlInfo' => $this->curUrlInfo,
1159 'curUrlArray' => $this->curUrlArray,
1160 'P' => $this->P,
1161 'bparams' => $this->bparams,
1162 'RTEtsConfigParams' => $this->RTEtsConfigParams,
1163 'expandPage' => $this->expandPage,
1164 'expandFolder' => $this->expandFolder,
1165 'PM' => $this->PM,
1166 ),'Internal variables of Script Class:');
1167 }
1168
1169
1170 /**
1171 * Session data for this class can be set from outside with this method.
1172 * Call after init()
1173 *
1174 * @param array Session data array
1175 * @return array Session data and boolean which indicates that data needs to be stored in session because it's changed
1176 */
1177 function processSessionData($data) {
1178 $store = FALSE;
1179
1180 switch((string)$this->mode) {
1181 case 'db':
1182 if (isset($this->expandPage)) {
1183 $data['expandPage']=$this->expandPage;
1184 $store = TRUE;
1185 } else {
1186 $this->expandPage=$data['expandPage'];
1187 }
1188 break;
1189 case 'file':
1190 case 'filedrag':
1191 case 'folder':
1192 if (isset($this->expandFolder)) {
1193 $data['expandFolder']=$this->expandFolder;
1194 $store = TRUE;
1195 } else {
1196 $this->expandFolder=$data['expandFolder'];
1197 }
1198 break;
1199 }
1200
1201 return array($data, $store);
1202 }
1203
1204
1205
1206
1207 /******************************************************************
1208 *
1209 * Main functions
1210 *
1211 ******************************************************************/
1212
1213 /**
1214 * Rich Text Editor (RTE) link selector (MAIN function)
1215 * Generates the link selector for the Rich Text Editor.
1216 * Can also be used to select links for the TCEforms (see $wiz)
1217 *
1218 * @param boolean If set, the "remove link" is not shown in the menu: Used for the "Select link" wizard which is used by the TCEforms
1219 * @return string Modified content variable.
1220 */
1221 function main_rte($wiz=0) {
1222 // Starting content:
1223 $content=$this->doc->startPage('RTE link');
1224
1225 // Initializing the action value, possibly removing blinded values etc:
1226 $allowedItems = array_diff(
1227 explode(',','page,file,folder,url,mail,spec'),
1228 t3lib_div::trimExplode(',',$this->thisConfig['blindLinkOptions'],1)
1229 );
1230 $allowedItems = array_diff(
1231 $allowedItems,
1232 t3lib_div::trimExplode(',',$this->P['params']['blindLinkOptions'])
1233 );
1234
1235 //call hook for extra options
1236 foreach($this->hookObjects as $hookObject) {
1237 $allowedItems = $hookObject->addAllowedItems($allowedItems);
1238 }
1239
1240 // Removing link fields if configured
1241 $allowedFields = array_diff(
1242 array('target', 'title', 'class', 'params'),
1243 t3lib_div::trimExplode(',', $this->thisConfig['blindLinkFields'], TRUE),
1244 t3lib_div::trimExplode(',', $this->P['params']['blindLinkFields'], TRUE)
1245 );
1246
1247 // if $this->act is not allowed, default to first allowed
1248 if (!in_array($this->act, $allowedItems)) {
1249 $this->act = reset($allowedItems);
1250 }
1251
1252 // Making menu in top:
1253 $menuDef = array();
1254 if (!$wiz) {
1255 $menuDef['removeLink']['isActive'] = $this->act=='removeLink';
1256 $menuDef['removeLink']['label'] = $GLOBALS['LANG']->getLL('removeLink', 1);
1257 $menuDef['removeLink']['url'] = '#';
1258 $menuDef['removeLink']['addParams'] = 'onclick="self.parent.parent.renderPopup_unLink();return false;"';
1259 }
1260 if (in_array('page',$allowedItems)) {
1261 $menuDef['page']['isActive'] = $this->act=='page';
1262 $menuDef['page']['label'] = $GLOBALS['LANG']->getLL('page', 1);
1263 $menuDef['page']['url'] = '#';
1264 $menuDef['page']['addParams'] = 'onclick="jumpToUrl(\'?act=page\');return false;"';
1265 }
1266 if (in_array('file',$allowedItems)){
1267 $menuDef['file']['isActive'] = $this->act=='file';
1268 $menuDef['file']['label'] = $GLOBALS['LANG']->getLL('file', 1);
1269 $menuDef['file']['url'] = '#';
1270 $menuDef['file']['addParams'] = 'onclick="jumpToUrl(\'?act=file\');return false;"';
1271 }
1272 if (in_array('folder',$allowedItems)){
1273 $menuDef['folder']['isActive'] = $this->act == 'folder';
1274 $menuDef['folder']['label'] = $GLOBALS['LANG']->getLL('folder', 1);
1275 $menuDef['folder']['url'] = '#';
1276 $menuDef['folder']['addParams'] = 'onclick="jumpToUrl(\'?act=folder\');return false;"';
1277 }
1278 if (in_array('url',$allowedItems)) {
1279 $menuDef['url']['isActive'] = $this->act=='url';
1280 $menuDef['url']['label'] = $GLOBALS['LANG']->getLL('extUrl', 1);
1281 $menuDef['url']['url'] = '#';
1282 $menuDef['url']['addParams'] = 'onclick="jumpToUrl(\'?act=url\');return false;"';
1283 }
1284 if (in_array('mail',$allowedItems)) {
1285 $menuDef['mail']['isActive'] = $this->act=='mail';
1286 $menuDef['mail']['label'] = $GLOBALS['LANG']->getLL('email', 1);
1287 $menuDef['mail']['url'] = '#';
1288 $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(\'?act=mail\');return false;"';
1289 }
1290 if (is_array($this->thisConfig['userLinks.']) && in_array('spec',$allowedItems)) {
1291 $menuDef['spec']['isActive'] = $this->act=='spec';
1292 $menuDef['spec']['label'] = $GLOBALS['LANG']->getLL('special', 1);
1293 $menuDef['spec']['url'] = '#';
1294 $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(\'?act=spec\');return false;"';
1295 }
1296
1297 // call hook for extra options
1298 foreach($this->hookObjects as $hookObject) {
1299 $menuDef = $hookObject->modifyMenuDefinition($menuDef);
1300 }
1301
1302 $content .= $this->doc->getTabMenuRaw($menuDef);
1303
1304 // Adding the menu and header to the top of page:
1305 $content.=$this->printCurrentUrl($this->curUrlInfo['info']).'<br />';
1306
1307 // Depending on the current action we will create the actual module content for selecting a link:
1308 switch($this->act) {
1309 case 'mail':
1310 $extUrl='
1311
1312 <!--
1313 Enter mail address:
1314 -->
1315 <form action="" name="lurlform" id="lurlform">
1316 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
1317 <tr>
1318 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('emailAddress', 1) . ':</td>
1319 <td><input type="text" name="lemail"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='mail'?$this->curUrlInfo['info']:'').'" /> '.
1320 '<input type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', 1) . '" onclick="browse_links_setTarget(\'\');browse_links_setValue(\'mailto:\'+document.lurlform.lemail.value); return link_current();" /></td>
1321 </tr>
1322 </table>
1323 </form>';
1324 $content.=$extUrl;
1325 break;
1326 case 'url':
1327 $extUrl='
1328
1329 <!--
1330 Enter External URL:
1331 -->
1332 <form action="" name="lurlform" id="lurlform">
1333 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
1334 <tr>
1335 <td style="width: 96px;">URL:</td>
1336 <td><input type="text" name="lurl"'.$this->doc->formWidth(30).' value="'.htmlspecialchars($this->curUrlInfo['act']=='url'?$this->curUrlInfo['info']:'http://').'" /> '.
1337 '<input type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', 1) . '" onclick="browse_links_setValue(document.lurlform.lurl.value); return link_current();" /></td>
1338 </tr>
1339 </table>
1340 </form>';
1341 $content.=$extUrl;
1342 break;
1343 case 'file':
1344 case 'folder':
1345 $foldertree = t3lib_div::makeInstance('rteFolderTree');
1346 $foldertree->thisScript = $this->thisScript;
1347 $tree = $foldertree->getBrowsableTree();
1348
1349 if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act'] != $this->act) {
1350 $cmpPath = '';
1351 } else {
1352 $cmpPath = $this->curUrlInfo['value'];
1353 if (!isset($this->expandFolder)) {
1354 $this->expandFolder = $cmpPath;
1355 }
1356 }
1357
1358 if ($this->expandFolder) {
1359 $selectedFolder = FALSE;
1360
1361 $fileOrFolderObject = t3lib_file_Factory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
1362 // it's a file
1363 if ($fileOrFolderObject instanceof t3lib_file_Folder) {
1364 $selectedFolder = $fileOrFolderObject;
1365
1366 } elseif ($fileOrFolderObject instanceof t3lib_file_FileInterface) {
1367 // @todo: find the parent folder, right now done a bit ugly, because the file does not
1368 // support finding the parent folder of a file on purpose
1369 $folderIdentifier = dirname($fileOrFolderObject->getIdentifier());
1370 $selectedFolder = $fileOrFolderObject->getStorage()->getFolder($folderIdentifier);
1371 }
1372 }
1373 // render the filelist if there is a folder selected
1374 if ($selectedFolder) {
1375 $files = $this->expandFolder(
1376 $selectedFolder,
1377 $this->P['params']['allowedExtensions']
1378 );
1379 }
1380
1381 $this->doc->JScode .= $this->doc->wrapScriptTags('
1382 Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
1383 ');
1384
1385 $content.= '
1386 <!--
1387 Wrapper table for folder tree / file/folder list:
1388 -->
1389 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
1390 <tr>
1391 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1392 <td class="c-wCell" valign="top">'.$files.'</td>
1393 </tr>
1394 </table>
1395 ';
1396 break;
1397 case 'spec':
1398 if (is_array($this->thisConfig['userLinks.'])) {
1399 $subcats=array();
1400 $v=$this->thisConfig['userLinks.'];
1401 foreach ($v as $k2 => $value) {
1402 $k2i = intval($k2);
1403 if (substr($k2,-1)=='.' && is_array($v[$k2i.'.'])) {
1404
1405 // Title:
1406 $title = trim($v[$k2i]);
1407 if (!$title) {
1408 $title=$v[$k2i.'.']['url'];
1409 } else {
1410 $title = $GLOBALS['LANG']->sL($title);
1411 }
1412 // Description:
1413 $description = ($v[$k2i . '.']['description'] ? $GLOBALS['LANG']->sL($v[$k2i . '.']['description'], 1) . '<br />' : '');
1414
1415 // URL + onclick event:
1416 $onClickEvent='';
1417 if (isset($v[$k2i.'.']['target'])) $onClickEvent.="browse_links_setTarget('".$v[$k2i.'.']['target']."');";
1418 $v[$k2i.'.']['url'] = str_replace('###_URL###',$this->siteURL,$v[$k2i.'.']['url']);
1419 if (substr($v[$k2i.'.']['url'],0,7)=='http://' || substr($v[$k2i.'.']['url'],0,7)=='mailto:') {
1420 $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i.'.']['url'])."');link_current();";
1421 } else {
1422 $onClickEvent.="link_spec(unescape('".$this->siteURL.rawurlencode($v[$k2i.'.']['url'])."'));";
1423 }
1424
1425 // Link:
1426 $A=array('<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">','</a>');
1427
1428 // Adding link to menu of user defined links:
1429 $subcats[$k2i]='
1430 <tr>
1431 <td class="bgColor4">'.$A[0].'<strong>'.htmlspecialchars($title).($this->curUrlInfo['info']==$v[$k2i.'.']['url']?'<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" />':'').'</strong><br />'.$description.$A[1].'</td>
1432 </tr>';
1433 }
1434 }
1435
1436 // Sort by keys:
1437 ksort($subcats);
1438
1439 // Add menu to content:
1440 $content.= '
1441
1442 <!--
1443 Special userdefined menu:
1444 -->
1445 <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
1446 <tr>
1447 <td class="bgColor5" class="c-wCell" valign="top"><strong>' . $GLOBALS['LANG']->getLL('special', 1) . '</strong></td>
1448 </tr>
1449 '.implode('',$subcats).'
1450 </table>
1451 ';
1452 }
1453 break;
1454 case 'page':
1455 $pagetree = t3lib_div::makeInstance('rtePageTree');
1456 $pagetree->thisScript = $this->thisScript;
1457 $pagetree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
1458 $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
1459 $pagetree->addField('nav_title');
1460 $tree=$pagetree->getBrowsableTree();
1461 $cElements = $this->expandPage();
1462
1463 // Outputting Temporary DB mount notice:
1464 if (intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint'))) {
1465 $link = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))) . '">' .
1466 $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount', 1) .
1467 '</a>';
1468 $flashMessage = t3lib_div::makeInstance(
1469 't3lib_FlashMessage',
1470 $link,
1471 '',
1472 t3lib_FlashMessage::INFO
1473 );
1474 $dbmount = $flashMessage->render();
1475 }
1476
1477 $content.= '
1478
1479 <!--
1480 Wrapper table for page tree / record list:
1481 -->
1482 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
1483 <tr>
1484 <td class="c-wCell" valign="top">' . $this->barheader($GLOBALS['LANG']->getLL('pageTree') . ':') . $dbmount . $tree . '</td>
1485 <td class="c-wCell" valign="top">'.$cElements.'</td>
1486 </tr>
1487 </table>
1488 ';
1489 break;
1490 default:
1491 //call hook
1492 foreach($this->hookObjects as $hookObject) {
1493 $content .= $hookObject->getTab($this->act);
1494 }
1495 break;
1496 }
1497
1498 if (in_array('params', $allowedFields, TRUE)) {
1499 $content .= '
1500 <!--
1501 Selecting params for link:
1502 -->
1503 <form action="" name="lparamsform" id="lparamsform">
1504 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkParams">
1505 <tr>
1506 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('params', 1) . '</td>
1507 <td><input type="text" name="lparams" class="typo3-link-input" onchange="browse_links_setParams(this.value);" value="' . htmlspecialchars($this->setParams) . '" /></td>
1508 </tr>
1509 </table>
1510 </form>
1511 ';
1512 }
1513
1514 if (in_array('class', $allowedFields, TRUE)) {
1515 $content .= '
1516 <!--
1517 Selecting class for link:
1518 -->
1519 <form action="" name="lclassform" id="lclassform">
1520 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkClass">
1521 <tr>
1522 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('class', 1) . '</td>
1523 <td><input type="text" name="lclass" class="typo3-link-input" onchange="browse_links_setClass(this.value);" value="' . htmlspecialchars($this->setClass) . '" /></td>
1524 </tr>
1525 </table>
1526 </form>
1527 ';
1528 }
1529
1530 if (in_array('title', $allowedFields, TRUE)) {
1531 $content .= '
1532 <!--
1533 Selecting title for link:
1534 -->
1535 <form action="" name="ltitleform" id="ltitleform">
1536 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTitle">
1537 <tr>
1538 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('title', 1) . '</td>
1539 <td><input type="text" name="ltitle" class="typo3-link-input" onchange="browse_links_setTitle(this.value);" value="' . htmlspecialchars($this->setTitle) . '" /></td>
1540 </tr>
1541 </table>
1542 </form>
1543 ';
1544 }
1545
1546 // additional fields for page links
1547 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['addFields_PageLink']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['addFields_PageLink'])) {
1548 $_params = array(
1549 'conf' => &$conf,
1550 );
1551 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['addFields_PageLink'] as $objRef) {
1552 $processor = &t3lib_div::getUserObj($objRef);
1553 $content .= $processor->addFields( $_params, $this);
1554 }
1555 }
1556
1557
1558 // Target:
1559 if ($this->act != 'mail' && in_array('target', $allowedFields, TRUE)) {
1560 $ltarget='
1561
1562
1563
1564 <!--
1565 Selecting target for link:
1566 -->
1567 <form action="" name="ltargetform" id="ltargetform">
1568 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
1569 <tr>
1570 <td>'.$GLOBALS['LANG']->getLL('target',1).':</td>
1571 <td><input type="text" name="ltarget" onchange="browse_links_setTarget(this.value);" value="' . htmlspecialchars($this->setTarget) . '"' . $this->doc->formWidth(10) . ' /></td>
1572 <td>
1573 <select name="ltarget_type" onchange="browse_links_setTarget(this.options[this.selectedIndex].value);document.ltargetform.ltarget.value=this.options[this.selectedIndex].value;this.selectedIndex=0;">
1574 <option></option>
1575 <option value="_top">'.$GLOBALS['LANG']->getLL('top',1).'</option>
1576 <option value="_blank">'.$GLOBALS['LANG']->getLL('newWindow',1).'</option>
1577 </select>
1578 </td>
1579 <td>';
1580 if (($this->curUrlInfo['act'] == 'page' || $this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder') && $this->curUrlArray['href'] && $this->curUrlInfo['act'] == $this->act) {
1581 $ltarget.='
1582 <input type="submit" value="'.$GLOBALS['LANG']->getLL('update',1).'" onclick="return link_current();" />';
1583 }
1584
1585 $selectJS = '
1586 if (document.ltargetform.popup_width.options[document.ltargetform.popup_width.selectedIndex].value>0 && document.ltargetform.popup_height.options[document.ltargetform.popup_height.selectedIndex].value>0) {
1587 document.ltargetform.ltarget.value = document.ltargetform.popup_width.options[document.ltargetform.popup_width.selectedIndex].value+"x"+document.ltargetform.popup_height.options[document.ltargetform.popup_height.selectedIndex].value;
1588 browse_links_setTarget(document.ltargetform.ltarget.value);
1589 browse_links_setClass(document.lclassform.lclass.value);
1590 browse_links_setTitle(document.ltitleform.ltitle.value);
1591 browse_links_setParams(document.lparamsform.lparams.value);
1592 document.ltargetform.popup_width.selectedIndex=0;
1593 document.ltargetform.popup_height.selectedIndex=0;
1594 }
1595 ';
1596
1597 $ltarget.=' </td>
1598 </tr>
1599 <tr>
1600 <td>'.$GLOBALS['LANG']->getLL('target_popUpWindow',1).':</td>
1601 <td colspan="3">
1602 <select name="popup_width" onchange="'.htmlspecialchars($selectJS).'">
1603 <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_width',1).'</option>
1604 <option value="300">300</option>
1605 <option value="400">400</option>
1606 <option value="500">500</option>
1607 <option value="600">600</option>
1608 <option value="700">700</option>
1609 <option value="800">800</option>
1610 </select>
1611 x
1612 <select name="popup_height" onchange="'.htmlspecialchars($selectJS).'">
1613 <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_height',1).'</option>
1614 <option value="200">200</option>
1615 <option value="300">300</option>
1616 <option value="400">400</option>
1617 <option value="500">500</option>
1618 <option value="600">600</option>
1619 </select>
1620 </td>
1621 </tr>
1622 </table>
1623 </form>';
1624
1625 // Add "target selector" box to content:
1626 $content.=$ltarget;
1627
1628 // Add some space
1629 $content.='<br /><br />';
1630 }
1631
1632 // End page, return content:
1633 $content.= $this->doc->endPage();
1634 $content = $this->doc->insertStylesAndJS($content);
1635 return $content;
1636 }
1637
1638 /**
1639 * TYPO3 Element Browser: Showing a page tree and allows you to browse for records
1640 *
1641 * @return string HTML content for the module
1642 */
1643 function main_db() {
1644
1645 // Starting content:
1646 $content=$this->doc->startPage('TBE record selector');
1647
1648 // Init variable:
1649 $pArr = explode('|',$this->bparams);
1650
1651 // Making the browsable pagetree:
1652 $pagetree = t3lib_div::makeInstance('TBE_PageTree');
1653 $pagetree->thisScript=$this->thisScript;
1654 $pagetree->ext_pArrPages = !strcmp($pArr[3],'pages')?1:0;
1655 $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
1656 $pagetree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
1657 $pagetree->addField('nav_title');
1658 $tree=$pagetree->getBrowsableTree();
1659
1660 // Making the list of elements, if applicable:
1661 $cElements = $this->TBE_expandPage($pArr[3]);
1662
1663 // Putting the things together, side by side:
1664 $content.= '
1665
1666 <!--
1667 Wrapper table for page tree / record list:
1668 -->
1669 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBrecords">
1670 <tr>
1671 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('pageTree').':').$tree.'</td>
1672 <td class="c-wCell" valign="top">'.$cElements.'</td>
1673 </tr>
1674 </table>
1675 ';
1676
1677 // Add some space
1678 $content.='<br /><br />';
1679
1680 // End page, return content:
1681 $content.= $this->doc->endPage();
1682 $content = $this->doc->insertStylesAndJS($content);
1683 return $content;
1684 }
1685
1686 /**
1687 * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for files.
1688 *
1689 * @return string HTML content for the module
1690 */
1691 function main_file() {
1692 // include JS files and set prefs for foldertree
1693 $this->doc->getDragDropCode('folders');
1694 $this->doc->JScode .= $this->doc->wrapScriptTags('
1695 Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
1696 ');
1697
1698 // Starting content:
1699 $content = $this->doc->startPage('TBE file selector');
1700
1701
1702 // Init variable:
1703 $pArr = explode('|',$this->bparams);
1704 // Create upload/create folder forms, if a path is given:
1705 if ($this->expandFolder) {
1706 $this->selectedFolder = t3lib_file_Factory::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder);
1707 }
1708
1709 // @todo implement upload stuff (default upload folder of a storaget etc)
1710 if (!$this->selectedFolder) {
1711 $fileStorages = $GLOBALS['BE_USER']->getFileStorages();
1712 $fileStorage = reset($fileStorages);
1713 $this->selectedFolder = $fileStorage->getRootLevelFolder();
1714 }
1715
1716 if ($this->selectedFolder) {
1717 $uploadForm = $this->uploadForm($this->selectedFolder);
1718 $createFolder = $this->createFolder($this->selectedFolder);
1719 } else {
1720 $uploadForm = $createFolder = '';
1721 }
1722
1723 if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
1724 $content .= $uploadForm;
1725 }
1726
1727 // Getting flag for showing/not showing thumbnails:
1728 $noThumbs = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
1729
1730 if (!$noThumbs) {
1731 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
1732 $_MOD_MENU = array('displayThumbs' => '');
1733 $_MCONF['name']='file_list';
1734 $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']);
1735 }
1736 $noThumbs = $noThumbs ? $noThumbs : !$_MOD_SETTINGS['displayThumbs'];
1737
1738 // Create folder tree:
1739 $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
1740 $foldertree->thisScript=$this->thisScript;
1741 $foldertree->ext_noTempRecyclerDirs = ($this->mode == 'filedrag');
1742 $tree=$foldertree->getBrowsableTree();
1743
1744 list(,,$specUid) = explode('_',$this->PM);
1745
1746 if ($this->mode=='filedrag') {
1747 $files = $this->TBE_dragNDrop($this->selectedFolder, $pArr[3]);
1748 } else {
1749 $files = $this->TBE_expandFolder($this->selectedFolder, $pArr[3], $noThumbs);
1750 }
1751
1752 // Putting the parts together, side by side:
1753 $content.= '
1754
1755 <!--
1756 Wrapper table for folder tree / file list:
1757 -->
1758 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
1759 <tr>
1760 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1761 <td class="c-wCell" valign="top">'.$files.'</td>
1762 </tr>
1763 </table>
1764 ';
1765
1766 // Adding create folder + upload forms if applicable:
1767 if (!$GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
1768 $content .= $uploadForm;
1769 }
1770 if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
1771 $content .= $createFolder;
1772 }
1773
1774 // Add some space
1775 $content.='<br /><br />';
1776
1777 // Setup indexed elements:
1778 $this->doc->JScode.= $this->doc->wrapScriptTags('BrowseLinks.addElements(' . json_encode($this->elements) . ');');
1779 // Ending page, returning content:
1780 $content.= $this->doc->endPage();
1781 $content = $this->doc->insertStylesAndJS($content);
1782
1783 return $content;
1784 }
1785
1786 /**
1787 * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for folders.
1788 *
1789 * @return string HTML content for the module
1790 */
1791 function main_folder() {
1792
1793 // include JS files
1794 $this->doc->getDragDropCode('folders');
1795
1796 // setting prefs for foldertree
1797 $this->doc->JScode .= $this->doc->wrapScriptTags('
1798 Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
1799 ');
1800
1801 // Starting content:
1802 $content = $this->doc->startPage('TBE folder selector');
1803
1804 // Init variable:
1805 $parameters = explode('|', $this->bparams);
1806
1807 if ($this->expandFolder) {
1808 $this->selectedFolder = t3lib_file_Factory::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder);
1809 }
1810
1811 if ($this->selectedFolder) {
1812 $createFolder = $this->createFolder($this->selectedFolder);
1813 } else {
1814 $createFolder='';
1815 }
1816
1817 // Create folder tree:
1818 $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
1819 $foldertree->thisScript = $this->thisScript;
1820 $foldertree->ext_noTempRecyclerDirs = ($this->mode == 'filedrag');
1821 $tree = $foldertree->getBrowsableTree(FALSE);
1822
1823 list(, , $specUid) = explode('_', $this->PM);
1824
1825 if($this->mode == 'filedrag') {
1826 $folders = $this->TBE_dragNDrop($this->selectedFolder, $parameters[3]);
1827 } else {
1828 $folders = $this->TBE_expandSubFolders($this->selectedFolder);
1829 }
1830
1831 // Putting the parts together, side by side:
1832 $content.= '
1833
1834 <!--
1835 Wrapper table for folder tree / folder list:
1836 -->
1837 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
1838 <tr>
1839 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1840 <td class="c-wCell" valign="top">'.$folders.'</td>
1841 </tr>
1842 </table>
1843 ';
1844
1845 // Adding create folder if applicable:
1846 if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
1847 $content .= $createFolder;
1848 }
1849
1850 // Add some space
1851 $content .= '<br /><br />';
1852
1853 // Ending page, returning content:
1854 $content.= $this->doc->endPage();
1855 $content = $this->doc->insertStylesAndJS($content);
1856
1857 return $content;
1858 }
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876 /******************************************************************
1877 *
1878 * Record listing
1879 *
1880 ******************************************************************/
1881 /**
1882 * For RTE: This displays all content elements on a page and lets you create a link to the element.
1883 *
1884 * @return string HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...)
1885 */
1886 function expandPage() {
1887 $out='';
1888 $expPageId = $this->expandPage; // Set page id (if any) to expand
1889
1890 // If there is an anchor value (content element reference) in the element reference, then force an ID to expand:
1891 if (!$this->expandPage && $this->curUrlInfo['cElement']) {
1892 $expPageId = $this->curUrlInfo['pageid']; // Set to the current link page id.
1893 }
1894
1895 // Draw the record list IF there is a page id to expand:
1896 if ($expPageId && t3lib_utility_Math::canBeInterpretedAsInteger($expPageId) && $GLOBALS['BE_USER']->isInWebMount($expPageId)) {
1897
1898 // Set header:
1899 $out.=$this->barheader($GLOBALS['LANG']->getLL('contentElements').':');
1900
1901 // Create header for listing, showing the page title/icon:
1902 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1903 $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages',$expPageId);
1904 $picon = t3lib_iconWorks::getSpriteIconForRecord('pages', $mainPageRec);
1905 $picon .= t3lib_BEfunc::getRecordTitle('pages', $mainPageRec, TRUE);
1906 $out.=$picon.'<br />';
1907
1908 // Look up tt_content elements from the expanded page:
1909 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1910 'uid,header,hidden,starttime,endtime,fe_group,CType,colPos,bodytext',
1911 'tt_content',
1912 'pid='.intval($expPageId).
1913 t3lib_BEfunc::deleteClause('tt_content').
1914 t3lib_BEfunc::versioningPlaceholderClause('tt_content'),
1915 '',
1916 'colPos,sorting'
1917 );
1918 $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1919
1920 // Traverse list of records:
1921 $c=0;
1922 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1923 $c++;
1924 $icon = t3lib_iconWorks::getSpriteIconForRecord('tt_content', $row);
1925 if ($this->curUrlInfo['act']=='page' && $this->curUrlInfo['cElement']==$row['uid']) {
1926 $arrCol='<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
1927 } else {
1928 $arrCol='';
1929 }
1930 // Putting list element HTML together:
1931 $out.='<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/ol/join'.($c==$cc?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
1932 $arrCol.
1933 '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.$row['uid'].'\');">'.
1934 $icon.
1935 t3lib_BEfunc::getRecordTitle('tt_content', $row, TRUE) .
1936 '</a><br />';
1937
1938 // Finding internal anchor points:
1939 if (t3lib_div::inList('text,textpic', $row['CType'])) {
1940 $split = preg_split('/(<a[^>]+name=[\'"]?([^"\'>[:space:]]+)[\'"]?[^>]*>)/i', $row['bodytext'], -1, PREG_SPLIT_DELIM_CAPTURE);
1941
1942 foreach($split as $skey => $sval) {
1943 if (($skey%3)==2) {
1944 // Putting list element HTML together:
1945 $sval = substr($sval,0,100);
1946 $out.='<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/ol/line.gif','width="18" height="16"').' alt="" />'.
1947 '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/ol/join'.($skey+3>count($split)?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
1948 '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.rawurlencode($sval).'\');">'.
1949 htmlspecialchars(' <A> '.$sval).
1950 '</a><br />';
1951 }
1952 }
1953 }
1954 }
1955 }
1956 return $out;
1957 }
1958
1959 /**
1960 * For TYPO3 Element Browser: This lists all content elements from the given list of tables
1961 *
1962 * @param string Commalist of tables. Set to "*" if you want all tables.
1963 * @return string HTML output.
1964 */
1965 function TBE_expandPage($tables) {
1966 $out='';
1967 if ($this->expandPage >= 0 && t3lib_utility_Math::canBeInterpretedAsInteger($this->expandPage) && $GLOBALS['BE_USER']->isInWebMount($this->expandPage)) {
1968
1969 // Set array with table names to list:
1970 if (!strcmp(trim($tables),'*')) {
1971 $tablesArr = array_keys($GLOBALS['TCA']);
1972 } else {
1973 $tablesArr = t3lib_div::trimExplode(',',$tables,1);
1974 }
1975 reset($tablesArr);
1976
1977 // Headline for selecting records:
1978 $out.=$this->barheader($GLOBALS['LANG']->getLL('selectRecords').':');
1979
1980 // Create the header, showing the current page for which the listing is. Includes link to the page itself, if pages are amount allowed tables.
1981 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1982 $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages',$this->expandPage);
1983 $ATag='';
1984 $ATag_e='';
1985 $ATag2='';
1986 $picon = '';
1987 if (is_array($mainPageRec)) {
1988 $picon = t3lib_iconWorks::getSpriteIconForRecord('pages', $mainPageRec);
1989 if (in_array('pages', $tablesArr)) {
1990 $ATag = "<a href=\"#\" onclick=\"return insertElement('pages', '" . $mainPageRec['uid'] .
1991 "', 'db', " . t3lib_div::quoteJSvalue($mainPageRec['title']) . ", '', '', '','',1);\">";
1992 $ATag2 = "<a href=\"#\" onclick=\"return insertElement('pages', '" . $mainPageRec['uid'] .
1993 "', 'db', " . t3lib_div::quoteJSvalue($mainPageRec['title']) . ", '', '', '','',0);\">";
1994 $ATag_alt = substr($ATag, 0, -4) . ",'',1);\">";
1995 $ATag_e = '</a>';
1996 }
1997 }
1998 $pBicon = ($ATag2 ? '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' alt="" />' : '');
1999 $pText=htmlspecialchars(t3lib_div::fixed_lgd_cs($mainPageRec['title'],$titleLen));
2000 $out.=$picon.$ATag2.$pBicon.$ATag_e.$ATag.$pText.$ATag_e.'<br />';
2001
2002 // Initialize the record listing:
2003 $id = $this->expandPage;
2004 $pointer = t3lib_utility_Math::forceIntegerInRange($this->pointer,0,100000);
2005 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
2006 $pageinfo = t3lib_BEfunc::readPageAccess($id,$perms_clause);
2007 $table='';
2008
2009 // Generate the record list:
2010 /** @var $dblist TBE_browser_recordList */
2011 $dblist = t3lib_div::makeInstance('TBE_browser_recordList');
2012 $dblist->thisScript=$this->thisScript;
2013 $dblist->backPath = $GLOBALS['BACK_PATH'];
2014 $dblist->thumbs = 0;
2015 $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageinfo);
2016 $dblist->noControlPanels=1;
2017 $dblist->clickMenuEnabled=0;
2018 $dblist->tableList=implode(',',$tablesArr);
2019
2020
2021 $pArr = explode('|', $this->bparams);
2022 $fieldPointerString = $pArr[0]; // a string like "data[pages][79][storage_pid]"
2023 $fieldPointerParts = explode('[', $fieldPointerString); // parts like: data, pages], 79], storage_pid]
2024 $relatingTableName = substr($fieldPointerParts[1], 0, -1);
2025 $relatingFieldName = substr($fieldPointerParts[3], 0, -1);
2026
2027 if($relatingTableName && $relatingFieldName) {
2028 $dblist->setRelatingTableAndField($relatingTableName, $relatingFieldName);
2029 }
2030
2031
2032 $dblist->start($id,t3lib_div::_GP('table'),$pointer,
2033 t3lib_div::_GP('search_field'),
2034 t3lib_div::_GP('search_levels'),
2035 t3lib_div::_GP('showLimit')
2036 );
2037 $dblist->setDispFields();
2038 $dblist->generateList();
2039 $dblist->writeBottom();
2040
2041 // Add the HTML for the record list to output variable:
2042 $out.=$dblist->HTMLcode;
2043
2044 // Add support for fieldselectbox in singleTableMode
2045 if ($dblist->table) {
2046 $out.= $dblist->fieldSelectBox($dblist->table);
2047 }
2048
2049 $out.=$dblist->getSearchBox();
2050 }
2051
2052 // Return accumulated content:
2053 return $out;
2054 }
2055
2056
2057 /**
2058 * Render list of folders inside a folder.
2059 *
2060 * @param string string of the current folder
2061 * @return string HTML output
2062 */
2063 function TBE_expandSubFolders(t3lib_file_Folder $folder) {
2064 $content = '';
2065
2066 if ($folder->checkActionPermission('browse')) {
2067 $content .= $this->folderList($folder);
2068 }
2069
2070 // Return accumulated content for folderlisting:
2071 return $content;
2072 }
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084 /******************************************************************
2085 *
2086 * File listing
2087 *
2088 ******************************************************************/
2089 /**
2090 * For RTE: This displays all files from folder. No thumbnails shown
2091 *
2092 * @param string The folder path to expand
2093 * @param string List of fileextensions to show
2094 * @return string HTML output
2095 */
2096 function expandFolder(t3lib_file_Folder $folder, $extensionList='') {
2097 $out = '';
2098 $renderFolders = ($this->act === 'folder');
2099 if ($folder->checkActionPermission('browse')) {
2100
2101 // Create header for filelisting:
2102 $out .= $this->barheader($GLOBALS['LANG']->getLL('files').':');
2103
2104 // Prepare current path value for comparison (showing red arrow)
2105 $currentIdentifier = '';
2106 if ($this->curUrlInfo['value']) {
2107 $currentIdentifier = $this->curUrlInfo['info'];
2108 }
2109
2110
2111 // Create header element; The folder from which files are listed.
2112 $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
2113
2114 $folderIcon = t3lib_iconWorks::getSpriteIconForFile('folder');
2115 $folderIcon .= htmlspecialchars(t3lib_div::fixed_lgd_cs($folder->getIdentifier(), $titleLen));
2116
2117 $picon='<a href="#" onclick="return link_folder(\'file:'.$folder->getCombinedIdentifier().'\');">' . $folderIcon . '</a>';
2118 if ($this->curUrlInfo['act'] == 'folder' && $currentIdentifier == $folder->getCombinedIdentifier()) {
2119 $out.= '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif', 'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />';
2120 }
2121 $out.=$picon.'<br />';
2122
2123 // Get files from the folder:
2124 if ($renderFolders) {
2125 $items = $folder->getSubfolders();
2126 } else {
2127 $items = $folder->getFiles($extensionList);
2128 }
2129
2130 $c = 0;
2131 $totalItems = count($items);
2132 foreach ($items as $fileOrFolderObject) {
2133 $c++;
2134
2135 if ($renderFolders) {
2136 $fileIdentifier = $fileOrFolderObject->getCombinedIdentifier();
2137 $icon = t3lib_iconWorks::getSpriteIconForFile('folder');
2138 $itemUid = 'file:' . $fileIdentifier;
2139 } else {
2140 $fileIdentifier = $fileOrFolderObject->getUid();
2141 // File icon:
2142 $fileExtension = $fileOrFolderObject->getExtension();
2143 // Get size and icon:
2144 $size = ' (' . t3lib_div::formatSize($fileOrFolderObject->getSize()) . 'bytes)';
2145 $icon = t3lib_iconWorks::getSpriteIconForFile($fileExtension, array('title' => $fileOrFolderObject->getName() . $size));
2146 $itemUid = 'file:' . $fileIdentifier;
2147 }
2148
2149 // If the listed file turns out to be the CURRENT file, then show blinking arrow:
2150 if (($this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder') && $currentIdentifier == $fileIdentifier) {
2151 $arrCol='<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
2152 } else {
2153 $arrCol='';
2154 }
2155
2156 // Put it all together for the file element:
2157 $out.='<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/ol/join'.($c == $totalItems ?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
2158 $arrCol.
2159 '<a href="#" onclick="return link_folder(\'' . $itemUid . '\');">'.
2160 $icon.
2161 htmlspecialchars(t3lib_div::fixed_lgd_cs($fileOrFolderObject->getName(), $titleLen)).
2162 '</a><br />';
2163 }
2164 }
2165 return $out;
2166 }
2167
2168 /**
2169 * For TYPO3 Element Browser: Expand folder of files.
2170 *
2171 * @param t3lib_file_Folder $folder The folder path to expand
2172 * @param string $extensionList List of fileextensions to show
2173 * @param boolean $noThumbs Whether to show thumbnails or not. If set, no thumbnails are shown.
2174 * @return string HTML output
2175 */
2176 function TBE_expandFolder(t3lib_file_Folder $folder, $extensionList = '', $noThumbs = 0) {
2177 $extensionList = ($extensionList == '*') ? '' : $extensionList;
2178 $content = '';
2179 if ($folder->checkActionPermission('browse')) {
2180 // Listing the files:
2181 $files = $folder->getFiles($extensionList);
2182 $content = $this->fileList($files, $folder, $noThumbs);
2183 }
2184 // Return accumulated content for filelisting:
2185 return $content;
2186 }
2187
2188 /**
2189 * Render list of files.
2190 *
2191 * @param array $filed List of files. See t3lib_div::getFilesInDir
2192 * @param string t3lib_file_Folder If set a header with a folder icon and folder name are shown
2193 * @param boolean $noThumbs Whether to show thumbnails or not. If set, no thumbnails are shown.
2194 * @return string HTML output
2195 */
2196 function fileList(array $files, t3lib_file_Folder $folder = NULL, $noThumbs=0) {
2197 $out = '';
2198 // Listing the files:
2199 if (is_array($files)) {
2200 $lines = array();
2201
2202 // Create headline (showing number of files):
2203 $filesCount = count($files);
2204 $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):', $filesCount));
2205 $out .= '<div id="filelist">';
2206 $out .= $this->getBulkSelector($filesCount);
2207
2208 $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
2209
2210 // Create the header of current folder:
2211 if ($folder) {
2212 $folderIcon = t3lib_iconWorks::getSpriteIconForFile('folder');
2213 $lines[] = '<tr class="t3-row-header">
2214 <td colspan="4">' . $folderIcon . htmlspecialchars(t3lib_div::fixed_lgd_cs($folder->getIdentifier(), $titleLen)) . '</td>
2215 </tr>';
2216 }
2217
2218 if ($filesCount == 0) {
2219 $lines[]='
2220 <tr class="file_list_normal">
2221 <td colspan="4">No files found.</td>
2222 </tr>';
2223 }
2224
2225 // Init graphic object for reading file dimensions:
2226 /** @var $imgObj t3lib_stdGraphic */
2227 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
2228 $imgObj->init();
2229 $imgObj->mayScaleUp = 0;
2230 $imgObj->tempPath = PATH_site . $imgObj->tempPath;
2231
2232 // Traverse the file list:
2233 foreach ($files as $fileObject) {
2234 $fileExtension = $fileObject->getExtension();
2235 // Thumbnail/size generation:
2236 if (t3lib_div::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']), strtolower($fileExtension)) && !$noThumbs) {
2237 $imageUrl = $fileObject->process(
2238 t3lib_file_ProcessedFile::CONTEXT_IMAGEPREVIEW,
2239 array('width' => 64, 'height' => 64)
2240 )->getPublicUrl(TRUE);
2241
2242 $imgInfo = $imgObj->getImageDimensions($fileObject->getForLocalProcessing(FALSE));
2243 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
2244 $clickIcon = '<img src="' . $imageUrl . '" hspace="5" vspace="5" border="1"';
2245 } else {
2246 $clickIcon = '';
2247 $pDim = '';
2248 }
2249
2250 // Create file icon:
2251 $size = ' ('.t3lib_div::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')';
2252 $icon = t3lib_iconWorks::getSpriteIconForFile($fileExtension, array('title' => $fileObject->getName() . $size));
2253
2254 // Create links for adding the file:
2255 $filesIndex = count($this->elements);
2256 $this->elements['file_' . $filesIndex] = array(
2257 'type' => 'file',
2258 'table' => 'sys_file',
2259 'uid' => $fileObject->getUid(),
2260 'fileName' => $fileObject->getName(),
2261 'filePath' => $fileObject->getUid(),
2262 'fileExt' => $fileExtension,
2263 'fileIcon' => $icon,
2264 );
2265 $ATag = "<a href=\"#\" onclick=\"return BrowseLinks.File.insertElement('file_$filesIndex');\">";
2266 $ATag_alt = substr($ATag,0,-4).",1);\">";
2267 $bulkCheckBox = '<input type="checkbox" class="typo3-bulk-item" name="file_'.$filesIndex.'" value="0" /> ';
2268
2269 $ATag_e='</a>';
2270
2271 // Create link to showing details about the file in a window:
2272 $Ahref = $GLOBALS['BACK_PATH'].'show_item.php?type=file&table=_FILE&uid='.rawurlencode($fileObject->getCombinedIdentifier()).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
2273 $ATag2='<a href="'.htmlspecialchars($Ahref).'">';
2274 $ATag2_e='</a>';
2275
2276 // Combine the stuff:
2277 $filenameAndIcon = $bulkCheckBox . $ATag_alt . $icon . htmlspecialchars(t3lib_div::fixed_lgd_cs($fileObject->getName(), $titleLen)) . $ATag_e;
2278
2279 // Show element:
2280 if ($pDim) { // Image...
2281 $lines[]='
2282 <tr class="file_list_normal">
2283 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
2284 <td>' . $ATag . '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList',1) . '" alt="" />' . $ATag_e . '</td>
2285 <td nowrap="nowrap">' . ($ATag2 . '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/zoom2.gif', 'width="12" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('info', 1) . '" alt="" /> ' . $GLOBALS['LANG']->getLL('info', 1) . $ATag2_e) . '</td>
2286 <td nowrap="nowrap">&nbsp;'.$pDim.'</td>
2287 </tr>';
2288 $lines[]='
2289 <tr>
2290 <td class="filelistThumbnail" colspan="4">' . $ATag_alt . $clickIcon . $ATag_e . '</td>
2291 </tr>';
2292 } else {
2293 $lines[]='
2294 <tr class="file_list_normal">
2295 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
2296 <td>' . $ATag . '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif','width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList',1) . '" alt="" />' . $ATag_e . '</td>
2297 <td nowrap="nowrap">' . ($ATag2 . '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/zoom2.gif','width="12" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('info', 1) . '" alt="" /> ' . $GLOBALS['LANG']->getLL('info', 1) . $ATag2_e) . '</td>
2298 <td>&nbsp;</td>
2299 </tr>';
2300 }
2301 }
2302
2303 // Wrap all the rows in table tags:
2304 $out.='
2305
2306
2307
2308 <!--
2309 File listing
2310 -->
2311 <table cellpadding="0" cellspacing="0" id="typo3-filelist">
2312 '.implode('',$lines).'
2313 </table>';
2314 }
2315 // Return accumulated content for filelisting:
2316 $out .= '</div>';
2317 return $out;
2318 }
2319
2320 /**
2321 * Render list of folders.
2322 *
2323 * @param array List of folders. See t3lib_div::get_dirs
2324 * @param string If set a header with a folder icon and folder name are shown
2325 * @return string HTML output
2326 */
2327 function folderList($baseFolder, $folders) {
2328 $content = '';
2329
2330 // Create headline (showing number of folders):
2331 $content.=$this->barheader(
2332 sprintf($GLOBALS['LANG']->getLL('folders').' (%s):',count($folders))
2333 );
2334
2335 $titleLength = intval($GLOBALS['BE_USER']->uc['titleLen']);
2336
2337 // Create the header of current folder:
2338 if($baseFolder) {
2339 if (strstr($baseFolder, ',') || strstr($baseFolder, '|')) {
2340 // In case an invalid character is in the filepath, display error message:
2341 $errorMessage = $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('invalidChar'), ', |'));
2342 $aTag = $aTag_alt = "<a href=\"#\" onclick=\"alert(".$errorMessage.");return false;\">";
2343 } else {
2344 // If foldername is OK, just add it:
2345 $aTag = "<a href=\"#\" onclick=\"return insertElement('','".rawurlencode($baseFolder)."', 'folder', '".rawurlencode($baseFolder)."', unescape('".rawurlencode($baseFolder)."'), '".$fI['extension']."', '".$ficon."');\">";
2346 $aTag_alt = substr($aTag,0,-4).",'',1);\">";
2347 }
2348 $aTag_e = '</a>';
2349
2350 // add the foder icon
2351 $folderIcon = $aTag_alt;
2352 $folderIcon.= '<img'.t3lib_iconWorks::skinImg(
2353 $GLOBALS['BACK_PATH'],
2354 'gfx/i/_icon_webfolders.gif','width="18" height="16"'
2355 ).' alt="" />';
2356 $folderIcon.= htmlspecialchars(
2357 t3lib_div::fixed_lgd_cs(basename($baseFolder),$titleLength)
2358 );
2359 $folderIcon.= $aTag_e;
2360
2361 $content.=$folderIcon.'<br />';
2362 }
2363
2364 // Listing the folders:
2365 if(is_array($folders)) {
2366 if(count($folders) > 0) {
2367 // Traverse the folder list:
2368 $lines = array();
2369 foreach($folders as $folderPath) {
2370 $pathInfo = pathinfo($folderPath);
2371
2372 // Create folder icon:
2373 $icon = '<img src="clear.gif" width="16" height="16" alt="" /><img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif','width="16" height="16"').' title="'.htmlspecialchars($pathInfo['basename'].$size).'" class="absmiddle" alt="" />';
2374
2375 // Create links for adding the folder:
2376 if($this->P['itemName'] != '' && $this->P['formName'] != '') {
2377 $aTag = "<a href=\"#\" onclick=\"return set_folderpath(unescape('".rawurlencode($folderPath)."'));\">";
2378 } else {
2379 $aTag = "<a href=\"#\" onclick=\"return insertElement('','".rawurlencode($folderPath)."', 'folder', '".rawurlencode($folderPath)."', unescape('".rawurlencode($folderPath)."'), '".$pathInfo['extension']."', '".$ficon."');\">";
2380 }
2381
2382 if (strstr($folderPath,',') || strstr($folderPath,'|')) {
2383 // In case an invalid character is in the filepath, display error message:
2384 $errorMessage = $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('invalidChar'), ', |'));
2385 $aTag = $aTag_alt = "<a href=\"#\" onclick=\"alert(".$errorMessage.");return false;\">";
2386 } else {
2387 // If foldername is OK, just add it:
2388 $aTag_alt = substr($aTag,0,-4).",'',1);\">";
2389 }
2390 $aTag_e='</a>';
2391
2392 // Combine icon and folderpath:
2393 $foldernameAndIcon = $aTag_alt.$icon.htmlspecialchars(
2394 t3lib_div::fixed_lgd_cs(basename($folderPath),$titleLength)
2395 ).$aTag_e;
2396
2397 if($this->P['itemName'] != '') {
2398 $lines[] = '
2399 <tr class="bgColor4">
2400 <td nowrap="nowrap">'.$foldernameAndIcon.'&nbsp;</td>
2401 <td>&nbsp;</td>
2402 </tr>';
2403 } else {
2404 $lines[] = '
2405 <tr class="bgColor4">
2406 <td nowrap="nowrap">'.$foldernameAndIcon.'&nbsp;</td>
2407 <td>' . $aTag . '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList', 1) . '" alt="" />' . $aTag_e .' </td>
2408 <td>&nbsp;</td>
2409 </tr>';
2410 }
2411
2412 $lines[] = '
2413 <tr>
2414 <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
2415 </tr>';
2416 }
2417 }
2418
2419 // Wrap all the rows in table tags:
2420 $content.='
2421
2422 <!--
2423 Folder listing
2424 -->
2425 <table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList">
2426 '.implode('', $lines).'
2427 </table>';
2428 }
2429
2430 // Return accumulated content for folderlisting:
2431 return $content;
2432 }
2433
2434 /**
2435 * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
2436 * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
2437 *
2438 * @param t3lib_file_Folder $folder The folder path to expand
2439 * @param string $extensionList List of fileextensions to show
2440 * @return string HTML output
2441 */
2442 function TBE_dragNDrop(t3lib_file_Folder $folder, $extensionList='') {
2443 $extensionList = ($extensionList == '*') ? '' : $extensionList;
2444 $out='';
2445 if ($folder) {
2446 if ($folder->getStorage()->isPublic()) {
2447
2448 // Read files from directory:
2449 $files = $folder->getFiles($extensionList);
2450 if (is_array($files)) {
2451 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):', count($files)));
2452
2453 $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
2454 $picon = '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />';
2455 $picon .= htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($folder->getName()), $titleLen));
2456 $out .= $picon . '<br />';
2457
2458 // Init row-array:
2459 $lines = array();
2460
2461 // Add "drag-n-drop" message:
2462 $lines[]='
2463 <tr>
2464 <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
2465 </tr>';
2466
2467 // Traverse files:
2468 foreach ($files as $fileObject) {
2469 $fileInfo = $fileObject->getStorage()->getFileInfo($fileObject);
2470
2471 // URL of image:
2472 $iUrl = t3lib_div::rawurlencodeFP($fileObject->getPublicUrl(TRUE));
2473
2474 // Show only web-images
2475 $fileExtension = strtolower($fileObject->getExtension());
2476 if (t3lib_div::inList('gif,jpeg,jpg,png', $fileExtension)) {
2477 $imgInfo = @getimagesize($fileObject->getForLocalProcessing(FALSE));
2478 $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels';
2479
2480 $size = ' ('.t3lib_div::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')';
2481 $filenameAndIcon = t3lib_iconWorks::getSpriteIconForFile($fileExtension, array('title' => $fileObject->getName() . $size));
2482
2483 if (t3lib_div::_GP('noLimit')) {
2484 $maxW=10000;
2485 $maxH=10000;
2486 } else {
2487 $maxW=380;
2488 $maxH=500;
2489 }
2490 $IW = $imgInfo[0];
2491 $IH = $imgInfo[1];
2492 if ($IW>$maxW) {
2493 $IH=ceil($IH/$IW*$maxW);
2494 $IW=$maxW;
2495 }
2496 if ($IH>$maxH) {
2497 $IW=ceil($IW/$IH*$maxH);
2498 $IH=$maxH;
2499 }
2500
2501 // Make row:
2502 $lines[]='
2503 <tr class="bgColor4">
2504 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
2505 <td nowrap="nowrap">'.
2506 ($imgInfo[0]!=$IW ? '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('noLimit'=>'1'))).'">'.
2507 '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/icon_warning2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize',1).'" alt="" />'.
2508 '</a>':'').
2509 $pDim.'&nbsp;</td>
2510 </tr>';
2511
2512 $lines[]='
2513 <tr>
2514 <td colspan="2"><img src="' . $iUrl . '" data-htmlarea-file-uid="' . $fileObject->getUid() . '" width="'.$IW.'" height="'.$IH.'" border="1" alt="" /></td>
2515 </tr>';
2516 $lines[]='
2517 <tr>
2518 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
2519 </tr>';
2520 }
2521 }
2522
2523 // Finally, wrap all rows in a table tag:
2524 $out.='
2525
2526
2527 <!--
2528 File listing / Drag-n-drop
2529 -->
2530 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
2531 '.implode('',$lines).'
2532 </table>';
2533 }
2534 } else {
2535 // Print this warning if the folder is NOT a web folder:
2536 $out.=$this->barheader($GLOBALS['LANG']->getLL('files'));
2537 $out.=$this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'),'icon_warning2');
2538 }
2539 }
2540 return $out;
2541 }
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554 /******************************************************************
2555 *
2556 * Miscellaneous functions
2557 *
2558 ******************************************************************/
2559
2560
2561 /**
2562 * Verifies that a path is a web-folder:
2563 *
2564 * @param string Absolute filepath
2565 * @return boolean If the input path is found in PATH_site then it returns TRUE.
2566 */
2567 function isWebFolder($folder) {
2568 $folder = rtrim($folder, '/').'/';
2569 return t3lib_div::isFirstPartOfStr($folder,PATH_site) ? TRUE : FALSE;
2570 }
2571
2572 /**
2573 * Checks, if a path is within the mountpoints of the backend user
2574 *
2575 * @param string Absolute filepath
2576 * @return boolean If the input path is found in the backend users filemounts, then return TRUE.
2577 */
2578 function checkFolder($folder) {
2579 return $this->fileProcessor->checkPathAgainstMounts(rtrim($folder, '/') . '/') ? TRUE : FALSE;
2580 }
2581
2582 /**
2583 * Checks, if a path is within a read-only mountpoint of the backend user
2584 *
2585 * @param string Absolute filepath
2586 * @return boolean If the input path is found in the backend users filemounts and if the filemount is of type readonly, then return TRUE.
2587 */
2588 function isReadOnlyFolder($folder) {
2589 return ($GLOBALS['FILEMOUNTS'][$this->fileProcessor->checkPathAgainstMounts(rtrim($folder, '/') . '/')]['type'] == 'readonly');
2590 }
2591
2592 /**
2593 * Prints a 'header' where string is in a tablecell
2594 *
2595 * @param string The string to print in the header. The value is htmlspecialchars()'ed before output.
2596 * @return string The header HTML (wrapped in a table)
2597 */
2598 function barheader($str) {
2599 return '
2600 <!-- Bar header: -->
2601 <h3>' . htmlspecialchars($str) . '</h3>
2602 ';
2603 }
2604
2605 /**
2606 * Displays a message box with the input message
2607 *
2608 * @param string Input message to show (will be htmlspecialchars()'ed inside of this function)
2609 * @param string Icon filename body from gfx/ (default is "icon_note") - meant to allow change to warning type icons...
2610 * @return string HTML for the message (wrapped in a table).
2611 */
2612 function getMsgBox($in_msg,$icon='icon_note') {
2613 $msg = '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/'.$icon.'.gif','width="18" height="16"').' alt="" />'.htmlspecialchars($in_msg);
2614 $msg = '
2615
2616 <!--
2617 Message box:
2618 -->
2619 <table cellspacing="0" class="bgColor4" id="typo3-msgBox">
2620 <tr>
2621 <td>'.$msg.'</td>
2622 </tr>
2623 </table>
2624 ';
2625 return $msg;
2626 }
2627
2628 /**
2629 * For RTE/link: This prints the 'currentUrl'
2630 *
2631 * @param string $str URL value. The value is htmlspecialchars()'ed before output.
2632 * @return string HTML content, wrapped in a table.
2633 */
2634 function printCurrentUrl($str) {
2635 // output the folder or file identifier, when working with files
2636 if ($str && $this->act == 'file' || $this->act == 'folder') {
2637 try {
2638 $fileObject = t3lib_file_Factory::getInstance()->retrieveFileOrFolderObject($str);
2639 if (is_object($fileObject)) {
2640 $str = $fileObject->getIdentifier();
2641 }
2642 } catch (t3lib_file_exception_FileDoesNotExistException $e) {
2643 $str = '';
2644 }
2645 }
2646
2647 if (strlen($str)) {
2648 return '
2649 <!-- Print current URL -->
2650 <table border="0" cellpadding="0" cellspacing="0" id="typo3-curUrl">
2651 <tr>
2652 <td>' . $GLOBALS['LANG']->getLL('currentLink',1) . ': ' .htmlspecialchars(rawurldecode($str)) . '</td>
2653 </tr>
2654 </table>';
2655 } else {
2656 return '';
2657 }
2658 }
2659
2660 /**
2661 * For RTE/link: Parses the incoming URL and determines if it's a page, file, external or mail address.
2662 *
2663 * @param string HREF value tp analyse
2664 * @param string The URL of the current website (frontend)
2665 * @return array Array with URL information stored in assoc. keys: value, act (page, file, spec, mail), pageid, cElement, info
2666 */
2667 function parseCurUrl($href, $siteUrl) {
2668 $href = trim($href);
2669 if ($href) {
2670 $info = array();
2671
2672 // Default is "url":
2673 $info['value']=$href;
2674 $info['act']='url';
2675
2676 $specialParts = explode('#_SPECIAL',$href);
2677 if (count($specialParts)==2) { // Special kind (Something RTE specific: User configurable links through: "userLinks." from ->thisConfig)
2678 $info['value']='#_SPECIAL'.$specialParts[1];
2679 $info['act']='spec';
2680 // is a FAL resource/identifier
2681 } elseif (strpos($href, 'file:') !== FALSE) {
2682 $rel = substr($href, strpos($href, 'file:')+5);
2683 $rel = rawurldecode($rel);
2684
2685 // resolve FAL-api "file:UID-of-sys_file-record" and "file:combined-identifier"
2686 $fileOrFolderObject = t3lib_file_Factory::getInstance()->retrieveFileOrFolderObject($rel);
2687
2688 if ($fileOrFolderObject instanceof t3lib_file_Folder) {
2689 $info['act'] = 'folder';
2690 $info['value'] = $fileOrFolderObject->getCombinedIdentifier();
2691 } elseif ($fileOrFolderObject instanceof t3lib_file_FileInterface) {
2692 $info['act'] = 'file';
2693 $info['value'] = $fileOrFolderObject->getUid();
2694 } else {
2695 $info['value'] = $rel;
2696 }
2697
2698 } elseif (t3lib_div::isFirstPartOfStr($href,$siteUrl)) { // If URL is on the current frontend website:
2699 if (file_exists(PATH_site.rawurldecode($href))) { // URL is a file, which exists:
2700 $info['value']=rawurldecode($href);
2701 if (@is_dir(PATH_site . $info['value'])) {
2702 $info['act'] = 'folder';
2703 } else {
2704 $info['act'] = 'file';
2705 }
2706 } else { // URL is a page (id parameter)
2707 $uP=parse_url($rel);
2708 if (!trim($uP['path'])) {
2709 $pp = preg_split('/^id=/', $uP['query']);
2710 $pp[1] = preg_replace( '/&id=[^&]*/', '', $pp[1]);
2711 $parameters = explode('&', $pp[1]);
2712 $id = array_shift($parameters);
2713 if ($id) {
2714 // Checking if the id-parameter is an alias.
2715 if (!t3lib_utility_Math::canBeInterpretedAsInteger($id)) {
2716 list($idPartR) = t3lib_BEfunc::getRecordsByField('pages','alias',$id);
2717 $id=intval($idPartR['uid']);
2718 }
2719
2720 $pageRow = t3lib_BEfunc::getRecordWSOL('pages',$id);
2721 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
2722 $info['value']=$GLOBALS['LANG']->getLL('page',1)." '".htmlspecialchars(t3lib_div::fixed_lgd_cs($pageRow['title'],$titleLen))."' (ID:".$id.($uP['fragment']?', #'.$uP['fragment']:'').')';
2723 $info['pageid']=$id;
2724 $info['cElement']=$uP['fragment'];
2725 $info['act']='page';
2726 $info['query'] = $parameters[0]?'&'.implode('&', $parameters):'';
2727 }
2728 }
2729 }
2730 } else { // Email link:
2731 if (strtolower(substr($href,0,7))=='mailto:') {
2732 $info['value']=trim(substr($href,7));
2733 $info['act']='mail';
2734 }
2735 }
2736 $info['info'] = $info['value'];
2737 } else { // NO value inputted:
2738 $info=array();
2739 $info['info']=$GLOBALS['LANG']->getLL('none');
2740 $info['value']='';
2741 $info['act']='page';
2742 }
2743
2744 // let the hook have a look
2745 foreach($this->hookObjects as $hookObject) {
2746 $info = $hookObject->parseCurrentUrl($href, $siteUrl, $info);
2747 }
2748
2749 return $info;
2750 }
2751
2752 /**
2753 * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
2754 * The files are uploaded to the tce_file.php script in the core which will handle the upload.
2755 *
2756 * @param t3lib_file_Folder $folderObject Absolute filepath on server to which to upload.
2757 * @return string HTML for an upload form.
2758 */
2759 function uploadForm(t3lib_file_Folder $folderObject) {
2760 if (!$folderObject->checkActionPermission('write')) {
2761 return '';
2762 }
2763
2764 // Read configuration of upload field count
2765 $userSetting = $GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.uploadFieldsInLinkBrowser');
2766 $count = isset($userSetting) ? $userSetting : 3;
2767 if ($count === '0') {
2768 return '';
2769 }
2770 $count = intval($count) == 0 ? 3 : intval($count);
2771
2772 // Create header, showing upload path:
2773 $header = $folderObject->getIdentifier();
2774 $code = '
2775 <br />
2776 <!--
2777 Form, for uploading files:
2778 -->
2779 <form action="' . $GLOBALS['BACK_PATH'] . 'tce_file.php" method="post" name="editform" id="typo3-uplFilesForm" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '">
2780 <table border="0" cellpadding="0" cellspacing="0" id="typo3-uplFiles">
2781 <tr>
2782 <td>' . $this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.pagetitle', 1) . ':') . '</td>
2783 </tr>
2784 <tr>
2785 <td class="c-wCell c-hCell"><strong>' . $GLOBALS['LANG']->getLL('path', 1) . ':</strong> ' . htmlspecialchars($header) . '</td>
2786 </tr>
2787 <tr>
2788 <td class="c-wCell c-hCell">';
2789
2790 // Traverse the number of upload fields (default is 3):
2791 for ($a=1;$a<=$count;$a++) {
2792 $code.='<input type="file" multiple="multiple" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" />
2793 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($folderObject->getCombinedIdentifier()).'" />
2794 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
2795 }
2796
2797 // Make footer of upload form, including the submit button:
2798 $redirectValue = $this->thisScript.'?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($folderObject->getCombinedIdentifier()).'&bparams='.rawurlencode($this->bparams);
2799 $code .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($redirectValue) . '" />';
2800
2801 $code.='
2802 <div id="c-override">
2803 <label><input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles', 1) . '</label>
2804 </div>
2805 <input type="submit" name="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit', 1) . '" />
2806 ';
2807
2808
2809 $code.='</td>
2810 </tr>
2811 </table>
2812 </form><br />';
2813
2814 return $code;
2815 }
2816
2817 /**
2818 * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
2819 * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
2820 *
2821 * @param t3lib_file_Folder $folderObject Absolute filepath on server in which to create the new folder.
2822 * @return string HTML for the create folder form.
2823 */
2824 function createFolder(t3lib_file_Folder $folderObject) {
2825 if (!$folderObject->checkActionPermission('write')) {
2826 return '';
2827 }
2828
2829 // Don't show Folder-create form if it's denied
2830 if ($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.hideCreateFolder')) {
2831 return '';
2832 }
2833 // Create header, showing upload path:
2834 $header = $folderObject->getIdentifier();
2835 $code = '
2836
2837 <!--
2838 Form, for creating new folders:
2839 -->
2840 <form action="' . $GLOBALS['BACK_PATH'] . 'tce_file.php" method="post" name="editform2" id="typo3-crFolderForm">
2841 <table border="0" cellpadding="0" cellspacing="0" id="typo3-crFolder">
2842 <tr>
2843 <td>' . $this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle') . ':') . '</td>
2844 </tr>
2845 <tr>
2846 <td class="c-wCell c-hCell"><strong>' . $GLOBALS['LANG']->getLL('path', 1) . ':</strong> ' . htmlspecialchars($header) . '</td>
2847 </tr>
2848 <tr>
2849 <td class="c-wCell c-hCell">';
2850
2851 // Create the new-folder name field:
2852 $a=1;
2853 $code.='<input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
2854 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($folderObject->getCombinedIdentifier()).'" />';
2855
2856 // Make footer of upload form, including the submit button:
2857 $redirectValue = $this->thisScript.'?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($folderObject->getCombinedIdentifier()).'&bparams='.rawurlencode($this->bparams);
2858 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
2859 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
2860
2861 $code.='</td>
2862 </tr>
2863 </table>
2864 </form>';
2865
2866 return $code;
2867 }
2868
2869 /**
2870 * Get the HTML data required for a bulk selection of files of the TYPO3 Element Browser.
2871 *
2872 * @param integer $filesCount: Number of files currently displayed
2873 * @return string HTML data required for a bulk selection of files - if $filesCount is 0, nothing is returned
2874 */
2875 function getBulkSelector($filesCount) {
2876 if ($filesCount) {
2877 $labelToggleSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.php:toggleSelection',1);
2878 $labelImportSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.php:importSelection',1);
2879
2880 // Getting flag for showing/not showing thumbnails:
2881 $noThumbsInEB = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
2882
2883 $out = $this->doc->spacer(10).'<div>' .
2884 '<a href="#" onclick="BrowseLinks.Selector.handle()">' .
2885 '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/import.gif','width="12" height="12"').' title="'.$labelImportSelection.'" alt="" /> ' .
2886 $labelImportSelection.'</a>&nbsp;&nbsp;&nbsp;' .
2887 '<a href="#" onclick="BrowseLinks.Selector.toggle()">' .
2888 '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/clip_select.gif','width="12" height="12"').' title="'.$labelToggleSelection.'" alt="" /> ' .
2889 $labelToggleSelection.'</a>' .
2890 '</div>';
2891
2892 $thumbNailCheck = '';
2893 if (!$noThumbsInEB && $this->selectedFolder) {
2894
2895 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
2896 $_MOD_MENU = array('displayThumbs' => '');
2897 $_MCONF['name'] = 'file_list';
2898 $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']);
2899 $addParams = '&act=' . $this->act . '&mode=' . $this->mode . '&expandFolder=' . rawurlencode($this->selectedFolder->getCombinedIdentifier()) . '&bparams=' . rawurlencode($this->bparams);
2900 $thumbNailCheck = t3lib_BEfunc::getFuncCheck('', 'SET[displayThumbs]', $_MOD_SETTINGS['displayThumbs'], $this->thisScript, $addParams, 'id="checkDisplayThumbs"') . ' <label for="checkDisplayThumbs">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.php:displayThumbs', 1) . '</label>';
2901 $out .= $this->doc->spacer(5) . $thumbNailCheck . $this->doc->spacer(15);
2902 } else {
2903 $out .= $this->doc->spacer(15);
2904 }
2905 }
2906 return $out;
2907 }
2908
2909 /**
2910 * Determines whether submitted field change functions are valid
2911 * and are coming from the system and not from an external abuse.
2912 *
2913 * @param boolean $allowFlexformSections Whether to handle flexform sections differently
2914 * @return boolean Whether the submitted field change functions are valid
2915 */
2916 protected function areFieldChangeFunctionsValid($handleFlexformSections = FALSE) {
2917 $result = FALSE;
2918
2919 if (isset($this->P['fieldChangeFunc']) && is_array($this->P['fieldChangeFunc']) && isset($this->P['fieldChangeFuncHash'])) {
2920 $matches = array();
2921 $pattern = '#\[el\]\[(([^]-]+-[^]-]+-)(idx\d+-)([^]]+))\]#i';
2922
2923 $fieldChangeFunctions = $this->P['fieldChangeFunc'];
2924
2925 // Special handling of flexform sections:
2926 // Field change functions are modified in JavaScript, thus the hash is always invalid
2927 if ($handleFlexformSections && preg_match($pattern, $this->P['itemName'], $matches)) {
2928 $originalName = $matches[1];
2929 $cleanedName = $matches[2] . $matches[4];
2930
2931 foreach ($fieldChangeFunctions as &$value) {
2932 $value = str_replace($originalName, $cleanedName, $value);
2933 }
2934 unset($value);
2935 }
2936
2937 $result = ($this->P['fieldChangeFuncHash'] === t3lib_div::hmac(serialize($fieldChangeFunctions)));
2938 }
2939
2940 return $result;
2941 }
2942 }
2943 ?>