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