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