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