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