use doc->tabMenu now and seperates the fileList code what makes it easier to reuse...
[Packages/TYPO3.CMS.git] / typo3 / browse_links.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2004 Kasper Skaarhoj (kasper@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 <kasper@typo3.com>
37 */
38 /**
39 * [CLASS/FUNCTION INDEX of SCRIPT]
40 *
41 *
42 *
43 * 156: class TBE_browser_recordList extends localRecordList
44 * 167: function listURL($altId='',$table=-1,$exclList='')
45 * 186: function ext_addP()
46 * 203: function linkWrapItems($table,$uid,$code,$row)
47 * 236: function linkWrapTable($table,$code)
48 *
49 *
50 * 253: class localPageTree extends t3lib_browseTree
51 * 260: function localPageTree()
52 * 274: function wrapTitle($title,$v,$ext_pArrPages='')
53 * 289: function printTree($treeArr='')
54 * 339: function ext_isLinkable($doktype,$uid)
55 * 353: function PM_ATagWrap($icon,$cmd,$bMark='')
56 * 370: function wrapIcon($icon,$row)
57 *
58 *
59 * 389: class rtePageTree extends localPageTree
60 *
61 *
62 * 406: class TBE_PageTree extends localPageTree
63 * 415: function ext_isLinkable($doktype,$uid)
64 * 427: function wrapTitle($title,$v,$ext_pArrPages)
65 *
66 *
67 * 453: class localFolderTree extends t3lib_folderTree
68 * 463: function wrapTitle($title,$v)
69 * 478: function ext_isLinkable($v)
70 * 495: function PM_ATagWrap($icon,$cmd,$bMark='')
71 * 510: function printTree($treeArr='')
72 *
73 *
74 * 576: class rteFolderTree extends localFolderTree
75 *
76 *
77 * 592: class TBE_FolderTree extends localFolderTree
78 * 601: function ext_isLinkable($v)
79 * 614: function wrapTitle($title,$v)
80 *
81 *
82 * 635: class SC_browse_links
83 * 728: function init()
84 * 983: function main()
85 * 1025: function printContent()
86 *
87 * SECTION: Main functions
88 * 1056: function main_rte($wiz=0)
89 * 1322: function main_db()
90 * 1366: function main_file()
91 *
92 * SECTION: Record listing
93 * 1474: function expandPage()
94 * 1536: function TBE_expandPage($tables)
95 *
96 * SECTION: File listing
97 * 1628: function expandFolder($expandFolder=0,$extensionList='')
98 * 1697: function TBE_expandFolder($expandFolder=0,$extensionList='',$noThumbs=0)
99 * 1815: function TBE_dragNDrop($expandFolder=0,$extensionList='')
100 *
101 * SECTION: Miscellaneous functions
102 * 1942: function isWebFolder($folder)
103 * 1953: function checkFolder($folder)
104 * 1966: function barheader($str)
105 * 1983: function getMsgBox($in_msg,$icon='icon_note')
106 * 2005: function printCurrentUrl($str)
107 * 2025: function parseCurUrl($href,$siteUrl)
108 * 2087: function uploadForm($path)
109 * 2140: function createFolder($path)
110 *
111 * TOTAL FUNCTIONS: 37
112 * (This index is automatically created/updated by the extension "extdeveval")
113 *
114 */
115 $BACK_PATH='';
116 require ('init.php');
117 require ('template.php');
118 require_once (PATH_t3lib.'class.t3lib_browsetree.php');
119 require_once (PATH_t3lib.'class.t3lib_foldertree.php');
120 require_once (PATH_t3lib.'class.t3lib_stdgraphic.php');
121 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
122 $LANG->includeLLFile('EXT:lang/locallang_browse_links.xml');
123
124
125 // Include classes
126 require_once (PATH_t3lib.'class.t3lib_page.php');
127 require_once (PATH_t3lib.'class.t3lib_recordlist.php');
128 require_once ('class.db_list.inc');
129 require_once ('class.db_list_extra.inc');
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149 /**
150 * Local version of the record list.
151 *
152 * @author Kasper Skaarhoj <kasper@typo3.com>
153 * @package TYPO3
154 * @subpackage core
155 */
156 class TBE_browser_recordList extends localRecordList {
157 var $script='browse_links.php';
158
159 /**
160 * Creates the URL for links
161 *
162 * @param mixed If not blank string, this is used instead of $this->id as the id value.
163 * @param string If this is "-1" then $this->table is used, otherwise the value of the input variable.
164 * @param string Commalist of fields NOT to pass as parameters (currently "sortField" and "sortRev")
165 * @return string Query-string for URL
166 */
167 function listURL($altId='',$table=-1,$exclList='') {
168 return $this->script.
169 '?id='.(strcmp($altId,'')?$altId:$this->id).
170 '&table='.rawurlencode($table==-1?$this->table:$table).
171 ($this->thumbs?'&imagemode='.$this->thumbs:'').
172 ($this->searchString?'&search_field='.rawurlencode($this->searchString):'').
173 ($this->searchLevels?'&search_levels='.rawurlencode($this->searchLevels):'').
174 ((!$exclList || !t3lib_div::inList($exclList,'sortField')) && $this->sortField?'&sortField='.rawurlencode($this->sortField):'').
175 ((!$exclList || !t3lib_div::inList($exclList,'sortRev')) && $this->sortRev?'&sortRev='.rawurlencode($this->sortRev):'').
176 // extra:
177 $this->ext_addP()
178 ;
179 }
180
181 /**
182 * Returns additional, local GET parameters to include in the links of the record list.
183 *
184 * @return string
185 */
186 function ext_addP() {
187 $str = '&act='.$GLOBALS['SOBE']->act.
188 '&mode='.$GLOBALS['SOBE']->mode.
189 '&expandPage='.$GLOBALS['SOBE']->expandPage.
190 '&bparams='.rawurlencode($GLOBALS['SOBE']->bparams);
191 return $str;
192 }
193
194 /**
195 * 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...)
196 *
197 * @param string Table name
198 * @param integer UID (not used here)
199 * @param string Title string
200 * @param array Records array (from table name)
201 * @return string
202 */
203 function linkWrapItems($table,$uid,$code,$row) {
204 global $TCA;
205
206 if (!$code) {
207 $code = '<i>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</i>';
208 } else {
209 $code = htmlspecialchars(t3lib_div::fixed_lgd_cs($code,$this->fixedL));
210 }
211
212 $titleCol = $TCA[$table]['ctrl']['label'];
213 $title = $row[$titleCol];
214
215 $ficon = t3lib_iconWorks::getIcon($table,$row);
216 $aOnClick = "return insertElement('".$table."', '".$row['uid']."', 'db', unescape('".rawurlencode($title)."'), '', '', '".$ficon."');";
217 $ATag = '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">';
218 $ATag_alt = substr($ATag,0,-4).',\'\',1);">';
219 $ATag_e = '</a>';
220
221 return $ATag.
222 '<img'.t3lib_iconWorks::skinImg('','gfx/plusbullet2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('addToList',1).'" alt="" />'.
223 $ATag_e.
224 $ATag_alt.
225 $code.
226 $ATag_e;
227 }
228
229 /**
230 * Returns the title (based on $code) of a table ($table) without a link
231 *
232 * @param string Table name
233 * @param string Table label
234 * @return string The linked table label
235 */
236 function linkWrapTable($table,$code) {
237 return $code;
238 }
239 }
240
241
242
243
244
245
246 /**
247 * Class which generates the page tree
248 *
249 * @author Kasper Skaarhoj <kasper@typo3.com>
250 * @package TYPO3
251 * @subpackage core
252 */
253 class localPageTree extends t3lib_browseTree {
254
255 /**
256 * Constructor. Just calling init()
257 *
258 * @return void
259 */
260 function localPageTree() {
261 $this->init();
262
263 $this->clause = ' AND doktype!=255'.$this->clause;
264 }
265
266 /**
267 * Wrapping the title in a link, if applicable.
268 *
269 * @param string Title, (must be ready for output, that means it must be htmlspecialchars()'ed).
270 * @param array The record
271 * @param boolean (Ignore)
272 * @return string Wrapping title string.
273 */
274 function wrapTitle($title,$v,$ext_pArrPages='') {
275 if ($this->ext_isLinkable($v['doktype'],$v['uid'])) {
276 $aOnClick = "return link_typo3Page('".$v['uid']."');";
277 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
278 } else {
279 return '<span style="color: #666666;">'.$title.'</span>';
280 }
281 }
282
283 /**
284 * Create the page navigation tree in HTML
285 *
286 * @param array Tree array
287 * @return string HTML output.
288 */
289 function printTree($treeArr='') {
290 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
291 if (!is_array($treeArr)) $treeArr=$this->tree;
292
293 $out='';
294 $c=0;
295
296 foreach($treeArr as $k => $v) {
297 $c++;
298 $bgColorClass = ($c+1)%2 ? 'bgColor' : 'bgColor-10';
299 if ($GLOBALS['SOBE']->curUrlInfo['act']=='page' && $GLOBALS['SOBE']->curUrlInfo['pageid']==$v['row']['uid'] && $GLOBALS['SOBE']->curUrlInfo['pageid']) {
300 $arrCol='<td><img'.t3lib_iconWorks::skinImg('','gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
301 $bgColorClass='bgColor4';
302 } else {
303 $arrCol='<td></td>';
304 }
305
306 $aOnClick = 'return jumpToUrl(\''.$this->script.'?act='.$GLOBALS['SOBE']->act.'&mode='.$GLOBALS['SOBE']->mode.'&expandPage='.$v['row']['uid'].'\');';
307 $cEbullet = $this->ext_isLinkable($v['row']['doktype'],$v['row']['uid']) ?
308 '<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks::skinImg('','gfx/ol/arrowbullet.gif','width="18" height="16"').' alt="" /></a>' :
309 '';
310 $out.='
311 <tr class="'.$bgColorClass.'">
312 <td nowrap="nowrap">'.
313 $v['HTML'].
314 $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$this->ext_pArrPages).
315 '</td>'.
316 $arrCol.
317 '<td>'.$cEbullet.'</td>
318 </tr>';
319 }
320 $out='
321
322
323 <!--
324 Navigation Page Tree:
325 -->
326 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
327 '.$out.'
328 </table>';
329 return $out;
330 }
331
332 /**
333 * Returns true if a doktype can be linked.
334 *
335 * @param integer Doktype value to test
336 * @param integer uid to test.
337 * @return boolean
338 */
339 function ext_isLinkable($doktype,$uid) {
340 if ($uid && $doktype<199) {
341 return true;
342 }
343 }
344
345 /**
346 * Wrap the plus/minus icon in a link
347 *
348 * @param string HTML string to wrap, probably an image tag.
349 * @param string Command for 'PM' get var
350 * @param boolean If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
351 * @return string Link-wrapped input string
352 */
353 function PM_ATagWrap($icon,$cmd,$bMark='') {
354 if ($bMark) {
355 $anchor = '#'.$bMark;
356 $name=' name="'.$bMark.'"';
357 }
358 $aOnClick = "return jumpToUrl('".$this->script.'?PM='.$cmd."','".$anchor."');";
359
360 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
361 }
362
363 /**
364 * Wrapping the image tag, $icon, for the row, $row
365 *
366 * @param string The image tag for the icon
367 * @param array The row for the current element
368 * @return string The processed icon input value.
369 */
370 function wrapIcon($icon,$row) {
371 return $this->addTagAttributes($icon,' title="id='.$row['uid'].'"');
372 }
373 }
374
375
376
377
378
379
380
381
382 /**
383 * Page tree for the RTE - totally the same, no changes needed. (Just for the sake of beauty - or confusion... :-)
384 *
385 * @author Kasper Skaarhoj <kasper@typo3.com>
386 * @package TYPO3
387 * @subpackage core
388 */
389 class rtePageTree extends localPageTree {
390 }
391
392
393
394
395
396
397
398
399 /**
400 * For TBE record browser
401 *
402 * @author Kasper Skaarhoj <kasper@typo3.com>
403 * @package TYPO3
404 * @subpackage core
405 */
406 class TBE_PageTree extends localPageTree {
407
408 /**
409 * Returns true if a doktype can be linked (which is always the case here).
410 *
411 * @param integer Doktype value to test
412 * @param integer uid to test.
413 * @return boolean
414 */
415 function ext_isLinkable($doktype,$uid) {
416 return true;
417 }
418
419 /**
420 * Wrapping the title in a link, if applicable.
421 *
422 * @param string Title, ready for output.
423 * @param array The record
424 * @param boolean If set, pages clicked will return immediately, otherwise reload page.
425 * @return string Wrapping title string.
426 */
427 function wrapTitle($title,$v,$ext_pArrPages) {
428 if ($ext_pArrPages) {
429 $ficon=t3lib_iconWorks::getIcon('pages',$v);
430 $onClick = "return insertElement('pages', '".$v['uid']."', 'db', unescape('".rawurlencode($v['title'])."'), '', '', '".$ficon."','',1);";
431 } else {
432 $onClick = 'return jumpToUrl(\'browse_links.php?act='.$GLOBALS['SOBE']->act.'&mode='.$GLOBALS['SOBE']->mode.'&expandPage='.$v['uid'].'\');';
433 }
434 return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$title.'</a>';
435 }
436 }
437
438
439
440
441
442
443
444
445 /**
446 * Base extension class which generates the folder tree.
447 * Used directly by the RTE.
448 *
449 * @author Kasper Skaarhoj <kasper@typo3.com>
450 * @package TYPO3
451 * @subpackage core
452 */
453 class localFolderTree extends t3lib_folderTree {
454 var $ext_IconMode=1;
455
456 /**
457 * Wrapping the title in a link, if applicable.
458 *
459 * @param string Title, ready for output.
460 * @param array The "record"
461 * @return string Wrapping title string.
462 */
463 function wrapTitle($title,$v) {
464 if ($this->ext_isLinkable($v)) {
465 $aOnClick = 'return jumpToUrl(\''.$this->script.'?act='.$GLOBALS['SOBE']->act.'&mode='.$GLOBALS['SOBE']->mode.'&expandFolder='.rawurlencode($v['path']).'\');';
466 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
467 } else {
468 return '<span class="typo3-dimmed">'.$title.'</span>';
469 }
470 }
471
472 /**
473 * Returns true if the input "record" contains a folder which can be linked.
474 *
475 * @param array Array with information about the folder element. Contains keys like title, uid, path, _title
476 * @return boolean True is returned if the path is found in the web-part of the the server and is NOT a recycler or temp folder
477 */
478 function ext_isLinkable($v) {
479 $webpath=t3lib_BEfunc::getPathType_web_nonweb($v['path']); // Checking, if the input path is a web-path.
480 if (strstr($v['path'],'_recycler_') || strstr($v['path'],'_temp_') || $webpath!='web') {
481 return 0;
482 }
483 return 1;
484 }
485
486 /**
487 * Wrap the plus/minus icon in a link
488 *
489 * @param string HTML string to wrap, probably an image tag.
490 * @param string Command for 'PM' get var
491 * @param boolean If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
492 * @return string Link-wrapped input string
493 * @access private
494 */
495 function PM_ATagWrap($icon,$cmd,$bMark='') {
496 if ($bMark) {
497 $anchor = '#'.$bMark;
498 $name=' name="'.$bMark.'"';
499 }
500 $aOnClick = 'return jumpToUrl(\''.$this->script.'?PM='.$cmd.'\',\''.$anchor.'\');';
501 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
502 }
503
504 /**
505 * Create the folder navigation tree in HTML
506 *
507 * @param mixed Input tree array. If not array, then $this->tree is used.
508 * @return string HTML output of the tree.
509 */
510 function printTree($treeArr='') {
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']->curUrlInfo['value']) {
520 $cmpPath='';
521 } else if (substr(trim($GLOBALS['SOBE']->curUrlInfo['info']),-1)!='/') {
522 $cmpPath=PATH_site.dirname($GLOBALS['SOBE']->curUrlInfo['info']).'/';
523 } else {
524 $cmpPath=PATH_site.$GLOBALS['SOBE']->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']->curUrlInfo['act']=='file' && $cmpPath==$v['row']['path']) {
534 $arrCol='<td><img'.t3lib_iconWorks::skinImg('','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->script.'?act='.$GLOBALS['SOBE']->act.'&mode='.$GLOBALS['SOBE']->mode.'&expandFolder='.rawurlencode($v['row']['path']).'\');';
541 $cEbullet = $this->ext_isLinkable($v['row']) ? '<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks::skinImg('','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 <kasper@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 <kasper@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(\'browse_links.php?act='.$GLOBALS['SOBE']->act.'&mode='.$GLOBALS['SOBE']->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 * Script class for the Element Browser window.
630 *
631 * @author Kasper Skaarhoj <kasper@typo3.com>
632 * @package TYPO3
633 * @subpackage core
634 */
635 class SC_browse_links {
636
637 // Internal, static:
638 var $siteURL; // Current site URL (Frontend)
639 var $thisConfig; // RTE specific TSconfig
640 var $setTarget; // Target (RTE specific)
641 var $doc; // Backend template object
642
643 // GPvars: (Input variables from outside)
644 /**
645 * The mode determines the main kind of output from the element browser.
646 * There are these options for values: rte, db, file, filedrag, wizard.
647 * "rte" will show the link selector for the Rich Text Editor (see main_rte())
648 * "db" will allow you to browse for pages or records in the page tree (for TCEforms, see main_db())
649 * "file"/"filedrag" will allow you to browse for files or folders in the folder mounts (for TCEforms, main_file())
650 * "wizard" will allow you to browse for links (like "rte") which are passed back to TCEforms (see main_rte(1))
651 *
652 * @see main()
653 */
654 var $mode;
655
656 /**
657 * Link selector action.
658 * page,file,url,mail,spec are allowed values.
659 * These are only important with the link selector function and in that case they switch between the various menu options.
660 */
661 var $act;
662
663 /**
664 * 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")
665 */
666 var $expandPage;
667
668 /**
669 * 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/"
670 */
671 var $expandFolder;
672
673
674
675 /**
676 * TYPO3 Element Browser, wizard mode parameters. There is a heap of parameters there, better debug() them out if you need something... :-)
677 */
678 var $P;
679
680 /**
681 * 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.
682 * Example value: "data[pages][39][bodytext]|||tt_content|" or "data[tt_content][NEW3fba56fde763d][image]|||gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai|"
683 */
684 var $bparams;
685
686 /**
687 * Used with the Rich Text Editor.
688 * Example value: "tt_content:NEW3fba58c969f5c:bodytext:23:text:23:"
689 */
690 var $RTEtsConfigParams;
691
692
693
694
695 /**
696 * Plus/Minus icon value. Used by the tree class to open/close notes on the trees.
697 */
698 var $PM;
699
700 /**
701 * Pointer, used when browsing a long list of records etc.
702 */
703 var $pointer;
704
705
706
707
708 /**
709 * Used with the link selector: Contains the GET input information about the CURRENT link in the RTE/TCEform field. This consists of "href" and "target" keys. This information is passed around in links.
710 */
711 var $curUrlArray;
712
713 /**
714 * 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.
715 */
716 var $curUrlInfo;
717
718
719
720
721
722 /**
723 * Constructor:
724 * Initializes a lot of variables, setting JavaScript functions in header etc.
725 *
726 * @return void
727 */
728 function init() {
729 global $BE_USER,$BACK_PATH;
730
731 // Main GPvars:
732 $this->pointer = t3lib_div::_GP('pointer');
733 $this->bparams = t3lib_div::_GP('bparams');
734 $this->P = t3lib_div::_GP('P');
735 $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
736 $this->expandPage = t3lib_div::_GP('expandPage');
737 $this->expandFolder = t3lib_div::_GP('expandFolder');
738 $this->PM = t3lib_div::_GP('PM');
739
740 // Find "mode"
741 $this->mode=t3lib_div::_GP('mode');
742 if (!$this->mode) {
743 $this->mode='rte';
744 }
745
746 // Site URL
747 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL'); // Current site url
748
749 // CurrentUrl - the current link url must be passed around if it exists
750 if ($this->mode=='wizard') {
751 $currentLinkParts = t3lib_div::trimExplode(' ',$this->P['currentValue']);
752 $this->curUrlArray = array(
753 'target' => $currentLinkParts[1]
754 );
755 $this->curUrlInfo=$this->parseCurUrl($this->siteURL.'?id='.$currentLinkParts[0],$this->siteURL);
756 } else {
757 $this->curUrlArray = t3lib_div::_GP('curUrl');
758 if ($this->curUrlArray['all']) {
759 $this->curUrlArray=t3lib_div::get_tag_attributes($this->curUrlArray['all']);
760 }
761 $this->curUrlInfo=$this->parseCurUrl($this->curUrlArray['href'],$this->siteURL);
762 }
763
764 // Determine nature of current url:
765 $this->act=t3lib_div::_GP('act');
766 if (!$this->act) {
767 $this->act=$this->curUrlInfo['act'];
768 }
769
770 // Rich Text Editor specific configuration:
771 $addPassOnParams='';
772 if ((string)$this->mode=='rte') {
773 $RTEtsConfigParts = explode(':',$this->RTEtsConfigParams);
774 $addPassOnParams.='&RTEtsConfigParams='.rawurlencode($this->RTEtsConfigParams);
775 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
776 $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
777 }
778
779 // Initializing the target value (RTE)
780 $this->setTarget = $this->curUrlArray['target'];
781 if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target'])) {
782 $this->setTarget=$this->thisConfig['defaultLinkTarget'];
783 }
784
785
786
787 // Creating backend template object:
788 $this->doc = t3lib_div::makeInstance('template');
789 $this->doc->docType= 'xhtml_trans';
790 $this->doc->backPath = $BACK_PATH;
791
792 // BEGIN accumulation of header JavaScript:
793 $JScode = '';
794 $JScode.= '
795 // This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
796 var add_href="'.($this->curUrlArray['href']?'&curUrl[href]='.rawurlencode($this->curUrlArray['href']):'').'";
797 var add_target="'.($this->setTarget?'&curUrl[target]='.rawurlencode($this->setTarget):'').'";
798 var add_params="'.($this->bparams?'&bparams='.rawurlencode($this->bparams):'').'";
799
800 var cur_href="'.($this->curUrlArray['href']?$this->curUrlArray['href']:'').'";
801 var cur_target="'.($this->setTarget?$this->setTarget:'').'";
802
803 function setTarget(target) { //
804 cur_target=target;
805 add_target="&curUrl[target]="+escape(target);
806 }
807 function setValue(value) { //
808 cur_href=value;
809 add_href="&curUrl[href]="+value;
810 }
811 ';
812
813
814 if ($this->mode=='wizard') { // Functions used, if the link selector is in wizard mode (= TCEforms fields)
815 unset($this->P['fieldChangeFunc']['alert']);
816 reset($this->P['fieldChangeFunc']);
817 $update='';
818 while(list($k,$v)=each($this->P['fieldChangeFunc'])) {
819 $update.= '
820 window.opener.'.$v;
821 }
822
823 $P2=array();
824 $P2['itemName']=$this->P['itemName'];
825 $P2['formName']=$this->P['formName'];
826 $P2['fieldChangeFunc']=$this->P['fieldChangeFunc'];
827 $addPassOnParams.=t3lib_div::implodeArrayForUrl('P',$P2);
828
829 $JScode.='
830 function link_typo3Page(id,anchor) { //
831 updateValueInMainForm(id+(anchor?anchor:"")+" "+cur_target);
832 close();
833 return false;
834 }
835 function link_folder(folder) { //
836 updateValueInMainForm(folder+" "+cur_target);
837 close();
838 return false;
839 }
840 function link_current() { //
841 if (cur_href!="http://" && cur_href!="mailto:") {
842 var setValue = cur_href+" "+cur_target;
843 if (setValue.substr(0,7)=="http://") setValue = setValue.substr(7);
844 if (setValue.substr(0,7)=="mailto:") setValue = setValue.substr(7);
845 updateValueInMainForm(setValue);
846 close();
847 }
848 return false;
849 }
850 function checkReference() { //
851 if (window.opener && window.opener.document && window.opener.document.'.$this->P['formName'].' && window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"] ) {
852 return window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"];
853 } else {
854 close();
855 }
856 }
857 function updateValueInMainForm(input) { //
858 var field = checkReference();
859 if (field) {
860 field.value = input;
861 '.$update.'
862 }
863 }
864 ';
865 } else { // Functions used, if the link selector is in RTE mode:
866 $JScode.='
867 function link_typo3Page(id,anchor) { //
868 var theLink = \''.$this->siteURL.'?id=\'+id+(anchor?anchor:"");
869 self.parent.parent.renderPopup_addLink(theLink,cur_target);
870 return false;
871 }
872 function link_folder(folder) { //
873 var theLink = \''.$this->siteURL.'\'+folder;
874 self.parent.parent.renderPopup_addLink(theLink,cur_target);
875 return false;
876 }
877 function link_spec(theLink) { //
878 self.parent.parent.renderPopup_addLink(theLink,cur_target);
879 return false;
880 }
881 function link_current() { //
882 if (cur_href!="http://" && cur_href!="mailto:") {
883 self.parent.parent.renderPopup_addLink(cur_href,cur_target);
884 }
885 return false;
886 }
887 ';
888 }
889
890 // General "jumpToUrl" function:
891 $JScode.='
892 function jumpToUrl(URL,anchor) { //
893 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
894 var add_mode = URL.indexOf("mode=")==-1 ? "&mode='.$this->mode.'" : "";
895 var theLocation = URL+add_act+add_mode+add_href+add_target+add_params'.($addPassOnParams?'+"'.$addPassOnParams.'"':'').'+(anchor?anchor:"");
896 document.location = theLocation;
897 return false;
898 }
899 ';
900
901
902 // This is JavaScript especially for the TBE Element Browser!
903 $pArr = explode('|',$this->bparams);
904 $formFieldName = 'data['.$pArr[0].']['.$pArr[1].']['.$pArr[2].']';
905 $JScode.='
906 var elRef="";
907 var targetDoc="";
908
909 function launchView(url) { //
910 var thePreviewWindow="";
911 thePreviewWindow = window.open("show_item.php?table="+url,"ShowItem","height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
912 if (thePreviewWindow && thePreviewWindow.focus) {
913 thePreviewWindow.focus();
914 }
915 }
916 function setReferences() { //
917 if (parent.window.opener
918 && parent.window.opener.content
919 && parent.window.opener.content.document.editform
920 && parent.window.opener.content.document.editform["'.$formFieldName.'"]
921 ) {
922 targetDoc = parent.window.opener.content.document;
923 elRef = targetDoc.editform["'.$formFieldName.'"];
924 return true;
925 } else {
926 return false;
927 }
928 }
929 function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close) { //
930 if (1=='.($pArr[0]&&!$pArr[1]&&!$pArr[2] ? 1 : 0).') {
931 addElement(filename,table+"_"+uid,fp,close);
932 } else {
933 if (setReferences()) {
934 parent.window.opener.group_change("add","'.$pArr[0].'","'.$pArr[1].'","'.$pArr[2].'",elRef,targetDoc);
935 } else {
936 alert("Error - reference to main window is not set properly!");
937 }
938 if (close) {
939 parent.window.opener.focus();
940 parent.close();
941 }
942 }
943 return false;
944 }
945 function addElement(elName,elValue,altElValue,close) { //
946 if (parent.window.opener && parent.window.opener.setFormValueFromBrowseWin) {
947 parent.window.opener.setFormValueFromBrowseWin("'.$pArr[0].'",altElValue?altElValue:elValue,elName);
948 if (close) {
949 parent.window.opener.focus();
950 parent.close();
951 }
952 } else {
953 alert("Error - reference to main window is not set properly!");
954 parent.close();
955 }
956 }
957 ';
958
959 // Finally, add the accumulated JavaScript to the template object:
960 $this->doc->JScode = $this->doc->wrapScriptTags($JScode);
961
962 // Debugging:
963 if (FALSE) debug(array(
964 'pointer' => $this->pointer,
965 'act' => $this->act,
966 'mode' => $this->mode,
967 'curUrlInfo' => $this->curUrlInfo,
968 'curUrlArray' => $this->curUrlArray,
969 'P' => $this->P,
970 'bparams' => $this->bparams,
971 'RTEtsConfigParams' => $this->RTEtsConfigParams,
972 'expandPage' => $this->expandPage,
973 'expandFolder' => $this->expandFolder,
974 'PM' => $this->PM,
975 ),'Internal variables of Script Class:');
976 }
977
978 /**
979 * Main function, detecting the current mode of the element browser and branching out to internal methods.
980 *
981 * @return void
982 */
983 function main() {
984 global $BE_USER;
985
986 $modData = $BE_USER->getModuleData('browse_links.php','ses');
987
988 // Output the correct content according to $this->mode
989 switch((string)$this->mode) {
990 case 'rte':
991 $this->content=$this->main_rte();
992 break;
993 case 'db':
994 if (isset($this->expandPage)) {
995 $modData['expandPage']=$this->expandPage;
996 $BE_USER->pushModuleData('browse_links.php',$modData);
997 } else {
998 $this->expandPage=$modData['expandPage'];
999 }
1000
1001 $this->content=$this->main_db();
1002 break;
1003 case 'file':
1004 case 'filedrag':
1005 if (isset($this->expandFolder)) {
1006 $modData['expandFolder']=$this->expandFolder;
1007 $BE_USER->pushModuleData('browse_links.php',$modData);
1008 } else {
1009 $this->expandFolder=$modData['expandFolder'];
1010 }
1011
1012 $this->content=$this->main_file();
1013 break;
1014 case 'wizard':
1015 $this->content=$this->main_rte(1);
1016 break;
1017 }
1018 }
1019
1020 /**
1021 * Print module content
1022 *
1023 * @return void
1024 */
1025 function printContent() {
1026 echo $this->content;
1027 }
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042 /******************************************************************
1043 *
1044 * Main functions
1045 *
1046 ******************************************************************/
1047
1048 /**
1049 * Rich Text Editor (RTE) link selector (MAIN function)
1050 * Generates the link selector for the Rich Text Editor.
1051 * Can also be used to select links for the TCEforms (see $wiz)
1052 *
1053 * @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
1054 * @return string Modified content variable.
1055 */
1056 function main_rte($wiz=0) {
1057 global $LANG;
1058
1059 // Starting content:
1060 $content=$this->doc->startPage('RTE link');
1061
1062 // Initializing the action value, possibly removing blinded values etc:
1063 $allowedItems = array_diff(explode(',','page,file,url,mail,spec'),t3lib_div::trimExplode(',',$this->thisConfig['blindLinkOptions'],1));
1064 reset($allowedItems);
1065 if (!in_array($this->act,$allowedItems)) $this->act = current($allowedItems);
1066
1067 // Making menu in top:
1068 $menuDef = array();
1069 if (!$wiz) {
1070 $menuDef['removeLink']['isActive'] = $this->act=='removeLink';
1071 $menuDef['removeLink']['label'] = $LANG->getLL('removeLink',1);
1072 $menuDef['removeLink']['url'] = '#';
1073 $menuDef['removeLink']['addParams'] = 'onclick="self.parent.parent.renderPopup_unLink();return false;"';
1074 }
1075 if (in_array('page',$allowedItems)) {
1076 $menuDef['page']['isActive'] = $this->act=='page';
1077 $menuDef['page']['label'] = $LANG->getLL('page',1);
1078 $menuDef['page']['url'] = '#';
1079 $menuDef['page']['addParams'] = 'onclick="jumpToUrl(\'?act=page\');return false;"';
1080 }
1081 if (in_array('file',$allowedItems)){
1082 $menuDef['file']['isActive'] = $this->act=='file';
1083 $menuDef['file']['label'] = $LANG->getLL('file',1);
1084 $menuDef['file']['url'] = '#';
1085 $menuDef['file']['addParams'] = 'onclick="jumpToUrl(\'?act=file\');return false;"';
1086 }
1087 if (in_array('url',$allowedItems)) {
1088 $menuDef['url']['isActive'] = $this->act=='url';
1089 $menuDef['url']['label'] = $LANG->getLL('extUrl',1);
1090 $menuDef['url']['url'] = '#';
1091 $menuDef['url']['addParams'] = 'onclick="jumpToUrl(\'?act=url\');return false;"';
1092 }
1093 if (in_array('mail',$allowedItems)) {
1094 $menuDef['mail']['isActive'] = $this->act=='mail';
1095 $menuDef['mail']['label'] = $LANG->getLL('email',1);
1096 $menuDef['mail']['url'] = '#';
1097 $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(\'?act=mail\');return false;"';
1098 }
1099 if (is_array($this->thisConfig['userLinks.']) && in_array('spec',$allowedItems)) {
1100 $menuDef['spec']['isActive'] = $this->act=='spec';
1101 $menuDef['spec']['label'] = $LANG->getLL('special',1);
1102 $menuDef['spec']['url'] = '#';
1103 $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(\'?act=spec\');return false;"';
1104 }
1105 $content .= $this->doc->getTabMenuRaw($menuDef);
1106
1107 // Adding the menu and header to the top of page:
1108 $content.=$this->printCurrentUrl($this->curUrlInfo['info']).'<br />';
1109
1110
1111 // Depending on the current action we will create the actual module content for selecting a link:
1112 switch($this->act) {
1113 case 'mail':
1114 $extUrl='
1115
1116 <!--
1117 Enter mail address:
1118 -->
1119 <form action="" name="lurlform" id="lurlform">
1120 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
1121 <tr>
1122 <td>'.$GLOBALS['LANG']->getLL('emailAddress',1).':</td>
1123 <td><input type="text" name="lemail"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='mail'?$this->curUrlInfo['info']:'').'" /> '.
1124 '<input type="submit" value="'.$GLOBALS['LANG']->getLL('setLink',1).'" onclick="setTarget(\'\');setValue(\'mailto:\'+document.lurlform.lemail.value); return link_current();" /></td>
1125 </tr>
1126 </table>
1127 </form>';
1128 $content.=$extUrl;
1129 break;
1130 case 'url':
1131 $extUrl='
1132
1133 <!--
1134 Enter External URL:
1135 -->
1136 <form action="" name="lurlform" id="lurlform">
1137 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
1138 <tr>
1139 <td>URL:</td>
1140 <td><input type="text" name="lurl"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='url'?$this->curUrlInfo['info']:'http://').'" /> '.
1141 '<input type="submit" value="'.$GLOBALS['LANG']->getLL('setLink',1).'" onclick="setValue(document.lurlform.lurl.value); return link_current();" /></td>
1142 </tr>
1143 </table>
1144 </form>';
1145 $content.=$extUrl;
1146 break;
1147 case 'file':
1148 $foldertree = t3lib_div::makeInstance('rteFolderTree');
1149 $tree=$foldertree->getBrowsableTree();
1150
1151 if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act']!='file') {
1152 $cmpPath='';
1153 } elseif (substr(trim($this->curUrlInfo['info']),-1)!='/') {
1154 $cmpPath=PATH_site.dirname($this->curUrlInfo['info']).'/';
1155 if (!isset($this->expandFolder)) $this->expandFolder = $cmpPath;
1156 } else {
1157 $cmpPath=PATH_site.$this->curUrlInfo['info'];
1158 }
1159
1160 list(,,$specUid) = explode('_',$this->PM);
1161 $files = $this->expandFolder($foldertree->specUIDmap[$specUid]);
1162
1163 $content.= '
1164
1165 <!--
1166 Wrapper table for folder tree / file list:
1167 -->
1168 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
1169 <tr>
1170 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1171 <td class="c-wCell" valign="top">'.$files.'</td>
1172 </tr>
1173 </table>
1174 ';
1175 break;
1176 case 'spec':
1177 if (is_array($this->thisConfig['userLinks.'])) {
1178 $subcats=array();
1179 $v=$this->thisConfig['userLinks.'];
1180 reset($v);
1181 while(list($k2)=each($v)) {
1182 $k2i = intval($k2);
1183 if (substr($k2,-1)=='.' && is_array($v[$k2i.'.'])) {
1184
1185 // Title:
1186 $title = trim($v[$k2i]);
1187 if (!$title) {
1188 $title=$v[$k2i.'.']['url'];
1189 } else {
1190 $title=$LANG->sL($title);
1191 }
1192 // Description:
1193 $description=$v[$k2i.'.']['description'] ? $LANG->sL($v[$k2i.'.']['description'],1).'<br />' : '';
1194
1195 // URL + onclick event:
1196 $onClickEvent='';
1197 if (isset($v[$k2i.'.']['target'])) $onClickEvent.="setTarget('".$v[$k2i.'.']['target']."');";
1198 $v[$k2i.'.']['url'] = str_replace('###_URL###',$this->siteURL,$v[$k2i.'.']['url']);
1199 if (substr($v[$k2i.'.']['url'],0,7)=="http://" || substr($v[$k2i.'.']['url'],0,7)=='mailto:') {
1200 $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i.'.']['url'])."');link_current();";
1201 } else {
1202 $onClickEvent.="link_spec(unescape('".$this->siteURL.rawurlencode($v[$k2i.'.']['url'])."'));";
1203 }
1204
1205 // Link:
1206 $A=array('<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">','</a>');
1207
1208 // Adding link to menu of user defined links:
1209 $subcats[$k2i]='
1210 <tr>
1211 <td class="bgColor4">'.$A[0].'<strong>'.htmlspecialchars($title).($this->curUrlInfo['info']==$v[$k2i.'.']['url']?'<img'.t3lib_iconWorks::skinImg('','gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" />':'').'</strong><br />'.$description.$A[1].'</td>
1212 </tr>';
1213 }
1214 }
1215
1216 // Sort by keys:
1217 ksort($subcats);
1218
1219 // Add menu to content:
1220 $content.= '
1221
1222 <!--
1223 Special userdefined menu:
1224 -->
1225 <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
1226 <tr>
1227 <td class="bgColor5" class="c-wCell" valign="top"><strong>'.$LANG->getLL('special',1).'</strong></td>
1228 </tr>
1229 '.implode('',$subcats).'
1230 </table>
1231 ';
1232 }
1233 break;
1234 case 'page':
1235 default:
1236 $pagetree = t3lib_div::makeInstance('rtePageTree');
1237 $tree=$pagetree->getBrowsableTree();
1238 $cElements = $this->expandPage();
1239 $content.= '
1240
1241 <!--
1242 Wrapper table for page tree / record list:
1243 -->
1244 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
1245 <tr>
1246 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('pageTree').':').$tree.'</td>
1247 <td class="c-wCell" valign="top">'.$cElements.'</td>
1248 </tr>
1249 </table>
1250 ';
1251 break;
1252 }
1253
1254 // Target:
1255 if ($this->act!='mail') {
1256 $ltarget='
1257
1258
1259 <!--
1260 Selecting target for link:
1261 -->
1262 <form action="" name="ltargetform" id="ltargetform">
1263 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
1264 <tr>
1265 <td>'.$GLOBALS['LANG']->getLL('target',1).':</td>
1266 <td><input type="text" name="ltarget" onchange="setTarget(this.value);" value="'.htmlspecialchars($this->setTarget).'"'.$this->doc->formWidth(10).' /></td>
1267 <td>
1268 <select name="ltarget_type" onchange="setTarget(this.options[this.selectedIndex].value);document.ltargetform.ltarget.value=this.options[this.selectedIndex].value;this.selectedIndex=0;">
1269 <option></option>
1270 <option value="_top">'.$GLOBALS['LANG']->getLL('top',1).'</option>
1271 <option value="_blank">'.$GLOBALS['LANG']->getLL('newWindow',1).'</option>
1272 </select>
1273 </td>
1274 <td>';
1275
1276 if (($this->curUrlInfo['act']=="page" || $this->curUrlInfo['act']=='file') && $this->curUrlArray['href']) {
1277 $ltarget.='
1278 <input type="submit" value="'.$GLOBALS['LANG']->getLL('update',1).'" onclick="return link_current();" />';
1279 }
1280
1281 $selectJS = '
1282 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) {
1283 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;
1284 setTarget(document.ltargetform.ltarget.value);
1285 document.ltargetform.popup_width.selectedIndex=0;
1286 document.ltargetform.popup_height.selectedIndex=0;
1287 }
1288 ';
1289
1290 $ltarget.=' </td>
1291 </tr>
1292 <tr>
1293 <td>'.$GLOBALS['LANG']->getLL('target_popUpWindow',1).':</td>
1294 <td colspan="3">
1295 <select name="popup_width" onchange="'.htmlspecialchars($selectJS).'">
1296 <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_width',1).'</option>
1297 <option value="300">300</option>
1298 <option value="400">400</option>
1299 <option value="500">500</option>
1300 <option value="600">600</option>
1301 <option value="700">700</option>
1302 <option value="800">800</option>
1303 </select>
1304 x
1305 <select name="popup_height" onchange="'.htmlspecialchars($selectJS).'">
1306 <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_height',1).'</option>
1307 <option value="200">200</option>
1308 <option value="300">300</option>
1309 <option value="400">400</option>
1310 <option value="500">500</option>
1311 <option value="600">600</option>
1312 </select>
1313 </td>
1314 </tr>
1315 </table>
1316 </form>';
1317
1318 // Add "target selector" box to content:
1319 $content.=$ltarget;
1320
1321 // Add some space
1322 $content.='<br /><br />';
1323 }
1324
1325 // End page, return content:
1326 $content.= $this->doc->endPage();
1327 return $content;
1328 }
1329
1330 /**
1331 * TYPO3 Element Browser: Showing a page tree and allows you to browse for records
1332 *
1333 * @return string HTML content for the module
1334 */
1335 function main_db() {
1336
1337 // Starting content:
1338 $content=$this->doc->startPage('TBE file selector');
1339
1340 // Init variable:
1341 $pArr = explode('|',$this->bparams);
1342
1343 // Making the browsable pagetree:
1344 $pagetree = t3lib_div::makeInstance('TBE_PageTree');
1345 $pagetree->script='browse_links.php';
1346 $pagetree->ext_pArrPages = !strcmp($pArr[3],'pages')?1:0;
1347 $tree=$pagetree->getBrowsableTree();
1348
1349 // Making the list of elements, if applicable:
1350 $cElements = $this->TBE_expandPage($pArr[3]);
1351
1352 // Putting the things together, side by side:
1353 $content.= '
1354
1355 <!--
1356 Wrapper table for page tree / record list:
1357 -->
1358 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBrecords">
1359 <tr>
1360 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('pageTree').':').$tree.'</td>
1361 <td class="c-wCell" valign="top">'.$cElements.'</td>
1362 </tr>
1363 </table>
1364 ';
1365
1366 // Add some space
1367 $content.='<br /><br />';
1368
1369 // End page, return content:
1370 $content.= $this->doc->endPage();
1371 return $content;
1372 }
1373
1374 /**
1375 * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for files.
1376 *
1377 * @return string HTML content for the module
1378 */
1379 function main_file() {
1380 global $BE_USER;
1381
1382 // Starting content:
1383 $content.=$this->doc->startPage('TBE file selector');
1384
1385 // Init variable:
1386 $pArr = explode('|',$this->bparams);
1387
1388 // Create upload/create folder forms, if a path is given:
1389 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
1390 $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
1391 $path=$this->expandFolder;
1392 if (!$path || !@is_dir($path)) {
1393 $path = $fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
1394 }
1395 if ($path!='/' && @is_dir($path)) {
1396 $uploadForm=$this->uploadForm($path);
1397 $createFolder=$this->createFolder($path);
1398 } else {
1399 $createFolder='';
1400 $uploadForm='';
1401 }
1402 if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) $content.=$uploadForm;
1403
1404 // Getting flag for showing/not showing thumbnails:
1405 $noThumbs = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
1406
1407 if (!$noThumbs) {
1408 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
1409 $_MOD_MENU = array('displayThumbs' => '');
1410 $_MCONF['name']='file_list';
1411 $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']);
1412 $addParams = '&act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
1413 $thumbNailCheck = t3lib_BEfunc::getFuncCheck('','SET[displayThumbs]',$_MOD_SETTINGS['displayThumbs'],'browse_links.php',$addParams).' '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.php:displayThumbs',1);
1414 } else {
1415 $thumbNailCheck='';
1416 }
1417 $noThumbs = $noThumbs?$noThumbs:!$_MOD_SETTINGS['displayThumbs'];
1418
1419 // Create folder tree:
1420 $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
1421 $foldertree->script='browse_links.php';
1422 $foldertree->ext_noTempRecyclerDirs = ($this->mode == 'filedrag');
1423 $tree=$foldertree->getBrowsableTree();
1424
1425 list(,,$specUid) = explode('_',$this->PM);
1426
1427 if ($this->mode=='filedrag') {
1428 $files = $this->TBE_dragNDrop($foldertree->specUIDmap[$specUid],$pArr[3]);
1429 } else {
1430 $files = $this->TBE_expandFolder($foldertree->specUIDmap[$specUid],$pArr[3],$noThumbs);
1431 }
1432
1433 // Putting the parts together, side by side:
1434 $content.= '
1435
1436 <!--
1437 Wrapper table for folder tree / file list:
1438 -->
1439 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
1440 <tr>
1441 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1442 <td class="c-wCell" valign="top">'.$files.'</td>
1443 </tr>
1444 </table>
1445 ';
1446 $content.=$thumbNailCheck;
1447
1448 // Adding create folder + upload forms if applicable:
1449 if (!$BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) $content.=$uploadForm;
1450 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) $content.=$createFolder;
1451
1452 // Add some space
1453 $content.='<br /><br />';
1454
1455 // Ending page, returning content:
1456 $content.= $this->doc->endPage();
1457 return $content;
1458 }
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478 /******************************************************************
1479 *
1480 * Record listing
1481 *
1482 ******************************************************************/
1483 /**
1484 * For RTE: This displays all content elements on a page and lets you create a link to the element.
1485 *
1486 * @return string HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...)
1487 */
1488 function expandPage() {
1489 global $BE_USER;
1490
1491 $out='';
1492 $expPageId = $this->expandPage; // Set page id (if any) to expand
1493
1494 // If there is an anchor value (content element reference) in the element reference, then force an ID to expand:
1495 if (!$this->expandPage && $this->curUrlInfo['cElement']) {
1496 $expPageId = $this->curUrlInfo['pageid']; // Set to the current link page id.
1497 }
1498
1499 // Draw the record list IF there is a page id to expand:
1500 if ($expPageId && t3lib_div::testInt($expPageId) && $BE_USER->isInWebMount($expPageId)) {
1501
1502 // Set header:
1503 $out.=$this->barheader($GLOBALS['LANG']->getLL('contentElements').':');
1504
1505 // Create header for listing, showing the page title/icon:
1506 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1507 $mainPageRec = t3lib_BEfunc::getRecord('pages',$expPageId);
1508 $picon=t3lib_iconWorks::getIconImage('pages',$mainPageRec,'','');
1509 $picon.= htmlspecialchars(t3lib_div::fixed_lgd_cs($mainPageRec['title'],$titleLen));
1510 $out.=$picon.'<br />';
1511
1512 // Look up tt_content elements from the expanded page:
1513 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1514 'uid,header,hidden,starttime,endtime,fe_group,CType,colpos,bodytext',
1515 'tt_content',
1516 'pid='.intval($expPageId).t3lib_BEfunc::deleteClause('tt_content'),
1517 '',
1518 'colpos,sorting'
1519 );
1520 $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1521
1522 // Traverse list of records:
1523 $c=0;
1524 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1525 $c++;
1526 $icon=t3lib_iconWorks::getIconImage('tt_content',$row,'','');
1527 if ($this->curUrlInfo['act']=='page' && $this->curUrlInfo['cElement']==$row['uid']) {
1528 $arrCol='<img'.t3lib_iconWorks::skinImg('','gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
1529 } else {
1530 $arrCol='';
1531 }
1532 // Putting list element HTML together:
1533 $out.='<img'.t3lib_iconWorks::skinImg('','gfx/ol/join'.($c==$cc?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
1534 $arrCol.
1535 '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.$row['uid'].'\');">'.
1536 $icon.
1537 htmlspecialchars(t3lib_div::fixed_lgd_cs($row['header'],$titleLen)).
1538 '</a><br />';
1539
1540 // Finding internal anchor points:
1541 if (t3lib_div::inList('text,textpic', $row['CType'])) {
1542 $split = preg_split('/(<a[^>]+name=[\'"]?([^"\'>[:space:]]+)[\'"]?[^>]*>)/i', $row['bodytext'], -1, PREG_SPLIT_DELIM_CAPTURE);
1543
1544 foreach($split as $skey => $sval) {
1545 if (($skey%3)==2) {
1546 // Putting list element HTML together:
1547 $sval = substr($sval,0,100);
1548 $out.='<img'.t3lib_iconWorks::skinImg('','gfx/ol/line.gif','width="18" height="16"').' alt="" />'.
1549 '<img'.t3lib_iconWorks::skinImg('','gfx/ol/join'.($skey+3>count($split)?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
1550 '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.rawurlencode($sval).'\');">'.
1551 htmlspecialchars(' <A> '.$sval).
1552 '</a><br />';
1553 }
1554 }
1555 }
1556 }
1557 }
1558 return $out;
1559 }
1560
1561 /**
1562 * For TYPO3 Element Browser: This lists all content elements from the given list of tables
1563 *
1564 * @param string Commalist of tables. Set to "*" if you want all tables.
1565 * @return string HTML output.
1566 */
1567 function TBE_expandPage($tables) {
1568 global $TCA,$BE_USER;
1569
1570 $out='';
1571 if ($this->expandPage>=0 && t3lib_div::testInt($this->expandPage) && $BE_USER->isInWebMount($this->expandPage)) {
1572
1573 // Set array with table names to list:
1574 if (!strcmp(trim($tables),'*')) {
1575 $tablesArr = array_keys($TCA);
1576 } else {
1577 $tablesArr = t3lib_div::trimExplode(',',$tables,1);
1578 }
1579 reset($tablesArr);
1580
1581 // Headline for selecting records:
1582 $out.=$this->barheader($GLOBALS['LANG']->getLL('selectRecords').':');
1583
1584 // Create the header, showing the current page for which the listing is. Includes link to the page itself, if pages are amount allowed tables.
1585 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1586 $mainPageRec = t3lib_BEfunc::getRecord('pages',$this->expandPage);
1587 $ATag='';
1588 $ATag_e='';
1589 $ATag2='';
1590 if (in_array('pages',$tablesArr)) {
1591 $ficon=t3lib_iconWorks::getIcon('pages',$mainPageRec);
1592 $ATag="<a href=\"#\" onclick=\"return insertElement('pages', '".$mainPageRec['uid']."', 'db', unescape('".rawurlencode($mainPageRec['title'])."'), '', '', '".$ficon."','',1);\">";
1593 $ATag2="<a href=\"#\" onclick=\"return insertElement('pages', '".$mainPageRec['uid']."', 'db', unescape('".rawurlencode($mainPageRec['title'])."'), '', '', '".$ficon."','',0);\">";
1594 $ATag_alt=substr($ATag,0,-4).",'',1);\">";
1595 $ATag_e='</a>';
1596 }
1597 $picon=t3lib_iconWorks::getIconImage('pages',$mainPageRec,'','');
1598 $pBicon=$ATag2?'<img'.t3lib_iconWorks::skinImg('','gfx/plusbullet2.gif','width="18" height="16"').' alt="" />':'';
1599 $pText=htmlspecialchars(t3lib_div::fixed_lgd_cs($mainPageRec['title'],$titleLen));
1600 $out.=$picon.$ATag2.$pBicon.$ATag_e.$ATag.$pText.$ATag_e.'<br />';
1601
1602 // Initialize the record listing:
1603 $id = $this->expandPage;
1604 $pointer = t3lib_div::intInRange($this->pointer,0,100000);
1605 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
1606 $pageinfo = t3lib_BEfunc::readPageAccess($id,$perms_clause);
1607 $table='';
1608
1609 // Generate the record list:
1610 $dblist = t3lib_div::makeInstance('TBE_browser_recordList');
1611 $dblist->script='browse_links.php';
1612 $dblist->backPath = $GLOBALS['BACK_PATH'];
1613 $dblist->thumbs = 0;
1614 $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageinfo);
1615 $dblist->noControlPanels=1;
1616 $dblist->tableList=implode(',',$tablesArr);
1617
1618 $dblist->start($id,t3lib_div::_GP('table'),$pointer,
1619 t3lib_div::_GP('search_field'),
1620 t3lib_div::_GP('search_levels'),
1621 t3lib_div::_GP('showLimit')
1622 );
1623 $dblist->setDispFields();
1624 $dblist->generateList($id,$table);
1625 $dblist->writeBottom();
1626
1627 // Add the HTML for the record list to output variable:
1628 $out.=$dblist->HTMLcode;
1629 $out.=$dblist->getSearchBox();
1630 }
1631
1632 // Return accumulated content:
1633 return $out;
1634 }
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647 /******************************************************************
1648 *
1649 * File listing
1650 *
1651 ******************************************************************/
1652 /**
1653 * For RTE: This displays all files from folder. No thumbnails shown
1654 *
1655 * @param string The folder path to expand
1656 * @param string List of fileextensions to show
1657 * @return string HTML output
1658 */
1659 function expandFolder($expandFolder=0,$extensionList='') {
1660
1661 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
1662 $out='';
1663 if ($expandFolder && $this->checkFolder($expandFolder)) {
1664
1665 // Create header for filelisting:
1666 $out.=$this->barheader($GLOBALS['LANG']->getLL('files').':');
1667
1668 // Prepare current path value for comparison (showing red arrow)
1669 if (!$this->curUrlInfo['value']) {
1670 $cmpPath='';
1671 } else {
1672 $cmpPath=PATH_site.$this->curUrlInfo['info'];
1673 }
1674
1675
1676 // Create header element; The folder from which files are listed.
1677 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1678 $picon='<img'.t3lib_iconWorks::skinImg('','gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
1679 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen));
1680 $picon='<a href="#" onclick="return link_folder(\''.t3lib_div::rawUrlEncodeFP(substr($expandFolder,strlen(PATH_site))).'\');">'.$picon.'</a>';
1681 $out.=$picon.'<br />';
1682
1683 // Get files from the folder:
1684 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
1685 $c=0;
1686 $cc=count($files);
1687
1688 if (is_array($files)) {
1689 foreach($files as $filepath) {
1690 $c++;
1691 $fI=pathinfo($filepath);
1692
1693 // File icon:
1694 $icon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
1695
1696 // If the listed file turns out to be the CURRENT file, then show blinking arrow:
1697 if ($this->curUrlInfo['act']=="file" && $cmpPath==$filepath) {
1698 $arrCol='<img'.t3lib_iconWorks::skinImg('','gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
1699 } else {
1700 $arrCol='';
1701 }
1702
1703 // Get size and icon:
1704 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes)';
1705 $icon = '<img'.t3lib_iconWorks::skinImg('','gfx/fileicons/'.$icon.'','width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
1706
1707 // Put it all together for the file element:
1708 $out.='<img'.t3lib_iconWorks::skinImg('','gfx/ol/join'.($c==$cc?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
1709 $arrCol.
1710 '<a href="#" onclick="return link_folder(\''.t3lib_div::rawUrlEncodeFP(substr($filepath,strlen(PATH_site))).'\');">'.
1711 $icon.
1712 htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen)).
1713 '</a><br />';
1714 }
1715 }
1716 }
1717 return $out;
1718 }
1719
1720 /**
1721 * For TYPO3 Element Browser: Expand folder of files.
1722 *
1723 * @param string The folder path to expand
1724 * @param string List of fileextensions to show
1725 * @param boolean Whether to show thumbnails or not. If set, no thumbnails are shown.
1726 * @return string HTML output
1727 */
1728 function TBE_expandFolder($expandFolder=0,$extensionList='',$noThumbs=0) {
1729 global $LANG;
1730
1731 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
1732 $out='';
1733 if ($expandFolder && $this->checkFolder($expandFolder)) {
1734 // Listing the files:
1735 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
1736 $out.= $this->fileList($files, $expandFolder, $noThumbs);
1737 }
1738
1739 // Return accumulated content for filelisting:
1740 return $out;
1741 }
1742
1743 /**
1744 * Render list of files.
1745 *
1746 * @param array List of files. See t3lib_div::getFilesInDir
1747 * @param string If set a header with a folder icon and folder name are shown
1748 * @param boolean Whether to show thumbnails or not. If set, no thumbnails are shown.
1749 * @return string HTML output
1750 */
1751 function fileList($files, $folderName='', $noThumbs=0) {
1752 global $LANG;
1753
1754 $out='';
1755
1756 // Listing the files:
1757 if (is_array($files)) {
1758
1759 // Create headline (showing number of files):
1760 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
1761
1762 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1763
1764 // Create the header of current folder:
1765 if($folderName) {
1766 $picon='<img'.t3lib_iconWorks::skinImg('','gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
1767 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($folderName),$titleLen));
1768 $out.=$picon.'<br />';
1769 }
1770
1771 // Init graphic object for reading file dimensions:
1772 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
1773 $imgObj->init();
1774 $imgObj->mayScaleUp=0;
1775 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
1776
1777 // Traverse the file list:
1778 $lines=array();
1779 foreach($files as $filepath) {
1780 $fI=pathinfo($filepath);
1781
1782 // Thumbnail/size generation:
1783 if (t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],$fI['extension']) && !$noThumbs) {
1784 $imgInfo = $imgObj->getImageDimensions($filepath);
1785 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
1786 $clickIcon = t3lib_BEfunc::getThumbNail('thumbs.php',$filepath,'hspace="5" vspace="5" border="1"');
1787 } else {
1788 $clickIcon = '';
1789 $pDim = '';
1790 }
1791
1792 // Create file icon:
1793 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
1794 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
1795 $icon = '<img'.t3lib_iconWorks::skinImg('','gfx/fileicons/'.$ficon,'width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" class="absmiddle" alt="" />';
1796
1797 // Create links for adding the file:
1798 if (strstr($filepath,',') || strstr($filepath,'|')) { // In case an invalid character is in the filepath, display error message:
1799 $eMsg = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'),', |'));
1800 $ATag = $ATag_alt = "<a href=\"#\" onclick=\"alert(".$eMsg.");return false;\">";
1801 } else { // If filename is OK, just add it:
1802 $ATag = "<a href=\"#\" onclick=\"return insertElement('','".t3lib_div::shortMD5($filepath)."', 'file', '".rawurlencode($fI['basename'])."', unescape('".rawurlencode($filepath)."'), '".$fI['extension']."', '".$ficon."');\">";
1803 $ATag_alt = substr($ATag,0,-4).",'',1);\">";
1804 }
1805 $ATag_e='</a>';
1806
1807 // Create link to showing details about the file in a window:
1808 $Ahref = 'show_item.php?table='.rawurlencode($filepath).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
1809 $ATag2='<a href="'.htmlspecialchars($Ahref).'">';
1810 $ATag2_e='</a>';
1811
1812 // Combine the stuff:
1813 $filenameAndIcon=$ATag_alt.$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen)).$ATag_e;
1814
1815 // Show element:
1816 if ($pDim) { // Image...
1817 $lines[]='
1818 <tr class="bgColor4">
1819 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
1820 <td>'.$ATag.'<img'.t3lib_iconWorks::skinImg('','gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$ATag_e.'</td>
1821 <td nowrap="nowrap">'.($ATag2.'<img'.t3lib_iconWorks::skinImg('','gfx/zoom2.gif','width="12" height="12"').' title="'.$LANG->getLL('info',1).'" alt="" /> '.$LANG->getLL('info',1).$ATag2_e).'</td>
1822 <td nowrap="nowrap">&nbsp;'.$pDim.'</td>
1823 </tr>';
1824 $lines[]='
1825 <tr>
1826 <td colspan="4">'.$ATag_alt.$clickIcon.$ATag_e.'</td>
1827 </tr>';
1828 } else {
1829 $lines[]='
1830 <tr class="bgColor4">
1831 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
1832 <td>'.$ATag.'<img'.t3lib_iconWorks::skinImg('','gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$ATag_e.'</td>
1833 <td nowrap="nowrap">'.($ATag2.'<img'.t3lib_iconWorks::skinImg('','gfx/zoom2.gif','width="12" height="12"').' title="'.$LANG->getLL('info',1).'" alt="" /> '.$LANG->getLL('info',1).$ATag2_e).'</td>
1834 <td>&nbsp;</td>
1835 </tr>';
1836 }
1837 $lines[]='
1838 <tr>
1839 <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
1840 </tr>';
1841 }
1842
1843 // Wrap all the rows in table tags:
1844 $out.='
1845
1846
1847
1848 <!--
1849 File listing
1850 -->
1851 <table border="0" cellpadding="0" cellspacing="1" id="typo3-fileList">
1852 '.implode('',$lines).'
1853 </table>';
1854 }
1855
1856 // Return accumulated content for filelisting:
1857 return $out;
1858 }
1859
1860 /**
1861 * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
1862 * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
1863 *
1864 * @param string The folder path to expand
1865 * @param string List of fileextensions to show
1866 * @return string HTML output
1867 */
1868 function TBE_dragNDrop($expandFolder=0,$extensionList='') {
1869
1870 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
1871 $out='';
1872 if ($expandFolder && $this->checkFolder($expandFolder)) {
1873 if ($this->isWebFolder($expandFolder)) {
1874
1875 // Read files from directory:
1876 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
1877 if (is_array($files)) {
1878 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
1879
1880 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1881 $picon='<img'.t3lib_iconWorks::skinImg('','gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
1882 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen));
1883 $out.=$picon.'<br />';
1884
1885 // Init row-array:
1886 $lines=array();
1887
1888 // Add "drag-n-drop" message:
1889 $lines[]='
1890 <tr>
1891 <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
1892 </tr>';
1893
1894 // Fraverse files:
1895 while(list(,$filepath)=each($files)) {
1896 $fI=pathinfo($filepath);
1897
1898 // URL of image:
1899 $iurl = $this->siteURL.t3lib_div::rawurlencodeFP(substr($filepath,strlen(PATH_site)));
1900
1901 // Show only web-images
1902 if (t3lib_div::inList('gif,jpeg,jpg,png',$fI['extension'])) {
1903 $imgInfo = @getimagesize($filepath);
1904 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
1905
1906 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
1907 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
1908 $icon = '<img'.t3lib_iconWorks::skinImg('','gfx/fileicons/'.$ficon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
1909 $filenameAndIcon=$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen));
1910
1911 if (t3lib_div::_GP('noLimit')) {
1912 $maxW=10000;
1913 $maxH=10000;
1914 } else {
1915 $maxW=380;
1916 $maxH=500;
1917 }
1918 $IW = $imgInfo[0];
1919 $IH = $imgInfo[1];
1920 if ($IW>$maxW) {
1921 $IH=ceil($IH/$IW*$maxW);
1922 $IW=$maxW;
1923 }
1924 if ($IH>$maxH) {
1925 $IW=ceil($IW/$IH*$maxH);
1926 $IH=$maxH;
1927 }
1928
1929 // Make row:
1930 $lines[]='
1931 <tr class="bgColor4">
1932 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
1933 <td nowrap="nowrap">'.
1934 ($imgInfo[0]!=$IW ? '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('noLimit'=>'1'))).'">'.
1935 '<img'.t3lib_iconWorks::skinImg('','gfx/icon_warning2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize',1).'" alt="" />'.
1936 '</a>':'').
1937 $pDim.'&nbsp;</td>
1938 </tr>';
1939
1940 $lines[]='
1941 <tr>
1942 <td colspan="2"><img src="'.$iurl.'" width="'.$IW.'" height="'.$IH.'" border="1" alt="" /></td>
1943 </tr>';
1944 $lines[]='
1945 <tr>
1946 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
1947 </tr>';
1948 }
1949 }
1950
1951 // Finally, wrap all rows in a table tag:
1952 $out.='
1953
1954
1955 <!--
1956 File listing / Drag-n-drop
1957 -->
1958 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
1959 '.implode('',$lines).'
1960 </table>';
1961 }
1962 } else {
1963 // Print this warning if the folder is NOT a web folder:
1964 $out.=$this->barheader($GLOBALS['LANG']->getLL('files'));
1965 $out.=$this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'),'icon_warning2');
1966 }
1967 }
1968 return $out;
1969 }
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982 /******************************************************************
1983 *
1984 * Miscellaneous functions
1985 *
1986 ******************************************************************/
1987
1988
1989 /**
1990 * Verifies that a path is a web-folder:
1991 *
1992 * @param string Absolute filepath
1993 * @return boolean If the input path is found in PATH_site then it returns true.
1994 */
1995 function isWebFolder($folder) {
1996 $folder = ereg_replace('\/$','',$folder).'/';
1997 return t3lib_div::isFirstPartOfStr($folder,PATH_site) ? TRUE : FALSE;
1998 }
1999
2000 /**
2001 * Checks, if a path is within the mountpoints of the backend user
2002 *
2003 * @param string Absolute filepath
2004 * @return boolean If the input path is found in the backend users filemounts, then return true.
2005 */
2006 function checkFolder($folder) {
2007 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
2008 $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
2009
2010 return $fileProcessor->checkPathAgainstMounts(ereg_replace('\/$','',$folder).'/') ? TRUE : FALSE;
2011 }
2012
2013 /**
2014 * Prints a 'header' where string is in a tablecell
2015 *
2016 * @param string The string to print in the header. The value is htmlspecialchars()'ed before output.
2017 * @return string The header HTML (wrapped in a table)
2018 */
2019 function barheader($str) {
2020 return '
2021
2022 <!--
2023 Bar header:
2024 -->
2025 <h3 class="bgColor5">'.htmlspecialchars($str).'</h3>
2026 ';
2027 }
2028
2029 /**
2030 * Displays a message box with the input message
2031 *
2032 * @param string Input message to show (will be htmlspecialchars()'ed inside of this function)
2033 * @param string Icon filename body from gfx/ (default is "icon_note") - meant to allow change to warning type icons...
2034 * @return string HTML for the message (wrapped in a table).
2035 */
2036 function getMsgBox($in_msg,$icon='icon_note') {
2037 $msg = '<img'.t3lib_iconWorks::skinImg('','gfx/'.$icon.'.gif','width="18" height="16"').' alt="" />'.htmlspecialchars($in_msg);
2038 $msg = '
2039
2040 <!--
2041 Message box:
2042 -->
2043 <table cellspacing="0" class="bgColor4" id="typo3-msgBox">
2044 <tr>
2045 <td>'.$msg.'</td>
2046 </tr>
2047 </table>
2048 ';
2049 return $msg;
2050 }
2051
2052 /**
2053 * For RTE/link: This prints the 'currentUrl'
2054 *
2055 * @param string URL value. The value is htmlspecialchars()'ed before output.
2056 * @return string HTML content, wrapped in a table.
2057 */
2058 function printCurrentUrl($str) {
2059 return '
2060
2061 <!--
2062 Print current URL
2063 -->
2064 <table border="0" cellpadding="0" cellspacing="0" class="bgColor5" id="typo3-curUrl">
2065 <tr>
2066 <td>'.$GLOBALS['LANG']->getLL('currentLink',1).': '.htmlspecialchars(rawurldecode($str)).'</td>
2067 </tr>
2068 </table>';
2069 }
2070
2071 /**
2072 * For RTE/link: Parses the incoming URL and determines if it's a page, file, external or mail address.
2073 *
2074 * @param string HREF value tp analyse
2075 * @param string The URL of the current website (frontend)
2076 * @return array Array with URL information stored in assoc. keys: value, act (page, file, spec, mail), pageid, cElement, info
2077 */
2078 function parseCurUrl($href,$siteUrl) {
2079 $href = trim($href);
2080 if ($href) {
2081 $info=array();
2082
2083 // Default is "url":
2084 $info['value']=$href;
2085 $info['act']='url';
2086
2087 $specialParts = explode('#_SPECIAL',$href);
2088 if (count($specialParts)==2) { // Special kind (Something RTE specific: User configurable links through: "userLinks." from ->thisConfig)
2089 $info['value']='#_SPECIAL'.$specialParts[1];
2090 $info['act']='spec';
2091 } elseif (t3lib_div::isFirstPartOfStr($href,$siteUrl)) { // If URL is on the current frontend website:
2092 $rel = substr($href,strlen($siteUrl));
2093 if (@file_exists(PATH_site.rawurldecode($rel))) { // URL is a file, which exists:
2094 $info['value']=rawurldecode($rel);
2095 $info['act']='file';
2096 } else { // URL is a page (id parameter)
2097 $uP=parse_url($rel);
2098 if (!trim($uP['path'])) {
2099 $pp = explode('id=',$uP['query']);
2100 $id = $pp[1];
2101 if ($id) {
2102 // Checking if the id-parameter is an alias.
2103 if (!t3lib_div::testInt($id)) {
2104 list($idPartR) = t3lib_BEfunc::getRecordsByField('pages','alias',$id);
2105 $id=intval($idPartR['uid']);
2106 }
2107
2108 $pageRow = t3lib_BEfunc::getRecord('pages',$id);
2109 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
2110 $info['value']=$GLOBALS['LANG']->getLL('page',1)." '".htmlspecialchars(t3lib_div::fixed_lgd_cs($pageRow['title'],$titleLen))."' (ID:".$id.($uP['fragment']?', #'.$uP['fragment']:'').')';
2111 $info['pageid']=$id;
2112 $info['cElement']=$uP['fragment'];
2113 $info['act']='page';
2114 }
2115 }
2116 }
2117 } else { // Email link:
2118 if (strtolower(substr($href,0,7))=='mailto:') {
2119 $info['value']=trim(substr($href,7));
2120 $info['act']='mail';
2121 }
2122 }
2123 $info['info'] = $info['value'];
2124 } else { // NO value inputted:
2125 $info=array();
2126 $info['info']=$GLOBALS['LANG']->getLL('none');
2127 $info['value']='';
2128 $info['act']='page';
2129 }
2130 return $info;
2131 }
2132
2133 /**
2134 * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
2135 * The files are uploaded to the tce_file.php script in the core which will handle the upload.
2136 *
2137 * @param string Absolute filepath on server to which to upload.
2138 * @return string HTML for an upload form.
2139 */
2140 function uploadForm($path) {
2141 $count=3;
2142
2143 // Create header, showing upload path:
2144 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
2145 $code=$this->barheader($GLOBALS['LANG']->getLL('uploadImage').':');
2146 $code.='
2147
2148 <!--
2149 Form, for uploading files:
2150 -->
2151 <form action="tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
2152 <table border="0" cellpadding="0" cellspacing="3" id="typo3-uplFiles">
2153 <tr>
2154 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
2155 </tr>
2156 <tr>
2157 <td>';
2158
2159 // Traverse the number of upload fields (default is 3):
2160 for ($a=1;$a<=$count;$a++) {
2161 $code.='<input type="file" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" />
2162 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($path).'" />
2163 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
2164 }
2165
2166 // Make footer of upload form, including the submit button:
2167 $redirectValue = 'browse_links.php?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
2168 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
2169 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />';
2170
2171 $code.='
2172 <div id="c-override">
2173 <input type="checkbox" name="overwriteExistingFiles" value="1" /> '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'
2174 </div>
2175 ';
2176
2177
2178 $code.='</td>
2179 </tr>
2180 </table>
2181 </form>';
2182
2183 return $code;
2184 }
2185
2186 /**
2187 * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
2188 * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
2189 *
2190 * @param string Absolute filepath on server in which to create the new folder.
2191 * @return string HTML for the create folder form.
2192 */
2193 function createFolder($path) {
2194
2195 // Create header, showing upload path:
2196 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
2197 $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
2198 $code.='
2199
2200 <!--
2201 Form, for creating new folders:
2202 -->
2203 <form action="tce_file.php" method="post" name="editform2">
2204 <table border="0" cellpadding="0" cellspacing="3" id="typo3-crFolder">
2205 <tr>
2206 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
2207 </tr>
2208 <tr>
2209 <td>';
2210
2211 // Create the new-folder name field:
2212 $a=1;
2213 $code.='<input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
2214 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($path).'" />';
2215
2216 // Make footer of upload form, including the submit button:
2217 $redirectValue = 'browse_links.php?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
2218 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
2219 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
2220
2221 $code.='</td>
2222 </tr>
2223 </table>
2224 </form>';
2225
2226 return $code;
2227 }
2228 }
2229
2230 // Include extension?
2231 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/browse_links.php']) {
2232 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/browse_links.php']);
2233 }
2234
2235
2236
2237
2238
2239
2240
2241
2242 // Make instance:
2243 $SOBE = t3lib_div::makeInstance('SC_browse_links');
2244 $SOBE->init();
2245 $SOBE->main();
2246 $SOBE->printContent();
2247 ?>