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