Fixed bug #16050: htmlArea RTE: Backspacing in empty editing area may raise js error
[Packages/TYPO3.CMS.git] / typo3 / class.browse_links.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2010 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!=255'.$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 $currentLinkParts = t3lib_div::unQuoteFilenames($this->P['currentValue'], TRUE);
818 $initialCurUrlArray = array (
819 'href' => $currentLinkParts[0],
820 'target' => $currentLinkParts[1],
821 'class' => $currentLinkParts[2],
822 'title' => $currentLinkParts[3],
823 'params' => $currentLinkParts[4]
824 );
825 $this->curUrlArray = (is_array(t3lib_div::_GP('curUrl'))) ?
826 array_merge($initialCurUrlArray, t3lib_div::_GP('curUrl')) :
827 $initialCurUrlArray;
828 $this->curUrlInfo = $this->parseCurUrl($this->siteURL.'?id='.$this->curUrlArray['href'], $this->siteURL);
829 if ($this->curUrlInfo['pageid'] == 0 && $this->curUrlArray['href']) { // pageid == 0 means that this is not an internal (page) link
830 if (file_exists(PATH_site.rawurldecode($this->curUrlArray['href']))) { // check if this is a link to a file
831 if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], PATH_site)) {
832 $currentLinkParts[0] = substr($this->curUrlArray['href'], strlen(PATH_site));
833 }
834 $this->curUrlInfo = $this->parseCurUrl($this->siteURL.$this->curUrlArray['href'], $this->siteURL);
835 } elseif (strstr($this->curUrlArray['href'], '@')) { // check for email link
836 if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], 'mailto:')) {
837 $currentLinkParts[0] = substr($this->curUrlArray['href'], 7);
838 }
839 $this->curUrlInfo = $this->parseCurUrl('mailto:'.$this->curUrlArray['href'], $this->siteURL);
840 } else { // nothing of the above. this is an external link
841 if(strpos($this->curUrlArray['href'], '://') === false) {
842 $currentLinkParts[0] = 'http://' . $this->curUrlArray['href'];
843 }
844 $this->curUrlInfo = $this->parseCurUrl($currentLinkParts[0], $this->siteURL);
845 }
846 } elseif (!$this->curUrlArray['href']) {
847 $this->curUrlInfo = array();
848 $this->act = 'page';
849 } else {
850 $this->curUrlInfo = $this->parseCurUrl($this->siteURL.'?id='.$this->curUrlArray['href'], $this->siteURL);
851 }
852 } else {
853 $this->curUrlArray = t3lib_div::_GP('curUrl');
854 if ($this->curUrlArray['all']) {
855 $this->curUrlArray=t3lib_div::get_tag_attributes($this->curUrlArray['all']);
856 }
857 $this->curUrlInfo=$this->parseCurUrl($this->curUrlArray['href'],$this->siteURL);
858 }
859
860 // Determine nature of current url:
861 $this->act=t3lib_div::_GP('act');
862 if (!$this->act) {
863 $this->act=$this->curUrlInfo['act'];
864 }
865
866 // Rich Text Editor specific configuration:
867 $addPassOnParams='';
868 if ((string)$this->mode == 'rte') {
869 $RTEtsConfigParts = explode(':',$this->RTEtsConfigParams);
870 $addPassOnParams.='&RTEtsConfigParams='.rawurlencode($this->RTEtsConfigParams);
871 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
872 $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
873 }
874
875 // Initializing the target value (RTE)
876 $this->setTarget = ($this->curUrlArray['target'] != '-') ? $this->curUrlArray['target'] : '';
877 if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target'])) {
878 $this->setTarget=$this->thisConfig['defaultLinkTarget'];
879 }
880
881 // Initializing the class value (RTE)
882 $this->setClass = ($this->curUrlArray['class'] != '-') ? $this->curUrlArray['class'] : '';
883
884 // Initializing the title value (RTE)
885 $this->setTitle = ($this->curUrlArray['title'] != '-') ? $this->curUrlArray['title'] : '';
886
887 // Initializing the params value
888 $this->setParams = ($this->curUrlArray['params'] != '-') ? $this->curUrlArray['params'] : '';
889
890 // BEGIN accumulation of header JavaScript:
891 $JScode = '
892 // This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
893 var add_href="'.($this->curUrlArray['href']?'&curUrl[href]='.rawurlencode($this->curUrlArray['href']):'').'";
894 var add_target="'.($this->setTarget?'&curUrl[target]='.rawurlencode($this->setTarget):'').'";
895 var add_class="'.($this->setClass ? '&curUrl[class]='.rawurlencode($this->setClass) : '').'";
896 var add_title="'.($this->setTitle?'&curUrl[title]='.rawurlencode($this->setTitle):'').'";
897 var add_params="'.($this->bparams?'&bparams='.rawurlencode($this->bparams):'').'";
898
899 var cur_href="'.($this->curUrlArray['href']?$this->curUrlArray['href']:'').'";
900 var cur_target="'.($this->setTarget?$this->setTarget:'').'";
901 var cur_class = "' . ($this->setClass ? $this->setClass : '') . '";
902 var cur_title="'.($this->setTitle?$this->setTitle:'').'";
903 var cur_params="' . ($this->setParams ? $this->setParams : '') . '";
904
905 function browse_links_setTarget(target) { //
906 cur_target=target;
907 add_target="&curUrl[target]="+escape(target);
908 }
909 function browse_links_setClass(cssClass) { //
910 cur_class = cssClass;
911 add_class = "&curUrl[class]=" + escape(cssClass);
912 }
913 function browse_links_setTitle(title) { //
914 cur_title=title;
915 add_title="&curUrl[title]="+escape(title);
916 }
917 function browse_links_setValue(value) { //
918 cur_href=value;
919 add_href="&curUrl[href]="+value;
920 }
921 function browse_links_setParams(params) { //
922 cur_params=params;
923 add_params="&curUrl[params]="+escape(params);
924 }
925 ';
926
927 if ($this->mode == 'wizard') { // Functions used, if the link selector is in wizard mode (= TCEforms fields)
928 if (!$this->areFieldChangeFunctionsValid() && !$this->areFieldChangeFunctionsValid(TRUE)) {
929 $this->P['fieldChangeFunc'] = array();
930 }
931 unset($this->P['fieldChangeFunc']['alert']);
932 $update='';
933 foreach ($this->P['fieldChangeFunc'] as $k => $v) {
934 $update.= '
935 window.opener.'.$v;
936 }
937
938 $P2=array();
939 $P2['itemName']=$this->P['itemName'];
940 $P2['formName']=$this->P['formName'];
941 $P2['fieldChangeFunc']=$this->P['fieldChangeFunc'];
942 $P2['fieldChangeFuncHash'] = t3lib_div::hmac(serialize($this->P['fieldChangeFunc']));
943 $P2['params']['allowedExtensions']=$this->P['params']['allowedExtensions'];
944 $P2['params']['blindLinkOptions']=$this->P['params']['blindLinkOptions'];
945 $addPassOnParams.=t3lib_div::implodeArrayForUrl('P',$P2);
946
947 $JScode.='
948 function link_typo3Page(id,anchor) { //
949 updateValueInMainForm(id + (anchor ? anchor : ""));
950 close();
951 return false;
952 }
953 function link_folder(folder) { //
954 updateValueInMainForm(folder);
955 close();
956 return false;
957 }
958 function link_current() { //
959 if (cur_href!="http://" && cur_href!="mailto:") {
960 returnBeforeCleaned = cur_href;
961 if (returnBeforeCleaned.substr(0, 7) == "http://") {
962 returnToMainFormValue = returnBeforeCleaned.substr(7);
963 } else if (returnBeforeCleaned.substr(0, 7) == "mailto:") {
964 if (returnBeforeCleaned.substr(0, 14) == "mailto:mailto:") {
965 returnToMainFormValue = returnBeforeCleaned.substr(14);
966 } else {
967 returnToMainFormValue = returnBeforeCleaned.substr(7);
968 }
969 } else {
970 returnToMainFormValue = returnBeforeCleaned;
971 }
972 updateValueInMainForm(returnToMainFormValue);
973 close();
974 }
975 return false;
976 }
977 function checkReference() { //
978 if (window.opener && window.opener.document && window.opener.document.'.$this->P['formName'].' && window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"] ) {
979 return window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"];
980 } else {
981 close();
982 }
983 }
984 function updateValueInMainForm(input) { //
985 var field = checkReference();
986 if (field) {
987 if (cur_target == "" && (cur_class != "" || cur_title != "" || cur_params != "")) {
988 cur_target = "-";
989 }
990 if (cur_class == "" && (cur_title != "" || cur_params != "")) {
991 cur_class = "-";
992 }
993 cur_class = cur_class.replace(/[\'\"]/g, "");
994 if (cur_class.indexOf(" ") != -1) {
995 cur_class = "\"" + cur_class + "\"";
996 }
997 if (cur_title == "" && cur_params != "") {
998 cur_title = "-";
999 }
1000 cur_title = cur_title.replace(/(^\")|(\"$)/g, "");
1001 if (cur_title.indexOf(" ") != -1) {
1002 cur_title = "\"" + cur_title + "\"";
1003 }
1004 if (cur_params) {
1005 cur_params = cur_params.replace(/\bid\=.*?(\&|$)/, "");
1006 }
1007 input = input + " " + cur_target + " " + cur_class + " " + cur_title + " " + cur_params;
1008 field.value = input;
1009 '.$update.'
1010 }
1011 }
1012 ';
1013 } else { // Functions used, if the link selector is in RTE mode:
1014 $JScode.='
1015 function link_typo3Page(id,anchor) { //
1016 var theLink = \''.$this->siteURL.'?id=\'+id+(anchor?anchor:"");
1017 self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
1018 return false;
1019 }
1020 function link_folder(folder) { //
1021 var theLink = \''.$this->siteURL.'\'+folder;
1022 self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
1023 return false;
1024 }
1025 function link_spec(theLink) { //
1026 self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
1027 return false;
1028 }
1029 function link_current() { //
1030 if (cur_href!="http://" && cur_href!="mailto:") {
1031 self.parent.parent.renderPopup_addLink(cur_href, cur_target, cur_class, cur_title);
1032 }
1033 return false;
1034 }
1035 ';
1036 }
1037
1038 // General "jumpToUrl" function:
1039 $JScode.='
1040 function jumpToUrl(URL,anchor) { //
1041 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
1042 var add_mode = URL.indexOf("mode=")==-1 ? "&mode='.$this->mode.'" : "";
1043 var theLocation = URL + add_act + add_mode + add_href + add_target + add_class + add_title + add_params'.($addPassOnParams?'+"'.$addPassOnParams.'"':'').'+(anchor?anchor:"");
1044 window.location.href = theLocation;
1045 return false;
1046 }
1047 ';
1048
1049
1050 /**
1051 * Splits parts of $this->bparams
1052 * @see $bparams
1053 */
1054 $pArr = explode('|',$this->bparams);
1055
1056 // This is JavaScript especially for the TBE Element Browser!
1057 $formFieldName = 'data['.$pArr[0].']['.$pArr[1].']['.$pArr[2].']';
1058
1059 // insertElement - Call check function (e.g. for uniqueness handling):
1060 if ($pArr[4] && $pArr[5]) {
1061 $JScodeCheck = '
1062 // Call a check function in the opener window (e.g. for uniqueness handling):
1063 if (parent.window.opener) {
1064 var res = parent.window.opener.'.$pArr[5].'("'.addslashes($pArr[4]).'",table,uid,type);
1065 if (!res.passed) {
1066 if (res.message) alert(res.message);
1067 performAction = false;
1068 }
1069 } else {
1070 alert("Error - reference to main window is not set properly!");
1071 parent.close();
1072 }
1073 ';
1074 }
1075 // insertElement - Call helper function:
1076 if ($pArr[4] && $pArr[6]) {
1077 $JScodeHelper = '
1078 // Call helper function to manage data in the opener window:
1079 if (parent.window.opener) {
1080 parent.window.opener.'.$pArr[6].'("'.addslashes($pArr[4]).'",table,uid,type,"'.addslashes($pArr[0]).'");
1081 } else {
1082 alert("Error - reference to main window is not set properly!");
1083 parent.close();
1084 }
1085 ';
1086 }
1087 // insertElement - perform action commands:
1088 if ($pArr[4] && $pArr[7]) {
1089 // Call user defined action function:
1090 $JScodeAction = '
1091 if (parent.window.opener) {
1092 parent.window.opener.'.$pArr[7].'("'.addslashes($pArr[4]).'",table,uid,type);
1093 focusOpenerAndClose(close);
1094 } else {
1095 alert("Error - reference to main window is not set properly!");
1096 parent.close();
1097 }
1098 ';
1099 } else if ($pArr[0] && !$pArr[1] && !$pArr[2]) {
1100 $JScodeAction = '
1101 addElement(filename,table+"_"+uid,fp,close);
1102 ';
1103 } else {
1104 $JScodeAction = '
1105 if (setReferences()) {
1106 parent.window.opener.group_change("add","'.$pArr[0].'","'.$pArr[1].'","'.$pArr[2].'",elRef,targetDoc);
1107 } else {
1108 alert("Error - reference to main window is not set properly!");
1109 }
1110 focusOpenerAndClose(close);
1111 ';
1112 }
1113
1114 $JScode.='
1115 var elRef="";
1116 var targetDoc="";
1117
1118 function launchView(url) { //
1119 var thePreviewWindow="";
1120 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");
1121 if (thePreviewWindow && thePreviewWindow.focus) {
1122 thePreviewWindow.focus();
1123 }
1124 }
1125 function setReferences() { //
1126 if (parent.window.opener && parent.window.opener.content && parent.window.opener.content.document.editform && parent.window.opener.content.document.editform["'.$formFieldName.'"]) {
1127 targetDoc = parent.window.opener.content.document;
1128 elRef = targetDoc.editform["'.$formFieldName.'"];
1129 return true;
1130 } else {
1131 return false;
1132 }
1133 }
1134 function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close) { //
1135 var performAction = true;
1136 '.$JScodeCheck.'
1137 // Call performing function and finish this action:
1138 if (performAction) {
1139 '.$JScodeHelper.$JScodeAction.'
1140 }
1141 return false;
1142 }
1143 function addElement(elName,elValue,altElValue,close) { //
1144 if (parent.window.opener && parent.window.opener.setFormValueFromBrowseWin) {
1145 parent.window.opener.setFormValueFromBrowseWin("'.$pArr[0].'",altElValue?altElValue:elValue,elName);
1146 focusOpenerAndClose(close);
1147 } else {
1148 alert("Error - reference to main window is not set properly!");
1149 parent.close();
1150 }
1151 }
1152 function focusOpenerAndClose(close) { //
1153 BrowseLinks.focusOpenerAndClose(close);
1154 }
1155 ';
1156
1157 // Finally, add the accumulated JavaScript to the template object:
1158 $this->doc->JScode.= $this->doc->wrapScriptTags($JScode);
1159
1160 // Debugging:
1161 if (FALSE) debug(array(
1162 'pointer' => $this->pointer,
1163 'act' => $this->act,
1164 'mode' => $this->mode,
1165 'curUrlInfo' => $this->curUrlInfo,
1166 'curUrlArray' => $this->curUrlArray,
1167 'P' => $this->P,
1168 'bparams' => $this->bparams,
1169 'RTEtsConfigParams' => $this->RTEtsConfigParams,
1170 'expandPage' => $this->expandPage,
1171 'expandFolder' => $this->expandFolder,
1172 'PM' => $this->PM,
1173 ),'Internal variables of Script Class:');
1174 }
1175
1176
1177 /**
1178 * Session data for this class can be set from outside with this method.
1179 * Call after init()
1180 *
1181 * @param array Session data array
1182 * @return array Session data and boolean which indicates that data needs to be stored in session because it's changed
1183 */
1184 function processSessionData($data) {
1185 $store = false;
1186
1187 switch((string)$this->mode) {
1188 case 'db':
1189 if (isset($this->expandPage)) {
1190 $data['expandPage']=$this->expandPage;
1191 $store = true;
1192 } else {
1193 $this->expandPage=$data['expandPage'];
1194 }
1195 break;
1196 case 'file':
1197 case 'filedrag':
1198 case 'folder':
1199 if (isset($this->expandFolder)) {
1200 $data['expandFolder']=$this->expandFolder;
1201 $store = true;
1202 } else {
1203 $this->expandFolder=$data['expandFolder'];
1204 }
1205 break;
1206 }
1207
1208 return array($data, $store);
1209 }
1210
1211
1212
1213
1214 /******************************************************************
1215 *
1216 * Main functions
1217 *
1218 ******************************************************************/
1219
1220 /**
1221 * Rich Text Editor (RTE) link selector (MAIN function)
1222 * Generates the link selector for the Rich Text Editor.
1223 * Can also be used to select links for the TCEforms (see $wiz)
1224 *
1225 * @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
1226 * @return string Modified content variable.
1227 */
1228 function main_rte($wiz=0) {
1229 global $LANG, $BACK_PATH;
1230
1231 // Starting content:
1232 $content=$this->doc->startPage('RTE link');
1233
1234 // Initializing the action value, possibly removing blinded values etc:
1235 $allowedItems = array_diff(
1236 explode(',','page,file,folder,url,mail,spec'),
1237 t3lib_div::trimExplode(',',$this->thisConfig['blindLinkOptions'],1)
1238 );
1239 $allowedItems = array_diff(
1240 $allowedItems,
1241 t3lib_div::trimExplode(',',$this->P['params']['blindLinkOptions'])
1242 );
1243
1244 //call hook for extra options
1245 foreach($this->hookObjects as $hookObject) {
1246 $allowedItems = $hookObject->addAllowedItems($allowedItems);
1247 }
1248
1249 reset($allowedItems);
1250 if (!in_array($this->act,$allowedItems)) $this->act = current($allowedItems);
1251
1252 // Making menu in top:
1253 $menuDef = array();
1254 if (!$wiz) {
1255 $menuDef['removeLink']['isActive'] = $this->act=='removeLink';
1256 $menuDef['removeLink']['label'] = $LANG->getLL('removeLink',1);
1257 $menuDef['removeLink']['url'] = '#';
1258 $menuDef['removeLink']['addParams'] = 'onclick="self.parent.parent.renderPopup_unLink();return false;"';
1259 }
1260 if (in_array('page',$allowedItems)) {
1261 $menuDef['page']['isActive'] = $this->act=='page';
1262 $menuDef['page']['label'] = $LANG->getLL('page',1);
1263 $menuDef['page']['url'] = '#';
1264 $menuDef['page']['addParams'] = 'onclick="jumpToUrl(\'?act=page\');return false;"';
1265 }
1266 if (in_array('file',$allowedItems)){
1267 $menuDef['file']['isActive'] = $this->act=='file';
1268 $menuDef['file']['label'] = $LANG->getLL('file',1);
1269 $menuDef['file']['url'] = '#';
1270 $menuDef['file']['addParams'] = 'onclick="jumpToUrl(\'?act=file\');return false;"';
1271 }
1272 if (in_array('folder',$allowedItems)){
1273 $menuDef['folder']['isActive'] = $this->act == 'folder';
1274 $menuDef['folder']['label'] = $LANG->getLL('folder', 1);
1275 $menuDef['folder']['url'] = '#';
1276 $menuDef['folder']['addParams'] = 'onclick="jumpToUrl(\'?act=folder\');return false;"';
1277 }
1278 if (in_array('url',$allowedItems)) {
1279 $menuDef['url']['isActive'] = $this->act=='url';
1280 $menuDef['url']['label'] = $LANG->getLL('extUrl',1);
1281 $menuDef['url']['url'] = '#';
1282 $menuDef['url']['addParams'] = 'onclick="jumpToUrl(\'?act=url\');return false;"';
1283 }
1284 if (in_array('mail',$allowedItems)) {
1285 $menuDef['mail']['isActive'] = $this->act=='mail';
1286 $menuDef['mail']['label'] = $LANG->getLL('email',1);
1287 $menuDef['mail']['url'] = '#';
1288 $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(\'?act=mail\');return false;"';
1289 }
1290 if (is_array($this->thisConfig['userLinks.']) && in_array('spec',$allowedItems)) {
1291 $menuDef['spec']['isActive'] = $this->act=='spec';
1292 $menuDef['spec']['label'] = $LANG->getLL('special',1);
1293 $menuDef['spec']['url'] = '#';
1294 $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(\'?act=spec\');return false;"';
1295 }
1296
1297 // call hook for extra options
1298 foreach($this->hookObjects as $hookObject) {
1299 $menuDef = $hookObject->modifyMenuDefinition($menuDef);
1300 }
1301
1302 $content .= $this->doc->getTabMenuRaw($menuDef);
1303
1304 // Adding the menu and header to the top of page:
1305 $content.=$this->printCurrentUrl($this->curUrlInfo['info']).'<br />';
1306
1307 // Depending on the current action we will create the actual module content for selecting a link:
1308 switch($this->act) {
1309 case 'mail':
1310 $extUrl='
1311
1312 <!--
1313 Enter mail address:
1314 -->
1315 <form action="" name="lurlform" id="lurlform">
1316 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
1317 <tr>
1318 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('emailAddress', 1) . ':</td>
1319 <td><input type="text" name="lemail"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='mail'?$this->curUrlInfo['info']:'').'" /> '.
1320 '<input type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', 1) . '" onclick="browse_links_setTarget(\'\');browse_links_setValue(\'mailto:\'+document.lurlform.lemail.value); return link_current();" /></td>
1321 </tr>
1322 </table>
1323 </form>';
1324 $content.=$extUrl;
1325 break;
1326 case 'url':
1327 $extUrl='
1328
1329 <!--
1330 Enter External URL:
1331 -->
1332 <form action="" name="lurlform" id="lurlform">
1333 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
1334 <tr>
1335 <td style="width: 96px;">URL:</td>
1336 <td><input type="text" name="lurl"'.$this->doc->formWidth(30).' value="'.htmlspecialchars($this->curUrlInfo['act']=='url'?$this->curUrlInfo['info']:'http://').'" /> '.
1337 '<input type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', 1) . '" onclick="browse_links_setValue(document.lurlform.lurl.value); return link_current();" /></td>
1338 </tr>
1339 </table>
1340 </form>';
1341 $content.=$extUrl;
1342 break;
1343 case 'file':
1344 case 'folder':
1345 $foldertree = t3lib_div::makeInstance('rteFolderTree');
1346 $foldertree->thisScript = $this->thisScript;
1347 $tree = $foldertree->getBrowsableTree();
1348
1349 if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act'] != $this->act) {
1350 $cmpPath = '';
1351 } elseif (substr(trim($this->curUrlInfo['info']), -1) != '/') {
1352 $cmpPath = PATH_site.dirname($this->curUrlInfo['info']).'/';
1353 if (!isset($this->expandFolder)) {
1354 $this->expandFolder = $cmpPath;
1355 }
1356 } else {
1357 $cmpPath = PATH_site.$this->curUrlInfo['info'];
1358 if (!isset($this->expandFolder) && $this->curUrlInfo['act'] == 'folder') {
1359 $this->expandFolder = $cmpPath;
1360 }
1361 }
1362
1363 list(, , $specUid) = explode('_', $this->PM);
1364 $files = $this->expandFolder(
1365 $foldertree->specUIDmap[$specUid],
1366 $this->P['params']['allowedExtensions']
1367 );
1368 $content.= '
1369
1370 <!--
1371 Wrapper table for folder tree / file/folder list:
1372 -->
1373 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
1374 <tr>
1375 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1376 <td class="c-wCell" valign="top">'.$files.'</td>
1377 </tr>
1378 </table>
1379 ';
1380 break;
1381 case 'spec':
1382 if (is_array($this->thisConfig['userLinks.'])) {
1383 $subcats=array();
1384 $v=$this->thisConfig['userLinks.'];
1385 foreach ($v as $k2 => $value) {
1386 $k2i = intval($k2);
1387 if (substr($k2,-1)=='.' && is_array($v[$k2i.'.'])) {
1388
1389 // Title:
1390 $title = trim($v[$k2i]);
1391 if (!$title) {
1392 $title=$v[$k2i.'.']['url'];
1393 } else {
1394 $title=$LANG->sL($title);
1395 }
1396 // Description:
1397 $description=$v[$k2i.'.']['description'] ? $LANG->sL($v[$k2i.'.']['description'],1).'<br />' : '';
1398
1399 // URL + onclick event:
1400 $onClickEvent='';
1401 if (isset($v[$k2i.'.']['target'])) $onClickEvent.="browse_links_setTarget('".$v[$k2i.'.']['target']."');";
1402 $v[$k2i.'.']['url'] = str_replace('###_URL###',$this->siteURL,$v[$k2i.'.']['url']);
1403 if (substr($v[$k2i.'.']['url'],0,7)=='http://' || substr($v[$k2i.'.']['url'],0,7)=='mailto:') {
1404 $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i.'.']['url'])."');link_current();";
1405 } else {
1406 $onClickEvent.="link_spec(unescape('".$this->siteURL.rawurlencode($v[$k2i.'.']['url'])."'));";
1407 }
1408
1409 // Link:
1410 $A=array('<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">','</a>');
1411
1412 // Adding link to menu of user defined links:
1413 $subcats[$k2i]='
1414 <tr>
1415 <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>
1416 </tr>';
1417 }
1418 }
1419
1420 // Sort by keys:
1421 ksort($subcats);
1422
1423 // Add menu to content:
1424 $content.= '
1425
1426 <!--
1427 Special userdefined menu:
1428 -->
1429 <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
1430 <tr>
1431 <td class="bgColor5" class="c-wCell" valign="top"><strong>'.$LANG->getLL('special',1).'</strong></td>
1432 </tr>
1433 '.implode('',$subcats).'
1434 </table>
1435 ';
1436 }
1437 break;
1438 case 'page':
1439 $pagetree = t3lib_div::makeInstance('rtePageTree');
1440 $pagetree->thisScript = $this->thisScript;
1441 $pagetree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
1442 $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
1443 $pagetree->addField('nav_title');
1444 $tree=$pagetree->getBrowsableTree();
1445 $cElements = $this->expandPage();
1446
1447 // Outputting Temporary DB mount notice:
1448 if (intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint'))) {
1449 $link = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))) . '">' .
1450 $LANG->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount', 1) .
1451 '</a>';
1452 $flashMessage = t3lib_div::makeInstance(
1453 't3lib_FlashMessage',
1454 $link,
1455 '',
1456 t3lib_FlashMessage::INFO
1457 );
1458 $dbmount = $flashMessage->render();
1459 }
1460
1461 $content.= '
1462
1463 <!--
1464 Wrapper table for page tree / record list:
1465 -->
1466 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
1467 <tr>
1468 <td class="c-wCell" valign="top">' . $this->barheader($GLOBALS['LANG']->getLL('pageTree') . ':') . $dbmount . $tree . '</td>
1469 <td class="c-wCell" valign="top">'.$cElements.'</td>
1470 </tr>
1471 </table>
1472 ';
1473 break;
1474 default:
1475 //call hook
1476 foreach($this->hookObjects as $hookObject) {
1477 $content .= $hookObject->getTab($this->act);
1478 }
1479 break;
1480 }
1481
1482 $content .= '
1483 <!--
1484 Selecting params for link:
1485 -->
1486 <form action="" name="lparamsform" id="lparamsform">
1487 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkParams">
1488 <tr>
1489 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('params', 1) . '</td>
1490 <td><input type="text" name="lparams" class="typo3-link-input" onchange="browse_links_setParams(this.value);" value="' . htmlspecialchars($this->setParams) . '" /></td>
1491 </tr>
1492 </table>
1493 </form>
1494
1495 <!--
1496 Selecting class for link:
1497 -->
1498 <form action="" name="lclassform" id="lclassform">
1499 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkClass">
1500 <tr>
1501 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('class', 1) . '</td>
1502 <td><input type="text" name="lclass" class="typo3-link-input" onchange="browse_links_setClass(this.value);" value="' . htmlspecialchars($this->setClass) . '" /></td>
1503 </tr>
1504 </table>
1505 </form>
1506
1507 <!--
1508 Selecting title for link:
1509 -->
1510 <form action="" name="ltitleform" id="ltitleform">
1511 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTitle">
1512 <tr>
1513 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('title', 1) . '</td>
1514 <td><input type="text" name="ltitle" class="typo3-link-input" onchange="browse_links_setTitle(this.value);" value="' . htmlspecialchars($this->setTitle) . '" /></td>
1515 </tr>
1516 </table>
1517 </form>
1518 ';
1519
1520 // Target:
1521 if ($this->act!='mail') {
1522 $ltarget='
1523
1524
1525
1526 <!--
1527 Selecting target for link:
1528 -->
1529 <form action="" name="ltargetform" id="ltargetform">
1530 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
1531 <tr>
1532 <td>'.$GLOBALS['LANG']->getLL('target',1).':</td>
1533 <td><input type="text" name="ltarget" onchange="browse_links_setTarget(this.value);" value="' . htmlspecialchars($this->setTarget) . '"' . $this->doc->formWidth(10) . ' /></td>
1534 <td>
1535 <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;">
1536 <option></option>
1537 <option value="_top">'.$GLOBALS['LANG']->getLL('top',1).'</option>
1538 <option value="_blank">'.$GLOBALS['LANG']->getLL('newWindow',1).'</option>
1539 </select>
1540 </td>
1541 <td>';
1542 if (($this->curUrlInfo['act'] == 'page' || $this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder') && $this->curUrlArray['href'] && $this->curUrlInfo['act'] == $this->act) {
1543 $ltarget.='
1544 <input type="submit" value="'.$GLOBALS['LANG']->getLL('update',1).'" onclick="return link_current();" />';
1545 }
1546
1547 $selectJS = '
1548 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) {
1549 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;
1550 browse_links_setTarget(document.ltargetform.ltarget.value);
1551 browse_links_setClass(document.lclassform.lclass.value);
1552 browse_links_setTitle(document.ltitleform.ltitle.value);
1553 browse_links_setParams(document.lparamsform.lparams.value);
1554 document.ltargetform.popup_width.selectedIndex=0;
1555 document.ltargetform.popup_height.selectedIndex=0;
1556 }
1557 ';
1558
1559 $ltarget.=' </td>
1560 </tr>
1561 <tr>
1562 <td>'.$GLOBALS['LANG']->getLL('target_popUpWindow',1).':</td>
1563 <td colspan="3">
1564 <select name="popup_width" onchange="'.htmlspecialchars($selectJS).'">
1565 <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_width',1).'</option>
1566 <option value="300">300</option>
1567 <option value="400">400</option>
1568 <option value="500">500</option>
1569 <option value="600">600</option>
1570 <option value="700">700</option>
1571 <option value="800">800</option>
1572 </select>
1573 x
1574 <select name="popup_height" onchange="'.htmlspecialchars($selectJS).'">
1575 <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_height',1).'</option>
1576 <option value="200">200</option>
1577 <option value="300">300</option>
1578 <option value="400">400</option>
1579 <option value="500">500</option>
1580 <option value="600">600</option>
1581 </select>
1582 </td>
1583 </tr>
1584 </table>
1585 </form>';
1586
1587 // Add "target selector" box to content:
1588 $content.=$ltarget;
1589
1590 // Add some space
1591 $content.='<br /><br />';
1592 }
1593
1594 // End page, return content:
1595 $content.= $this->doc->endPage();
1596 $content = $this->doc->insertStylesAndJS($content);
1597 return $content;
1598 }
1599
1600 /**
1601 * TYPO3 Element Browser: Showing a page tree and allows you to browse for records
1602 *
1603 * @return string HTML content for the module
1604 */
1605 function main_db() {
1606
1607 // Starting content:
1608 $content=$this->doc->startPage('TBE record selector');
1609
1610 // Init variable:
1611 $pArr = explode('|',$this->bparams);
1612
1613 // Making the browsable pagetree:
1614 $pagetree = t3lib_div::makeInstance('TBE_PageTree');
1615 $pagetree->thisScript=$this->thisScript;
1616 $pagetree->ext_pArrPages = !strcmp($pArr[3],'pages')?1:0;
1617 $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
1618 $pagetree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
1619 $pagetree->addField('nav_title');
1620 $tree=$pagetree->getBrowsableTree();
1621
1622 // Making the list of elements, if applicable:
1623 $cElements = $this->TBE_expandPage($pArr[3]);
1624
1625 // Putting the things together, side by side:
1626 $content.= '
1627
1628 <!--
1629 Wrapper table for page tree / record list:
1630 -->
1631 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBrecords">
1632 <tr>
1633 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('pageTree').':').$tree.'</td>
1634 <td class="c-wCell" valign="top">'.$cElements.'</td>
1635 </tr>
1636 </table>
1637 ';
1638
1639 // Add some space
1640 $content.='<br /><br />';
1641
1642 // End page, return content:
1643 $content.= $this->doc->endPage();
1644 $content = $this->doc->insertStylesAndJS($content);
1645 return $content;
1646 }
1647
1648 /**
1649 * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for files.
1650 *
1651 * @return string HTML content for the module
1652 */
1653 function main_file() {
1654 global $BE_USER;
1655
1656 // Starting content:
1657 $content.=$this->doc->startPage('TBE file selector');
1658
1659 // Init variable:
1660 $pArr = explode('|',$this->bparams);
1661
1662 // Create upload/create folder forms, if a path is given:
1663 $path=$this->expandFolder;
1664 if (!$path || !@is_dir($path)) {
1665 // The closest TEMP-path is found
1666 $path = $this->fileProcessor->findTempFolder().'/';
1667 }
1668 if ($path!='/' && @is_dir($path)) {
1669 $uploadForm=$this->uploadForm($path);
1670 $createFolder=$this->createFolder($path);
1671 } else {
1672 $createFolder='';
1673 $uploadForm='';
1674 }
1675 if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) $content.=$uploadForm;
1676
1677 // Getting flag for showing/not showing thumbnails:
1678 $noThumbs = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
1679
1680 if (!$noThumbs) {
1681 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
1682 $_MOD_MENU = array('displayThumbs' => '');
1683 $_MCONF['name']='file_list';
1684 $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']);
1685 $addParams = '&act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
1686 $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>';
1687 } else {
1688 $thumbNailCheck='';
1689 }
1690 $noThumbs = $noThumbs ? $noThumbs : !$_MOD_SETTINGS['displayThumbs'];
1691
1692 // Create folder tree:
1693 $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
1694 $foldertree->thisScript=$this->thisScript;
1695 $foldertree->ext_noTempRecyclerDirs = ($this->mode == 'filedrag');
1696 $tree=$foldertree->getBrowsableTree();
1697
1698 list(,,$specUid) = explode('_',$this->PM);
1699
1700 if ($this->mode=='filedrag') {
1701 $files = $this->TBE_dragNDrop($foldertree->specUIDmap[$specUid],$pArr[3]);
1702 } else {
1703 $files = $this->TBE_expandFolder($foldertree->specUIDmap[$specUid],$pArr[3],$noThumbs);
1704 }
1705
1706 // Putting the parts together, side by side:
1707 $content.= '
1708
1709 <!--
1710 Wrapper table for folder tree / file list:
1711 -->
1712 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
1713 <tr>
1714 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1715 <td class="c-wCell" valign="top">'.$files.'</td>
1716 </tr>
1717 </table>
1718 ';
1719 $content.= $thumbNailCheck;
1720
1721 // Adding create folder + upload forms if applicable:
1722 if (!$BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) $content.=$uploadForm;
1723 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) $content.=$createFolder;
1724
1725 // Add some space
1726 $content.='<br /><br />';
1727
1728 // Setup indexed elements:
1729 $this->doc->JScode.= $this->doc->wrapScriptTags('BrowseLinks.addElements(' . json_encode($this->elements) . ');');
1730 // Ending page, returning content:
1731 $content.= $this->doc->endPage();
1732 $content = $this->doc->insertStylesAndJS($content);
1733
1734 return $content;
1735 }
1736
1737 /**
1738 * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for folders.
1739 *
1740 * @return string HTML content for the module
1741 */
1742 function main_folder() {
1743 global $BE_USER;
1744
1745 // Starting content:
1746 $content = $this->doc->startPage('TBE folder selector');
1747
1748 // Init variable:
1749 $parameters = explode('|', $this->bparams);
1750
1751
1752 $path = $this->expandFolder;
1753 if (!$path || !@is_dir($path)) {
1754 // The closest TEMP-path is found
1755 $path = $this->fileProcessor->findTempFolder().'/';
1756 }
1757 if ($path != '/' && @is_dir($path)) {
1758 $createFolder = $this->createFolder($path);
1759 } else {
1760 $createFolder='';
1761 }
1762
1763 // Create folder tree:
1764 $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
1765 $foldertree->thisScript = $this->thisScript;
1766 $foldertree->ext_noTempRecyclerDirs = ($this->mode == 'filedrag');
1767 $tree = $foldertree->getBrowsableTree(false);
1768
1769 list(, , $specUid) = explode('_', $this->PM);
1770
1771 if($this->mode == 'filedrag') {
1772 $folders = $this->TBE_dragNDrop(
1773 $foldertree->specUIDmap[$specUid],
1774 $parameters[3]
1775 );
1776 } else {
1777 $folders = $this->TBE_expandSubFolders($foldertree->specUIDmap[$specUid]);
1778 }
1779
1780 // Putting the parts together, side by side:
1781 $content.= '
1782
1783 <!--
1784 Wrapper table for folder tree / folder list:
1785 -->
1786 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
1787 <tr>
1788 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1789 <td class="c-wCell" valign="top">'.$folders.'</td>
1790 </tr>
1791 </table>
1792 ';
1793
1794 // Adding create folder if applicable:
1795 if($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
1796 $content .= $createFolder;
1797 }
1798
1799 // Add some space
1800 $content .= '<br /><br />';
1801
1802 // Ending page, returning content:
1803 $content.= $this->doc->endPage();
1804 $content = $this->doc->insertStylesAndJS($content);
1805
1806 return $content;
1807 }
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825 /******************************************************************
1826 *
1827 * Record listing
1828 *
1829 ******************************************************************/
1830 /**
1831 * For RTE: This displays all content elements on a page and lets you create a link to the element.
1832 *
1833 * @return string HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...)
1834 */
1835 function expandPage() {
1836 global $BE_USER, $BACK_PATH;
1837
1838 $out='';
1839 $expPageId = $this->expandPage; // Set page id (if any) to expand
1840
1841 // If there is an anchor value (content element reference) in the element reference, then force an ID to expand:
1842 if (!$this->expandPage && $this->curUrlInfo['cElement']) {
1843 $expPageId = $this->curUrlInfo['pageid']; // Set to the current link page id.
1844 }
1845
1846 // Draw the record list IF there is a page id to expand:
1847 if ($expPageId && t3lib_div::testInt($expPageId) && $BE_USER->isInWebMount($expPageId)) {
1848
1849 // Set header:
1850 $out.=$this->barheader($GLOBALS['LANG']->getLL('contentElements').':');
1851
1852 // Create header for listing, showing the page title/icon:
1853 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1854 $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages',$expPageId);
1855 $picon = t3lib_iconWorks::getSpriteIconForRecord('pages', $mainPageRec);
1856 $picon.= htmlspecialchars(t3lib_div::fixed_lgd_cs($mainPageRec['title'],$titleLen));
1857 $out.=$picon.'<br />';
1858
1859 // Look up tt_content elements from the expanded page:
1860 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1861 'uid,header,hidden,starttime,endtime,fe_group,CType,colpos,bodytext',
1862 'tt_content',
1863 'pid='.intval($expPageId).
1864 t3lib_BEfunc::deleteClause('tt_content').
1865 t3lib_BEfunc::versioningPlaceholderClause('tt_content'),
1866 '',
1867 'colpos,sorting'
1868 );
1869 $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1870
1871 // Traverse list of records:
1872 $c=0;
1873 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1874 $c++;
1875 $icon = t3lib_iconWorks::getSpriteIconForRecord('tt_content', $row);
1876 if ($this->curUrlInfo['act']=='page' && $this->curUrlInfo['cElement']==$row['uid']) {
1877 $arrCol='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
1878 } else {
1879 $arrCol='';
1880 }
1881 // Putting list element HTML together:
1882 $out.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join'.($c==$cc?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
1883 $arrCol.
1884 '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.$row['uid'].'\');">'.
1885 $icon.
1886 htmlspecialchars(t3lib_div::fixed_lgd_cs($row['header'],$titleLen)).
1887 '</a><br />';
1888
1889 // Finding internal anchor points:
1890 if (t3lib_div::inList('text,textpic', $row['CType'])) {
1891 $split = preg_split('/(<a[^>]+name=[\'"]?([^"\'>[:space:]]+)[\'"]?[^>]*>)/i', $row['bodytext'], -1, PREG_SPLIT_DELIM_CAPTURE);
1892
1893 foreach($split as $skey => $sval) {
1894 if (($skey%3)==2) {
1895 // Putting list element HTML together:
1896 $sval = substr($sval,0,100);
1897 $out.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/line.gif','width="18" height="16"').' alt="" />'.
1898 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join'.($skey+3>count($split)?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
1899 '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.rawurlencode($sval).'\');">'.
1900 htmlspecialchars(' <A> '.$sval).
1901 '</a><br />';
1902 }
1903 }
1904 }
1905 }
1906 }
1907 return $out;
1908 }
1909
1910 /**
1911 * For TYPO3 Element Browser: This lists all content elements from the given list of tables
1912 *
1913 * @param string Commalist of tables. Set to "*" if you want all tables.
1914 * @return string HTML output.
1915 */
1916 function TBE_expandPage($tables) {
1917 global $TCA,$BE_USER, $BACK_PATH;
1918
1919 $out='';
1920 if ($this->expandPage>=0 && t3lib_div::testInt($this->expandPage) && $BE_USER->isInWebMount($this->expandPage)) {
1921
1922 // Set array with table names to list:
1923 if (!strcmp(trim($tables),'*')) {
1924 $tablesArr = array_keys($TCA);
1925 } else {
1926 $tablesArr = t3lib_div::trimExplode(',',$tables,1);
1927 }
1928 reset($tablesArr);
1929
1930 // Headline for selecting records:
1931 $out.=$this->barheader($GLOBALS['LANG']->getLL('selectRecords').':');
1932
1933 // Create the header, showing the current page for which the listing is. Includes link to the page itself, if pages are amount allowed tables.
1934 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1935 $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages',$this->expandPage);
1936 $ATag='';
1937 $ATag_e='';
1938 $ATag2='';
1939 $picon = '';
1940 if (is_array($mainPageRec)) {
1941 $picon = t3lib_iconWorks::getSpriteIconForRecord('pages', $mainPageRec);
1942 if (in_array('pages', $tablesArr)) {
1943 $ATag = "<a href=\"#\" onclick=\"return insertElement('pages', '" . $mainPageRec['uid'] .
1944 "', 'db', " . t3lib_div::quoteJSvalue($mainPageRec['title']) . ", '', '', '','',1);\">";
1945 $ATag2 = "<a href=\"#\" onclick=\"return insertElement('pages', '" . $mainPageRec['uid'] .
1946 "', 'db', " . t3lib_div::quoteJSvalue($mainPageRec['title']) . ", '', '', '','',0);\">";
1947 $ATag_alt = substr($ATag, 0, -4) . ",'',1);\">";
1948 $ATag_e = '</a>';
1949 }
1950 }
1951 $pBicon=$ATag2?'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' alt="" />':'';
1952 $pText=htmlspecialchars(t3lib_div::fixed_lgd_cs($mainPageRec['title'],$titleLen));
1953 $out.=$picon.$ATag2.$pBicon.$ATag_e.$ATag.$pText.$ATag_e.'<br />';
1954
1955 // Initialize the record listing:
1956 $id = $this->expandPage;
1957 $pointer = t3lib_div::intInRange($this->pointer,0,100000);
1958 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
1959 $pageinfo = t3lib_BEfunc::readPageAccess($id,$perms_clause);
1960 $table='';
1961
1962 // Generate the record list:
1963 $dblist = t3lib_div::makeInstance('TBE_browser_recordList');
1964 $dblist->thisScript=$this->thisScript;
1965 $dblist->backPath = $GLOBALS['BACK_PATH'];
1966 $dblist->thumbs = 0;
1967 $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageinfo);
1968 $dblist->noControlPanels=1;
1969 $dblist->clickMenuEnabled=0;
1970 $dblist->tableList=implode(',',$tablesArr);
1971
1972 $dblist->start($id,t3lib_div::_GP('table'),$pointer,
1973 t3lib_div::_GP('search_field'),
1974 t3lib_div::_GP('search_levels'),
1975 t3lib_div::_GP('showLimit')
1976 );
1977 $dblist->setDispFields();
1978 $dblist->generateList();
1979 $dblist->writeBottom();
1980
1981 // Add the HTML for the record list to output variable:
1982 $out.=$dblist->HTMLcode;
1983
1984 // Add support for fieldselectbox in singleTableMode
1985 if ($dblist->table) {
1986 $out.= $dblist->fieldSelectBox($dblist->table);
1987 }
1988
1989 $out.=$dblist->getSearchBox();
1990 }
1991
1992 // Return accumulated content:
1993 return $out;
1994 }
1995
1996
1997 /**
1998 * Render list of folders inside a folder.
1999 *
2000 * @param string string of the current folder
2001 * @return string HTML output
2002 */
2003 function TBE_expandSubFolders($expandFolder=0) {
2004 $content = '';
2005
2006 $expandFolder = $expandFolder ?
2007 $expandFolder :
2008 $this->expandFolder;
2009
2010 if($expandFolder && $this->checkFolder($expandFolder)) {
2011 if(t3lib_div::isFirstPartOfStr($expandFolder, PATH_site)) {
2012 $rootFolder = substr($expandFolder, strlen(PATH_site));
2013 }
2014
2015 $folders = array();
2016
2017 // Listing the folders:
2018 $folders = t3lib_div::get_dirs($expandFolder);
2019 if(count($folders) > 0) {
2020 foreach($folders as $index => $folder) {
2021 $folders[$index] = $rootFolder.$folder.'/';
2022 }
2023 }
2024 $content.= $this->folderList($rootFolder, $folders);
2025 }
2026
2027 // Return accumulated content for folderlisting:
2028 return $content;
2029 }
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041 /******************************************************************
2042 *
2043 * File listing
2044 *
2045 ******************************************************************/
2046 /**
2047 * For RTE: This displays all files from folder. No thumbnails shown
2048 *
2049 * @param string The folder path to expand
2050 * @param string List of fileextensions to show
2051 * @return string HTML output
2052 */
2053 function expandFolder($expandFolder=0,$extensionList='') {
2054 global $BACK_PATH;
2055
2056 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
2057 $out='';
2058 if ($expandFolder && $this->checkFolder($expandFolder)) {
2059
2060 // Create header for filelisting:
2061 $out.=$this->barheader($GLOBALS['LANG']->getLL('files').':');
2062
2063 // Prepare current path value for comparison (showing red arrow)
2064 if (!$this->curUrlInfo['value']) {
2065 $cmpPath='';
2066 } else {
2067 $cmpPath=PATH_site.$this->curUrlInfo['info'];
2068 }
2069
2070
2071 // Create header element; The folder from which files are listed.
2072 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
2073 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
2074 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen));
2075 $picon='<a href="#" onclick="return link_folder(\''.t3lib_div::rawUrlEncodeFP(substr($expandFolder,strlen(PATH_site))).'\');">'.$picon.'</a>';
2076 if ($this->curUrlInfo['act'] == 'folder' && $cmpPath == $expandFolder) {
2077 $out.= '<img'.t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/blinkarrow_left.gif', 'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />';
2078 }
2079 $out.=$picon.'<br />';
2080
2081 // Get files from the folder:
2082 if ($this->mode == 'wizard' && $this->act == 'folder') {
2083 $files = t3lib_div::get_dirs($expandFolder);
2084 } else {
2085 $files = t3lib_div::getFilesInDir($expandFolder, $extensionList, 1, 1); // $extensionList='', $prependPath=0, $order='')
2086 }
2087
2088 $c=0;
2089 $cc=count($files);
2090 if (is_array($files)) {
2091 foreach($files as $filepath) {
2092 $c++;
2093 $fI=pathinfo($filepath);
2094
2095 if ($this->mode == 'wizard' && $this->act == 'folder') {
2096 $filepath = $expandFolder.$filepath.'/';
2097 $icon = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />';
2098 } else {
2099 // File icon:
2100 $icon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
2101
2102 // Get size and icon:
2103 $size = ' (' . t3lib_div::formatSize(filesize($filepath)) . 'bytes)';
2104 $icon = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/fileicons/' . $icon . '', 'width="18" height="16"') . ' title="' . htmlspecialchars($fI['basename'] . $size) . '" alt="" />';
2105 }
2106
2107 // If the listed file turns out to be the CURRENT file, then show blinking arrow:
2108 if (($this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder') && $cmpPath == $filepath) {
2109 $arrCol='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
2110 } else {
2111 $arrCol='';
2112 }
2113
2114 // Put it all together for the file element:
2115 $out.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join'.($c==$cc?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
2116 $arrCol.
2117 '<a href="#" onclick="return link_folder(\''.t3lib_div::rawUrlEncodeFP(substr($filepath,strlen(PATH_site))).'\');">'.
2118 $icon.
2119 htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen)).
2120 '</a><br />';
2121 }
2122 }
2123 }
2124 return $out;
2125 }
2126
2127 /**
2128 * For TYPO3 Element Browser: Expand folder of files.
2129 *
2130 * @param string The folder path to expand
2131 * @param string List of fileextensions to show
2132 * @param boolean Whether to show thumbnails or not. If set, no thumbnails are shown.
2133 * @return string HTML output
2134 */
2135 function TBE_expandFolder($expandFolder=0,$extensionList='',$noThumbs=0) {
2136 global $LANG;
2137
2138 $extensionList = ($extensionList == '*') ? '' : $extensionList;
2139 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
2140 $out='';
2141 if ($expandFolder && $this->checkFolder($expandFolder)) {
2142 // Listing the files:
2143 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
2144 $out.= $this->fileList($files, $expandFolder, $noThumbs);
2145 }
2146
2147 // Return accumulated content for filelisting:
2148 return $out;
2149 }
2150
2151 /**
2152 * Render list of files.
2153 *
2154 * @param array List of files. See t3lib_div::getFilesInDir
2155 * @param string If set a header with a folder icon and folder name are shown
2156 * @param boolean Whether to show thumbnails or not. If set, no thumbnails are shown.
2157 * @return string HTML output
2158 */
2159 function fileList($files, $folderName='', $noThumbs=0) {
2160 global $LANG, $BACK_PATH;
2161
2162 $out='';
2163
2164 // Listing the files:
2165 if (is_array($files)) {
2166
2167 // Create headline (showing number of files):
2168 $filesCount = count($files);
2169 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):', $filesCount));
2170 $out.=$this->getBulkSelector($filesCount);
2171
2172 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
2173
2174 // Create the header of current folder:
2175 if($folderName) {
2176 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
2177 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($folderName),$titleLen));
2178 $out.=$picon.'<br />';
2179 }
2180
2181 // Init graphic object for reading file dimensions:
2182 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
2183 $imgObj->init();
2184 $imgObj->mayScaleUp=0;
2185 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
2186
2187 // Traverse the file list:
2188 $lines=array();
2189 foreach($files as $filepath) {
2190 $fI=pathinfo($filepath);
2191
2192 // Thumbnail/size generation:
2193 if (t3lib_div::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),strtolower($fI['extension'])) && !$noThumbs) {
2194 $imgInfo = $imgObj->getImageDimensions($filepath);
2195 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
2196 $clickIcon = t3lib_BEfunc::getThumbNail($BACK_PATH.'thumbs.php',$filepath,'hspace="5" vspace="5" border="1"');
2197 } else {
2198 $clickIcon = '';
2199 $pDim = '';
2200 }
2201
2202 // Create file icon:
2203 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
2204 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
2205 $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" class="absmiddle" alt="" />';
2206
2207 // Create links for adding the file:
2208 if (strstr($filepath,',') || strstr($filepath,'|')) { // In case an invalid character is in the filepath, display error message:
2209 $eMsg = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'),', |'));
2210 $ATag = $ATag_alt = "<a href=\"#\" onclick=\"alert(".$eMsg.");return false;\">";
2211 $bulkCheckBox = '';
2212 } else { // If filename is OK, just add it:
2213 $filesIndex = count($this->elements);
2214 $this->elements['file_'.$filesIndex] = array(
2215 'md5' => t3lib_div::shortMD5($filepath),
2216 'type' => 'file',
2217 'fileName' => $fI['basename'],
2218 'filePath' => $filepath,
2219 'fileExt' => $fI['extension'],
2220 'fileIcon' => $ficon,
2221 );
2222 $ATag = "<a href=\"#\" onclick=\"return BrowseLinks.File.insertElement('file_$filesIndex');\">";
2223 $ATag_alt = substr($ATag,0,-4).",1);\">";
2224 $bulkCheckBox = '<input type="checkbox" class="typo3-bulk-item" name="file_'.$filesIndex.'" value="0" /> ';
2225 }
2226 $ATag_e='</a>';
2227
2228 // Create link to showing details about the file in a window:
2229 $Ahref = $BACK_PATH.'show_item.php?table='.rawurlencode($filepath).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
2230 $ATag2='<a href="'.htmlspecialchars($Ahref).'">';
2231 $ATag2_e='</a>';
2232
2233 // Combine the stuff:
2234 $filenameAndIcon=$bulkCheckBox.$ATag_alt.$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen)).$ATag_e;
2235
2236 // Show element:
2237 if ($pDim) { // Image...
2238 $lines[]='
2239 <tr class="bgColor4">
2240 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
2241 <td>'.$ATag.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$ATag_e.'</td>
2242 <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>
2243 <td nowrap="nowrap">&nbsp;'.$pDim.'</td>
2244 </tr>';
2245 $lines[]='
2246 <tr>
2247 <td colspan="4">'.$ATag_alt.$clickIcon.$ATag_e.'</td>
2248 </tr>';
2249 } else {
2250 $lines[]='
2251 <tr class="bgColor4">
2252 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
2253 <td>'.$ATag.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$ATag_e.'</td>
2254 <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>
2255 <td>&nbsp;</td>
2256 </tr>';
2257 }
2258 $lines[]='
2259 <tr>
2260 <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
2261 </tr>';
2262 }
2263
2264 // Wrap all the rows in table tags:
2265 $out.='
2266
2267
2268
2269 <!--
2270 File listing
2271 -->
2272 <table cellpadding="0" cellspacing="0" id="typo3-fileList">
2273 '.implode('',$lines).'
2274 </table>';
2275 }
2276 // Return accumulated content for filelisting:
2277 return $out;
2278 }
2279
2280 /**
2281 * Render list of folders.
2282 *
2283 * @param array List of folders. See t3lib_div::get_dirs
2284 * @param string If set a header with a folder icon and folder name are shown
2285 * @return string HTML output
2286 */
2287 function folderList($baseFolder, $folders) {
2288 global $LANG, $BACK_PATH;
2289
2290 $content = '';
2291
2292 // Create headline (showing number of folders):
2293 $content.=$this->barheader(
2294 sprintf($GLOBALS['LANG']->getLL('folders').' (%s):',count($folders))
2295 );
2296
2297 $titleLength = intval($GLOBALS['BE_USER']->uc['titleLen']);
2298
2299 // Create the header of current folder:
2300 if($baseFolder) {
2301 if (strstr($baseFolder, ',') || strstr($baseFolder, '|')) {
2302 // In case an invalid character is in the filepath, display error message:
2303 $errorMessage = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'),', |'));
2304 $aTag = $aTag_alt = "<a href=\"#\" onclick=\"alert(".$errorMessage.");return false;\">";
2305 } else {
2306 // If foldername is OK, just add it:
2307 $aTag = "<a href=\"#\" onclick=\"return insertElement('','".rawurlencode($baseFolder)."', 'folder', '".rawurlencode($baseFolder)."', unescape('".rawurlencode($baseFolder)."'), '".$fI['extension']."', '".$ficon."');\">";
2308 $aTag_alt = substr($aTag,0,-4).",'',1);\">";
2309 }
2310 $aTag_e = '</a>';
2311
2312 // add the foder icon
2313 $folderIcon = $aTag_alt;
2314 $folderIcon.= '<img'.t3lib_iconWorks::skinImg(
2315 $BACK_PATH,
2316 'gfx/i/_icon_webfolders.gif','width="18" height="16"'
2317 ).' alt="" />';
2318 $folderIcon.= htmlspecialchars(
2319 t3lib_div::fixed_lgd_cs(basename($baseFolder),$titleLength)
2320 );
2321 $folderIcon.= $aTag_e;
2322
2323 $content.=$folderIcon.'<br />';
2324 }
2325
2326 // Listing the folders:
2327 if(is_array($folders)) {
2328 if(count($folders) > 0) {
2329 // Traverse the folder list:
2330 $lines = array();
2331 foreach($folders as $folderPath) {
2332 $pathInfo = pathinfo($folderPath);
2333
2334 // Create folder icon:
2335 $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="" />';
2336
2337 // Create links for adding the folder:
2338 if($this->P['itemName'] != '' && $this->P['formName'] != '') {
2339 $aTag = "<a href=\"#\" onclick=\"return set_folderpath(unescape('".rawurlencode($folderPath)."'));\">";
2340 } else {
2341 $aTag = "<a href=\"#\" onclick=\"return insertElement('','".rawurlencode($folderPath)."', 'folder', '".rawurlencode($folderPath)."', unescape('".rawurlencode($folderPath)."'), '".$pathInfo['extension']."', '".$ficon."');\">";
2342 }
2343
2344 if (strstr($folderPath,',') || strstr($folderPath,'|')) {
2345 // In case an invalid character is in the filepath, display error message:
2346 $errorMessage = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'),', |'));
2347 $aTag = $aTag_alt = "<a href=\"#\" onclick=\"alert(".$errorMessage.");return false;\">";
2348 } else {
2349 // If foldername is OK, just add it:
2350 $aTag_alt = substr($aTag,0,-4).",'',1);\">";
2351 }
2352 $aTag_e='</a>';
2353
2354 // Combine icon and folderpath:
2355 $foldernameAndIcon = $aTag_alt.$icon.htmlspecialchars(
2356 t3lib_div::fixed_lgd_cs(basename($folderPath),$titleLength)
2357 ).$aTag_e;
2358
2359 if($this->P['itemName'] != '') {
2360 $lines[] = '
2361 <tr class="bgColor4">
2362 <td nowrap="nowrap">'.$foldernameAndIcon.'&nbsp;</td>
2363 <td>&nbsp;</td>
2364 </tr>';
2365 } else {
2366 $lines[] = '
2367 <tr class="bgColor4">
2368 <td nowrap="nowrap">'.$foldernameAndIcon.'&nbsp;</td>
2369 <td>'.$aTag.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$aTag_e.'</td>
2370 <td>&nbsp;</td>
2371 </tr>';
2372 }
2373
2374 $lines[] = '
2375 <tr>
2376 <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
2377 </tr>';
2378 }
2379 }
2380
2381 // Wrap all the rows in table tags:
2382 $content.='
2383
2384 <!--
2385 Folder listing
2386 -->
2387 <table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList">
2388 '.implode('', $lines).'
2389 </table>';
2390 }
2391
2392 // Return accumulated content for folderlisting:
2393 return $content;
2394 }
2395
2396 /**
2397 * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
2398 * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
2399 *
2400 * @param string The folder path to expand
2401 * @param string List of fileextensions to show
2402 * @return string HTML output
2403 */
2404 function TBE_dragNDrop($expandFolder=0,$extensionList='') {
2405 global $BACK_PATH;
2406
2407 $extensionList = ($extensionList == '*') ? '' : $extensionList;
2408 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
2409 $out='';
2410 if ($expandFolder && $this->checkFolder($expandFolder)) {
2411 if ($this->isWebFolder($expandFolder)) {
2412
2413 // Read files from directory:
2414 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
2415 if (is_array($files)) {
2416 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
2417
2418 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
2419 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
2420 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen));
2421 $out.=$picon.'<br />';
2422
2423 // Init row-array:
2424 $lines=array();
2425
2426 // Add "drag-n-drop" message:
2427 $lines[]='
2428 <tr>
2429 <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
2430 </tr>';
2431
2432 // Traverse files:
2433 foreach ($files as $filepath) {
2434 $fI = pathinfo($filepath);
2435
2436 // URL of image:
2437 $iurl = $this->siteURL.t3lib_div::rawurlencodeFP(substr($filepath,strlen(PATH_site)));
2438
2439 // Show only web-images
2440 if (t3lib_div::inList('gif,jpeg,jpg,png',strtolower($fI['extension']))) {
2441 $imgInfo = @getimagesize($filepath);
2442 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
2443
2444 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
2445 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
2446 $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
2447 $filenameAndIcon=$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen));
2448
2449 if (t3lib_div::_GP('noLimit')) {
2450 $maxW=10000;
2451 $maxH=10000;
2452 } else {
2453 $maxW=380;
2454 $maxH=500;
2455 }
2456 $IW = $imgInfo[0];
2457 $IH = $imgInfo[1];
2458 if ($IW>$maxW) {
2459 $IH=ceil($IH/$IW*$maxW);
2460 $IW=$maxW;
2461 }
2462 if ($IH>$maxH) {
2463 $IW=ceil($IW/$IH*$maxH);
2464 $IH=$maxH;
2465 }
2466
2467 // Make row:
2468 $lines[]='
2469 <tr class="bgColor4">
2470 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
2471 <td nowrap="nowrap">'.
2472 ($imgInfo[0]!=$IW ? '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('noLimit'=>'1'))).'">'.
2473 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/icon_warning2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize',1).'" alt="" />'.
2474 '</a>':'').
2475 $pDim.'&nbsp;</td>
2476 </tr>';
2477
2478 $lines[]='
2479 <tr>
2480 <td colspan="2"><img src="'.$iurl.'" width="'.$IW.'" height="'.$IH.'" border="1" alt="" /></td>
2481 </tr>';
2482 $lines[]='
2483 <tr>
2484 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
2485 </tr>';
2486 }
2487 }
2488
2489 // Finally, wrap all rows in a table tag:
2490 $out.='
2491
2492
2493 <!--
2494 File listing / Drag-n-drop
2495 -->
2496 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
2497 '.implode('',$lines).'
2498 </table>';
2499 }
2500 } else {
2501 // Print this warning if the folder is NOT a web folder:
2502 $out.=$this->barheader($GLOBALS['LANG']->getLL('files'));
2503 $out.=$this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'),'icon_warning2');
2504 }
2505 }
2506 return $out;
2507 }
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520 /******************************************************************
2521 *
2522 * Miscellaneous functions
2523 *
2524 ******************************************************************/
2525
2526
2527 /**
2528 * Verifies that a path is a web-folder:
2529 *
2530 * @param string Absolute filepath
2531 * @return boolean If the input path is found in PATH_site then it returns true.
2532 */
2533 function isWebFolder($folder) {
2534 $folder = rtrim($folder, '/').'/';
2535 return t3lib_div::isFirstPartOfStr($folder,PATH_site) ? TRUE : FALSE;
2536 }
2537
2538 /**
2539 * Checks, if a path is within the mountpoints of the backend user
2540 *
2541 * @param string Absolute filepath
2542 * @return boolean If the input path is found in the backend users filemounts, then return true.
2543 */
2544 function checkFolder($folder) {
2545 return $this->fileProcessor->checkPathAgainstMounts(rtrim($folder, '/') . '/') ? true : false;
2546 }
2547
2548 /**
2549 * Checks, if a path is within a read-only mountpoint of the backend user
2550 *
2551 * @param string Absolute filepath
2552 * @return boolean If the input path is found in the backend users filemounts and if the filemount is of type readonly, then return true.
2553 */
2554 function isReadOnlyFolder($folder) {
2555 return ($GLOBALS['FILEMOUNTS'][$this->fileProcessor->checkPathAgainstMounts(rtrim($folder, '/') . '/')]['type'] == 'readonly');
2556 }
2557
2558 /**
2559 * Prints a 'header' where string is in a tablecell
2560 *
2561 * @param string The string to print in the header. The value is htmlspecialchars()'ed before output.
2562 * @return string The header HTML (wrapped in a table)
2563 */
2564 function barheader($str) {
2565 return '
2566 <!-- Bar header: -->
2567 <h3>' . htmlspecialchars($str) . '</h3>
2568 ';
2569 }
2570
2571 /**
2572 * Displays a message box with the input message
2573 *
2574 * @param string Input message to show (will be htmlspecialchars()'ed inside of this function)
2575 * @param string Icon filename body from gfx/ (default is "icon_note") - meant to allow change to warning type icons...
2576 * @return string HTML for the message (wrapped in a table).
2577 */
2578 function getMsgBox($in_msg,$icon='icon_note') {
2579 global $BACK_PATH;
2580
2581 $msg = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/'.$icon.'.gif','width="18" height="16"').' alt="" />'.htmlspecialchars($in_msg);
2582 $msg = '
2583
2584 <!--
2585 Message box:
2586 -->
2587 <table cellspacing="0" class="bgColor4" id="typo3-msgBox">
2588 <tr>
2589 <td>'.$msg.'</td>
2590 </tr>
2591 </table>
2592 ';
2593 return $msg;
2594 }
2595
2596 /**
2597 * For RTE/link: This prints the 'currentUrl'
2598 *
2599 * @param string URL value. The value is htmlspecialchars()'ed before output.
2600 * @return string HTML content, wrapped in a table.
2601 */
2602 function printCurrentUrl($str) {
2603 if (strlen($str)) {
2604 return '
2605 <!-- Print current URL -->
2606 <table border="0" cellpadding="0" cellspacing="0" id="typo3-curUrl">
2607 <tr>
2608 <td>' . $GLOBALS['LANG']->getLL('currentLink',1) . ': ' .htmlspecialchars(rawurldecode($str)) . '</td>
2609 </tr>
2610 </table>';
2611 } else {
2612 return '';
2613 }
2614 }
2615
2616 /**
2617 * For RTE/link: Parses the incoming URL and determines if it's a page, file, external or mail address.
2618 *
2619 * @param string HREF value tp analyse
2620 * @param string The URL of the current website (frontend)
2621 * @return array Array with URL information stored in assoc. keys: value, act (page, file, spec, mail), pageid, cElement, info
2622 */
2623 function parseCurUrl($href,$siteUrl) {
2624 $href = trim($href);
2625 if ($href) {
2626 $info=array();
2627
2628 // Default is "url":
2629 $info['value']=$href;
2630 $info['act']='url';
2631
2632 $specialParts = explode('#_SPECIAL',$href);
2633 if (count($specialParts)==2) { // Special kind (Something RTE specific: User configurable links through: "userLinks." from ->thisConfig)
2634 $info['value']='#_SPECIAL'.$specialParts[1];
2635 $info['act']='spec';
2636 } elseif (t3lib_div::isFirstPartOfStr($href,$siteUrl)) { // If URL is on the current frontend website:
2637 $rel = substr($href,strlen($siteUrl));
2638 if (file_exists(PATH_site.rawurldecode($rel))) { // URL is a file, which exists:
2639 $info['value']=rawurldecode($rel);
2640 if (@is_dir(PATH_site . $info['value'])) {
2641 $info['act'] = 'folder';
2642 } else {
2643 $info['act'] = 'file';
2644 }
2645 } else { // URL is a page (id parameter)
2646 $uP=parse_url($rel);
2647 if (!trim($uP['path'])) {
2648 $pp = preg_split('/^id=/', $uP['query']);
2649 $pp[1] = preg_replace( '/&id=[^&]*/', '', $pp[1]);
2650 $parameters = explode('&', $pp[1]);
2651 $id = array_shift($parameters);
2652 if ($id) {
2653 // Checking if the id-parameter is an alias.
2654 if (!t3lib_div::testInt($id)) {
2655 list($idPartR) = t3lib_BEfunc::getRecordsByField('pages','alias',$id);
2656 $id=intval($idPartR['uid']);
2657 }
2658
2659 $pageRow = t3lib_BEfunc::getRecordWSOL('pages',$id);
2660 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
2661 $info['value']=$GLOBALS['LANG']->getLL('page',1)." '".htmlspecialchars(t3lib_div::fixed_lgd_cs($pageRow['title'],$titleLen))."' (ID:".$id.($uP['fragment']?', #'.$uP['fragment']:'').')';
2662 $info['pageid']=$id;
2663 $info['cElement']=$uP['fragment'];
2664 $info['act']='page';
2665 $info['query'] = $parameters[0]?'&'.implode('&', $parameters):'';
2666 }
2667 }
2668 }
2669 } else { // Email link:
2670 if (strtolower(substr($href,0,7))=='mailto:') {
2671 $info['value']=trim(substr($href,7));
2672 $info['act']='mail';
2673 }
2674 }
2675 $info['info'] = $info['value'];
2676 } else { // NO value inputted:
2677 $info=array();
2678 $info['info']=$GLOBALS['LANG']->getLL('none');
2679 $info['value']='';
2680 $info['act']='page';
2681 }
2682
2683 // let the hook have a look
2684 foreach($this->hookObjects as $hookObject) {
2685 $info = $hookObject->parseCurrentUrl($href, $siteUrl, $info);
2686 }
2687
2688 return $info;
2689 }
2690
2691 /**
2692 * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
2693 * The files are uploaded to the tce_file.php script in the core which will handle the upload.
2694 *
2695 * @param string Absolute filepath on server to which to upload.
2696 * @return string HTML for an upload form.
2697 */
2698 function uploadForm($path) {
2699 global $BACK_PATH;
2700
2701 if ($this->isReadOnlyFolder($path)) return '';
2702
2703 // Read configuration of upload field count
2704 $userSetting = $GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.uploadFieldsInLinkBrowser');
2705 $count = isset($userSetting) ? $userSetting : 3;
2706 if ($count === '0') {
2707 return '';
2708 }
2709 $count = intval($count) == 0 ? 3 : intval($count);
2710
2711 // Create header, showing upload path:
2712 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
2713 $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.pagetitle',1).':');
2714 $code.='
2715
2716 <!--
2717 Form, for uploading files:
2718 -->
2719 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
2720 <table border="0" cellpadding="0" cellspacing="3" id="typo3-uplFiles">
2721 <tr>
2722 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
2723 </tr>
2724 <tr>
2725 <td>';
2726
2727 // Traverse the number of upload fields (default is 3):
2728 for ($a=1;$a<=$count;$a++) {
2729 $code.='<input type="file" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" />
2730 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($path).'" />
2731 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
2732 }
2733
2734 // Make footer of upload form, including the submit button:
2735 $redirectValue = $this->thisScript.'?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
2736 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
2737 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />';
2738
2739 $code.='
2740 <div id="c-override">
2741 <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> <label for="overwriteExistingFiles">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'</label>
2742 </div>
2743 ';
2744
2745
2746 $code.='</td>
2747 </tr>
2748 </table>
2749 </form>';
2750
2751 return $code;
2752 }
2753
2754 /**
2755 * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
2756 * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
2757 *
2758 * @param string Absolute filepath on server in which to create the new folder.
2759 * @return string HTML for the create folder form.
2760 */
2761 function createFolder($path) {
2762 global $BACK_PATH;
2763
2764 if ($this->isReadOnlyFolder($path)) return '';
2765
2766 // Don't show Folder-create form if it's denied
2767 if ($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.hideCreateFolder')) {
2768 return '';
2769 }
2770 // Create header, showing upload path:
2771 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
2772 $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
2773 $code.='
2774
2775 <!--
2776 Form, for creating new folders:
2777 -->
2778 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform2">
2779 <table border="0" cellpadding="0" cellspacing="3" id="typo3-crFolder">
2780 <tr>
2781 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
2782 </tr>
2783 <tr>
2784 <td>';
2785
2786 // Create the new-folder name field:
2787 $a=1;
2788 $code.='<input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
2789 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($path).'" />';
2790
2791 // Make footer of upload form, including the submit button:
2792 $redirectValue = $this->thisScript.'?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
2793 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
2794 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
2795
2796 $code.='</td>
2797 </tr>
2798 </table>
2799 </form>';
2800
2801 return $code;
2802 }
2803
2804 /**
2805 * Get the HTML data required for a bulk selection of files of the TYPO3 Element Browser.
2806 *
2807 * @param integer $filesCount: Number of files currently displayed
2808 * @return string HTML data required for a bulk selection of files - if $filesCount is 0, nothing is returned
2809 */
2810 function getBulkSelector($filesCount) {
2811 if ($filesCount) {
2812 $labelToggleSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.php:toggleSelection',1);
2813 $labelImportSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.php:importSelection',1);
2814
2815 $out = $this->doc->spacer(15).'<div>' .
2816 '<a href="#" onclick="BrowseLinks.Selector.toggle()">' .
2817 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/clip_select.gif','width="12" height="12"').' title="'.$labelToggleSelection.'" alt="" /> ' .
2818 $labelToggleSelection.'</a>'.$this->doc->spacer(5) .
2819 '<a href="#" onclick="BrowseLinks.Selector.handle()">' .
2820 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/import.gif','width="12" height="12"').' title="'.$labelImportSelection.'" alt="" /> ' .
2821 $labelImportSelection.'</a>' .
2822 '</div>'.$this->doc->spacer(15);
2823 }
2824 return $out;
2825 }
2826
2827 /**
2828 * Determines whether submitted field change functions are valid
2829 * and are coming from the system and not from an external abuse.
2830 *
2831 * @param boolean $allowFlexformSections Whether to handle flexform sections differently
2832 * @return boolean Whether the submitted field change functions are valid
2833 */
2834 protected function areFieldChangeFunctionsValid($handleFlexformSections = FALSE) {
2835 $result = FALSE;
2836
2837 if (isset($this->P['fieldChangeFunc']) && is_array($this->P['fieldChangeFunc']) && isset($this->P['fieldChangeFuncHash'])) {
2838 $matches = array();
2839 $pattern = '#\[el\]\[(([^]-]+-[^]-]+-)(idx\d+-)([^]]+))\]#i';
2840
2841 $fieldChangeFunctions = $this->P['fieldChangeFunc'];
2842
2843 // Special handling of flexform sections:
2844 // Field change functions are modified in JavaScript, thus the hash is always invalid
2845 if ($handleFlexformSections && preg_match($pattern, $this->P['itemName'], $matches)) {
2846 $originalName = $matches[1];
2847 $cleanedName = $matches[2] . $matches[4];
2848
2849 foreach ($fieldChangeFunctions as &$value) {
2850 $value = str_replace($originalName, $cleanedName, $value);
2851 }
2852 }
2853
2854 $result = ($this->P['fieldChangeFuncHash'] === t3lib_div::hmac(serialize($fieldChangeFunctions)));
2855 }
2856
2857 return $result;
2858 }
2859 }
2860
2861
2862 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.browse_links.php']) {
2863 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.browse_links.php']);
2864 }
2865
2866 ?>