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