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