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