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