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