First CVS update in a long time - see the top of changelog. In particular the foundat...
[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 include ('sysext/lang/locallang_browse_links.php');
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($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($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 $menu='
1069
1070
1071 <!--
1072 RTE Link top menu:
1073 -->
1074 <table border="0" cellpadding="2" cellspacing="1" id="typo3-RTElinkMenu">
1075 <tr>
1076 ';
1077 $bgcolor=' class="bgColor4"';
1078 $bgcolorA=' class="bgColor5"';
1079 if (!$wiz) $menu.='<td'.$bgcolor.'><a href="#" onclick="self.parent.parent.renderPopup_unLink();return false;">'.$GLOBALS['LANG']->getLL('removeLink',1).'</a></td>';
1080 if (in_array('page',$allowedItems)) $menu.='
1081 <td'.($this->act=='page'?$bgcolorA:$bgcolor).'><a href="#" onclick="jumpToUrl(\'?act=page\');return false;">'.$GLOBALS['LANG']->getLL('page',1).'</a></td>';
1082 if (in_array('file',$allowedItems)) $menu.='
1083 <td'.($this->act=='file'?$bgcolorA:$bgcolor).'><a href="#" onclick="jumpToUrl(\'?act=file\');return false;">'.$GLOBALS['LANG']->getLL('file',1).'</a></td>';
1084 if (in_array('url',$allowedItems)) $menu.='
1085 <td'.($this->act=='url'?$bgcolorA:$bgcolor).'><a href="#" onclick="jumpToUrl(\'?act=url\');return false;">'.$GLOBALS['LANG']->getLL('extUrl',1).'</a></td>';
1086 if (in_array('mail',$allowedItems)) $menu.='
1087 <td'.($this->act=='mail'?$bgcolorA:$bgcolor).'><a href="#" onclick="jumpToUrl(\'?act=mail\');return false;">'.$GLOBALS['LANG']->getLL('email',1).'</a></td>';
1088 if (is_array($this->thisConfig['userLinks.']) && in_array('spec',$allowedItems)) $menu.='
1089 <td'.($this->act=='spec'?$bgcolorA:$bgcolor).'><a href="#" onclick="jumpToUrl(\'?act=spec\');return false;">'.$GLOBALS['LANG']->getLL('special',1).'</a></td>';
1090 $menu.='
1091 </tr>
1092 </table>';
1093
1094 // Adding the menu and header to the top of page:
1095 $content.=$this->printCurrentUrl($this->curUrlInfo['info']);
1096 $content.=$menu;
1097
1098 // Depending on the current action we will create the actual module content for selecting a link:
1099 switch($this->act) {
1100 case 'mail':
1101 $extUrl='
1102
1103 <!--
1104 Enter mail address:
1105 -->
1106 <form action="" name="lurlform" id="lurlform">
1107 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
1108 <tr>
1109 <td>'.$GLOBALS['LANG']->getLL('emailAddress',1).':</td>
1110 <td><input type="text" name="lemail"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='mail'?$this->curUrlInfo['info']:'').'" /> '.
1111 '<input type="submit" value="'.$GLOBALS['LANG']->getLL('setLink',1).'" onclick="setTarget(\'\');setValue(\'mailto:\'+document.lurlform.lemail.value); return link_current();" /></td>
1112 </tr>
1113 </table>
1114 </form>';
1115 $content.=$extUrl;
1116 break;
1117 case 'url':
1118 $extUrl='
1119
1120 <!--
1121 Enter External URL:
1122 -->
1123 <form action="" name="lurlform" id="lurlform">
1124 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
1125 <tr>
1126 <td>URL:</td>
1127 <td><input type="text" name="lurl"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='url'?$this->curUrlInfo['info']:'http://').'" /> '.
1128 '<input type="submit" value="'.$GLOBALS['LANG']->getLL('setLink',1).'" onclick="setValue(document.lurlform.lurl.value); return link_current();" /></td>
1129 </tr>
1130 </table>
1131 </form>';
1132 $content.=$extUrl;
1133 break;
1134 case 'file':
1135 $foldertree = t3lib_div::makeInstance('rteFolderTree');
1136 $tree=$foldertree->getBrowsableTree();
1137
1138 if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act']!='file') {
1139 $cmpPath='';
1140 } elseif (substr(trim($this->curUrlInfo['info']),-1)!='/') {
1141 $cmpPath=PATH_site.dirname($this->curUrlInfo['info']).'/';
1142 if (!isset($this->expandFolder)) $this->expandFolder = $cmpPath;
1143 } else {
1144 $cmpPath=PATH_site.$this->curUrlInfo['info'];
1145 }
1146
1147 list(,,$specUid) = explode('_',$this->PM);
1148 $files = $this->expandFolder($foldertree->specUIDmap[$specUid]);
1149
1150 $content.= '
1151
1152 <!--
1153 Wrapper table for folder tree / file list:
1154 -->
1155 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
1156 <tr>
1157 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1158 <td class="c-wCell" valign="top">'.$files.'</td>
1159 </tr>
1160 </table>
1161 ';
1162 break;
1163 case 'spec':
1164 if (is_array($this->thisConfig['userLinks.'])) {
1165 $subcats=array();
1166 $v=$this->thisConfig['userLinks.'];
1167 reset($v);
1168 while(list($k2)=each($v)) {
1169 $k2i = intval($k2);
1170 if (substr($k2,-1)=='.' && is_array($v[$k2i.'.'])) {
1171
1172 // Title:
1173 $title = trim($v[$k2i]);
1174 if (!$title) {
1175 $title=$v[$k2i.'.']['url'];
1176 } else {
1177 $title=$LANG->sL($title);
1178 }
1179 // Description:
1180 $description=$v[$k2i.'.']['description'] ? $LANG->sL($v[$k2i.'.']['description'],1).'<br />' : '';
1181
1182 // URL + onclick event:
1183 $onClickEvent='';
1184 if (isset($v[$k2i.'.']['target'])) $onClickEvent.="setTarget('".$v[$k2i.'.']['target']."');";
1185 $v[$k2i.'.']['url'] = str_replace('###_URL###',$this->siteURL,$v[$k2i.'.']['url']);
1186 if (substr($v[$k2i.'.']['url'],0,7)=="http://" || substr($v[$k2i.'.']['url'],0,7)=='mailto:') {
1187 $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i.'.']['url'])."');link_current();";
1188 } else {
1189 $onClickEvent.="link_spec(unescape('".$this->siteURL.rawurlencode($v[$k2i.'.']['url'])."'));";
1190 }
1191
1192 // Link:
1193 $A=array('<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">','</a>');
1194
1195 // Adding link to menu of user defined links:
1196 $subcats[$k2i]='
1197 <tr>
1198 <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>
1199 </tr>';
1200 }
1201 }
1202
1203 // Sort by keys:
1204 ksort($subcats);
1205
1206 // Add menu to content:
1207 $content.= '
1208
1209 <!--
1210 Special userdefined menu:
1211 -->
1212 <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
1213 <tr>
1214 <td class="bgColor5" class="c-wCell" valign="top"><strong>'.$LANG->getLL('special',1).'</strong></td>
1215 </tr>
1216 '.implode('',$subcats).'
1217 </table>
1218 ';
1219 }
1220 break;
1221 case 'page':
1222 default:
1223 $pagetree = t3lib_div::makeInstance('rtePageTree');
1224 $tree=$pagetree->getBrowsableTree();
1225 $cElements = $this->expandPage();
1226 $content.= '
1227
1228 <!--
1229 Wrapper table for page tree / record list:
1230 -->
1231 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
1232 <tr>
1233 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('pageTree').':').$tree.'</td>
1234 <td class="c-wCell" valign="top">'.$cElements.'</td>
1235 </tr>
1236 </table>
1237 ';
1238 break;
1239 }
1240
1241 // Target:
1242 if ($this->act!='mail') {
1243 $ltarget='
1244
1245
1246 <!--
1247 Selecting target for link:
1248 -->
1249 <form action="" name="ltargetform" id="ltargetform">
1250 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
1251 <tr>
1252 <td>'.$GLOBALS['LANG']->getLL('target',1).':</td>
1253 <td><input type="text" name="ltarget" onchange="setTarget(this.value);" value="'.htmlspecialchars($this->setTarget).'"'.$this->doc->formWidth(10).' /></td>
1254 <td>
1255 <select name="ltarget_type" onchange="setTarget(this.options[this.selectedIndex].value);document.ltargetform.ltarget.value=this.options[this.selectedIndex].value;this.selectedIndex=0;">
1256 <option></option>
1257 <option value="_top">'.$GLOBALS['LANG']->getLL('top',1).'</option>
1258 <option value="_blank">'.$GLOBALS['LANG']->getLL('newWindow',1).'</option>
1259 </select>
1260 </td>
1261 <td>';
1262
1263 if (($this->curUrlInfo['act']=="page" || $this->curUrlInfo['act']=='file') && $this->curUrlArray['href']) {
1264 $ltarget.='
1265 <input type="submit" value="'.$GLOBALS['LANG']->getLL('update',1).'" onclick="return link_current();" />';
1266 }
1267
1268 $selectJS = '
1269 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) {
1270 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;
1271 setTarget(document.ltargetform.ltarget.value);
1272 document.ltargetform.popup_width.selectedIndex=0;
1273 document.ltargetform.popup_height.selectedIndex=0;
1274 }
1275 ';
1276
1277 $ltarget.=' </td>
1278 </tr>
1279 <tr>
1280 <td>'.$GLOBALS['LANG']->getLL('target_popUpWindow',1).':</td>
1281 <td colspan="3">
1282 <select name="popup_width" onchange="'.htmlspecialchars($selectJS).'">
1283 <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_width',1).'</option>
1284 <option value="300">300</option>
1285 <option value="400">400</option>
1286 <option value="500">500</option>
1287 <option value="600">600</option>
1288 <option value="700">700</option>
1289 <option value="800">800</option>
1290 </select>
1291 x
1292 <select name="popup_height" onchange="'.htmlspecialchars($selectJS).'">
1293 <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_height',1).'</option>
1294 <option value="200">200</option>
1295 <option value="300">300</option>
1296 <option value="400">400</option>
1297 <option value="500">500</option>
1298 <option value="600">600</option>
1299 </select>
1300 </td>
1301 </tr>
1302 </table>
1303 </form>';
1304
1305 // Add "target selector" box to content:
1306 $content.=$ltarget;
1307
1308 // Add some space
1309 $content.='<br /><br />';
1310 }
1311
1312 // End page, return content:
1313 $content.= $this->doc->endPage();
1314 return $content;
1315 }
1316
1317 /**
1318 * TYPO3 Element Browser: Showing a page tree and allows you to browse for records
1319 *
1320 * @return string HTML content for the module
1321 */
1322 function main_db() {
1323
1324 // Starting content:
1325 $content=$this->doc->startPage('TBE file selector');
1326
1327 // Init variable:
1328 $pArr = explode('|',$this->bparams);
1329
1330 // Making the browsable pagetree:
1331 $pagetree = t3lib_div::makeInstance('TBE_PageTree');
1332 $pagetree->script='browse_links.php';
1333 $pagetree->ext_pArrPages = !strcmp($pArr[3],'pages')?1:0;
1334 $tree=$pagetree->getBrowsableTree();
1335
1336 // Making the list of elements, if applicable:
1337 $cElements = $this->TBE_expandPage($pArr[3]);
1338
1339 // Putting the things together, side by side:
1340 $content.= '
1341
1342 <!--
1343 Wrapper table for page tree / record list:
1344 -->
1345 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBrecords">
1346 <tr>
1347 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('pageTree').':').$tree.'</td>
1348 <td class="c-wCell" valign="top">'.$cElements.'</td>
1349 </tr>
1350 </table>
1351 ';
1352
1353 // Add some space
1354 $content.='<br /><br />';
1355
1356 // End page, return content:
1357 $content.= $this->doc->endPage();
1358 return $content;
1359 }
1360
1361 /**
1362 * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for files.
1363 *
1364 * @return string HTML content for the module
1365 */
1366 function main_file() {
1367 global $BE_USER;
1368
1369 // Starting content:
1370 $content.=$this->doc->startPage('TBE file selector');
1371
1372 // Init variable:
1373 $pArr = explode('|',$this->bparams);
1374
1375 // Create upload/create folder forms, if a path is given:
1376 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
1377 $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
1378 $path=$this->expandFolder;
1379 if (!$path || !@is_dir($path)) {
1380 $path = $fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
1381 }
1382 if ($path!='/' && @is_dir($path)) {
1383 $uploadForm=$this->uploadForm($path);
1384 $createFolder=$this->createFolder($path);
1385 } else {
1386 $createFolder='';
1387 $uploadForm='';
1388 }
1389 if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) $content.=$uploadForm;
1390
1391 // Getting flag for showing/not showing thumbnails:
1392 $noThumbs = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
1393
1394 if (!$noThumbs) {
1395 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
1396 $_MOD_MENU = array('displayThumbs' => '');
1397 $_MCONF['name']='file_list';
1398 $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']);
1399 $addParams = '&act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
1400 $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);
1401 } else {
1402 $thumbNailCheck='';
1403 }
1404
1405 // Create folder tree:
1406 $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
1407 $foldertree->script='browse_links.php';
1408 $foldertree->ext_noTempRecyclerDirs = ($this->mode == 'filedrag');
1409 $tree=$foldertree->getBrowsableTree();
1410
1411 list(,,$specUid) = explode('_',$this->PM);
1412
1413 if ($this->mode=='filedrag') {
1414 $files = $this->TBE_dragNDrop($foldertree->specUIDmap[$specUid],$pArr[3]);
1415 } else {
1416 $files = $this->TBE_expandFolder($foldertree->specUIDmap[$specUid],$pArr[3],$noThumbs?$noThumbs:!$_MOD_SETTINGS['displayThumbs']);
1417 }
1418
1419 // Putting the parts together, side by side:
1420 $content.= '
1421
1422 <!--
1423 Wrapper table for folder tree / file list:
1424 -->
1425 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
1426 <tr>
1427 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1428 <td class="c-wCell" valign="top">'.$files.'</td>
1429 </tr>
1430 </table>
1431 ';
1432 $content.=$thumbNailCheck;
1433
1434 // Adding create folder + upload forms if applicable:
1435 if (!$BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) $content.=$uploadForm;
1436 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) $content.=$createFolder;
1437
1438 // Add some space
1439 $content.='<br /><br />';
1440
1441 // Ending page, returning content:
1442 $content.= $this->doc->endPage();
1443 return $content;
1444 }
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464 /******************************************************************
1465 *
1466 * Record listing
1467 *
1468 ******************************************************************/
1469 /**
1470 * For RTE: This displays all content elements on a page and lets you create a link to the element.
1471 *
1472 * @return string HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...)
1473 */
1474 function expandPage() {
1475 global $BE_USER;
1476
1477 $out = '';
1478 $expPageId = $this->expandPage; // Set page id (if any) to expand
1479
1480 // If there is an anchor value (content element reference) in the element reference, then force an ID to expand:
1481 if (!$this->expandPage && $this->curUrlInfo['cElement']) {
1482 $expPageId = $this->curUrlInfo['pageid']; // Set to the current link page id.
1483 }
1484
1485 // Draw the record list IF there is a page id to expand:
1486 if ($expPageId && t3lib_div::testInt($expPageId) && $BE_USER->isInWebMount($expPageId)) {
1487
1488 // Set header:
1489 $out.= $this->barheader($GLOBALS['LANG']->getLL('contentElements').':');
1490
1491 // Create header for listing, showing the page title/icon:
1492 $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
1493 $mainPageRec = t3lib_BEfunc::getRecord('pages',$expPageId);
1494 $picon = t3lib_iconWorks::getIconImage('pages',$mainPageRec,'','');
1495 $picon.= htmlspecialchars(t3lib_div::fixed_lgd($mainPageRec['title'],$titleLen));
1496 $out.= $picon.'<br />';
1497
1498 // Look up tt_content elements from the expanded page:
1499 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1500 'uid,header,hidden,starttime,endtime,fe_group,CType,colpos',
1501 'tt_content',
1502 'pid='.intval($expPageId).t3lib_BEfunc::deleteClause('tt_content'),
1503 '',
1504 'colpos,sorting'
1505 );
1506 $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1507
1508 // Traverse list of records:
1509 $c=0;
1510 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1511 $c++;
1512 $icon=t3lib_iconWorks::getIconImage('tt_content',$row,'','');
1513 if ($this->curUrlInfo['act']=='page' && $this->curUrlInfo['cElement']==$row['uid']) {
1514 $arrCol='<img'.t3lib_iconWorks::skinImg('','gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
1515 } else {
1516 $arrCol='';
1517 }
1518 // Putting list element HTML together:
1519 $out.='<img'.t3lib_iconWorks::skinImg('','gfx/ol/join'.($c==$cc?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
1520 $arrCol.
1521 '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.$row['uid'].'\');">'.
1522 $icon.
1523 htmlspecialchars(t3lib_div::fixed_lgd($row['header'],$titleLen)).
1524 '</a><br />';
1525 }
1526 }
1527 return $out;
1528 }
1529
1530 /**
1531 * For TYPO3 Element Browser: This lists all content elements from the given list of tables
1532 *
1533 * @param string Commalist of tables. Set to "*" if you want all tables.
1534 * @return string HTML output.
1535 */
1536 function TBE_expandPage($tables) {
1537 global $TCA,$BE_USER;
1538
1539 $out='';
1540 if ($this->expandPage>=0 && t3lib_div::testInt($this->expandPage) && $BE_USER->isInWebMount($this->expandPage)) {
1541
1542 // Set array with table names to list:
1543 if (!strcmp(trim($tables),'*')) {
1544 $tablesArr = array_keys($TCA);
1545 } else {
1546 $tablesArr = t3lib_div::trimExplode(',',$tables,1);
1547 }
1548 reset($tablesArr);
1549
1550 // Headline for selecting records:
1551 $out.=$this->barheader($GLOBALS['LANG']->getLL('selectRecords').':');
1552
1553 // Create the header, showing the current page for which the listing is. Includes link to the page itself, if pages are amount allowed tables.
1554 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1555 $mainPageRec = t3lib_BEfunc::getRecord('pages',$this->expandPage);
1556 $ATag='';
1557 $ATag_e='';
1558 $ATag2='';
1559 if (in_array('pages',$tablesArr)) {
1560 $ficon=t3lib_iconWorks::getIcon('pages',$mainPageRec);
1561 $ATag="<a href=\"#\" onclick=\"return insertElement('pages', '".$mainPageRec['uid']."', 'db', unescape('".rawurlencode($mainPageRec['title'])."'), '', '', '".$ficon."','',1);\">";
1562 $ATag2="<a href=\"#\" onclick=\"return insertElement('pages', '".$mainPageRec['uid']."', 'db', unescape('".rawurlencode($mainPageRec['title'])."'), '', '', '".$ficon."','',0);\">";
1563 $ATag_alt=substr($ATag,0,-4).",'',1);\">";
1564 $ATag_e='</a>';
1565 }
1566 $picon=t3lib_iconWorks::getIconImage('pages',$mainPageRec,'','');
1567 $pBicon=$ATag2?'<img'.t3lib_iconWorks::skinImg('','gfx/plusbullet2.gif','width="18" height="16"').' alt="" />':'';
1568 $pText=htmlspecialchars(t3lib_div::fixed_lgd($mainPageRec['title'],$titleLen));
1569 $out.=$picon.$ATag2.$pBicon.$ATag_e.$ATag.$pText.$ATag_e.'<br />';
1570
1571 // Initialize the record listing:
1572 $id = $this->expandPage;
1573 $pointer = t3lib_div::intInRange($this->pointer,0,100000);
1574 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
1575 $pageinfo = t3lib_BEfunc::readPageAccess($id,$perms_clause);
1576 $table='';
1577
1578 // Generate the record list:
1579 $dblist = t3lib_div::makeInstance('TBE_browser_recordList');
1580 $dblist->script='browse_links.php';
1581 $dblist->backPath = $GLOBALS['BACK_PATH'];
1582 $dblist->thumbs = 0;
1583 $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageinfo);
1584 $dblist->noControlPanels=1;
1585 $dblist->tableList=implode(',',$tablesArr);
1586
1587 $dblist->start($id,t3lib_div::_GP('table'),$pointer,
1588 t3lib_div::_GP('search_field'),
1589 t3lib_div::_GP('search_levels'),
1590 t3lib_div::_GP('showLimit')
1591 );
1592 $dblist->setDispFields();
1593 $dblist->generateList($id,$table);
1594 $dblist->writeBottom();
1595
1596 // Add the HTML for the record list to output variable:
1597 $out.=$dblist->HTMLcode;
1598 $out.=$dblist->getSearchBox();
1599 }
1600
1601 // Return accumulated content:
1602 return $out;
1603 }
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616 /******************************************************************
1617 *
1618 * File listing
1619 *
1620 ******************************************************************/
1621 /**
1622 * For RTE: This displays all files from folder. No thumbnails shown
1623 *
1624 * @param string The folder path to expand
1625 * @param string List of fileextensions to show
1626 * @return string HTML output
1627 */
1628 function expandFolder($expandFolder=0,$extensionList='') {
1629
1630 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
1631 $out='';
1632 if ($expandFolder && $this->checkFolder($expandFolder)) {
1633
1634 // Create header for filelisting:
1635 $out.=$this->barheader($GLOBALS['LANG']->getLL('files').':');
1636
1637 // Prepare current path value for comparison (showing red arrow)
1638 if (!$this->curUrlInfo['value']) {
1639 $cmpPath='';
1640 } else {
1641 $cmpPath=PATH_site.$this->curUrlInfo['info'];
1642 }
1643
1644
1645 // Create header element; The folder from which files are listed.
1646 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1647 $picon='<img'.t3lib_iconWorks::skinImg('','gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
1648 $picon.=htmlspecialchars(t3lib_div::fixed_lgd(basename($expandFolder),$titleLen));
1649 $picon='<a href="#" onclick="return link_folder(\''.t3lib_div::rawUrlEncodeFP(substr($expandFolder,strlen(PATH_site))).'\');">'.$picon.'</a>';
1650 $out.=$picon.'<br />';
1651
1652 // Get files from the folder:
1653 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
1654 $c=0;
1655 $cc=count($files);
1656
1657 if (is_array($files)) {
1658 foreach($files as $filepath) {
1659 $c++;
1660 $fI=pathinfo($filepath);
1661
1662 // File icon:
1663 $icon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
1664
1665 // If the listed file turns out to be the CURRENT file, then show blinking arrow:
1666 if ($this->curUrlInfo['act']=="file" && $cmpPath==$filepath) {
1667 $arrCol='<img'.t3lib_iconWorks::skinImg('','gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
1668 } else {
1669 $arrCol='';
1670 }
1671
1672 // Get size and icon:
1673 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes)';
1674 $icon = '<img'.t3lib_iconWorks::skinImg('','gfx/fileicons/'.$icon.'','width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
1675
1676 // Put it all together for the file element:
1677 $out.='<img'.t3lib_iconWorks::skinImg('','gfx/ol/join'.($c==$cc?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
1678 $arrCol.
1679 '<a href="#" onclick="return link_folder(\''.t3lib_div::rawUrlEncodeFP(substr($filepath,strlen(PATH_site))).'\');">'.
1680 $icon.
1681 htmlspecialchars(t3lib_div::fixed_lgd(basename($filepath),$titleLen)).
1682 '</a><br />';
1683 }
1684 }
1685 }
1686 return $out;
1687 }
1688
1689 /**
1690 * For TYPO3 Element Browser: Expand folder of files.
1691 *
1692 * @param string The folder path to expand
1693 * @param string List of fileextensions to show
1694 * @param boolean Whether to show thumbnails or not. It set, no thumbnails are shown.
1695 * @return string HTML output
1696 */
1697 function TBE_expandFolder($expandFolder=0,$extensionList='',$noThumbs=0) {
1698 global $LANG;
1699
1700 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
1701 $out='';
1702 if ($expandFolder && $this->checkFolder($expandFolder)) {
1703
1704 // Listing the files:
1705 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
1706 if (is_array($files)) {
1707
1708 // Create headline (showing number of files):
1709 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
1710
1711 // Create the header of current folder:
1712 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1713 $picon='<img'.t3lib_iconWorks::skinImg('','gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
1714 $picon.=htmlspecialchars(t3lib_div::fixed_lgd(basename($expandFolder),$titleLen));
1715 $out.=$picon.'<br />';
1716
1717 // Init graphic object for reading file dimensions:
1718 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
1719 $imgObj->init();
1720 $imgObj->mayScaleUp=0;
1721 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
1722
1723 // Traverse the file list:
1724 $lines=array();
1725 foreach($files as $filepath) {
1726 $fI=pathinfo($filepath);
1727
1728 // Thumbnail/size generation:
1729 if (t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],$fI['extension']) && !$noThumbs) {
1730 $imgInfo = $imgObj->getImageDimensions($filepath);
1731 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
1732 $clickIcon = t3lib_BEfunc::getThumbNail('thumbs.php',$filepath,'hspace="5" vspace="5" border="1"');
1733 } else {
1734 $clickIcon = '';
1735 $pDim = '';
1736 }
1737
1738 // Create file icon:
1739 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
1740 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
1741 $icon = '<img'.t3lib_iconWorks::skinImg('','gfx/fileicons/'.$ficon,'width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" class="absmiddle" alt="" />';
1742
1743 // Create links for adding the file:
1744 if (strstr($filepath,',') || strstr($filepath,'|')) { // In case an invalid character is in the filepath, display error message:
1745 $eMsg = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'),', |'));
1746 $ATag = $ATag_alt = "<a href=\"#\" onclick=\"alert(".$eMsg.");return false;\">";
1747 } else { // If filename is OK, just add it:
1748 $ATag = "<a href=\"#\" onclick=\"return insertElement('','".t3lib_div::shortMD5($filepath)."', 'file', '".rawurlencode($fI['basename'])."', unescape('".rawurlencode($filepath)."'), '".$fI['extension']."', '".$ficon."');\">";
1749 $ATag_alt = substr($ATag,0,-4).",'',1);\">";
1750 }
1751 $ATag_e='</a>';
1752
1753 // Create link to showing details about the file in a window:
1754 $Ahref = 'show_item.php?table='.rawurlencode($filepath).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
1755 $ATag2='<a href="'.htmlspecialchars($Ahref).'">';
1756 $ATag2_e='</a>';
1757
1758 // Combine the stuff:
1759 $filenameAndIcon=$ATag_alt.$icon.htmlspecialchars(t3lib_div::fixed_lgd(basename($filepath),$titleLen)).$ATag_e;
1760
1761 // Show element:
1762 if ($pDim) { // Image...
1763 $lines[]='
1764 <tr class="bgColor4">
1765 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
1766 <td>'.$ATag.'<img'.t3lib_iconWorks::skinImg('','gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$ATag_e.'</td>
1767 <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>
1768 <td nowrap="nowrap">&nbsp;'.$pDim.'</td>
1769 </tr>';
1770 $lines[]='
1771 <tr>
1772 <td colspan="4">'.$ATag_alt.$clickIcon.$ATag_e.'</td>
1773 </tr>';
1774 } else {
1775 $lines[]='
1776 <tr class="bgColor4">
1777 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
1778 <td>'.$ATag.'<img'.t3lib_iconWorks::skinImg('','gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$ATag_e.'</td>
1779 <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>
1780 <td>&nbsp;</td>
1781 </tr>';
1782 }
1783 $lines[]='
1784 <tr>
1785 <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
1786 </tr>';
1787 }
1788
1789 // Wrap all the rows in table tags:
1790 $out.='
1791
1792
1793
1794 <!--
1795 File listing
1796 -->
1797 <table border="0" cellpadding="0" cellspacing="1" id="typo3-fileList">
1798 '.implode('',$lines).'
1799 </table>';
1800 }
1801 }
1802
1803 // Return accumulated content for filelisting:
1804 return $out;
1805 }
1806
1807 /**
1808 * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
1809 * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
1810 *
1811 * @param string The folder path to expand
1812 * @param string List of fileextensions to show
1813 * @return string HTML output
1814 */
1815 function TBE_dragNDrop($expandFolder=0,$extensionList='') {
1816
1817 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
1818 $out='';
1819 if ($expandFolder && $this->checkFolder($expandFolder)) {
1820 if ($this->isWebFolder($expandFolder)) {
1821
1822 // Read files from directory:
1823 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
1824 if (is_array($files)) {
1825 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
1826
1827 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1828 $picon='<img'.t3lib_iconWorks::skinImg('','gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
1829 $picon.=htmlspecialchars(t3lib_div::fixed_lgd(basename($expandFolder),$titleLen));
1830 $out.=$picon.'<br />';
1831
1832 // Init row-array:
1833 $lines=array();
1834
1835 // Add "drag-n-drop" message:
1836 $lines[]='
1837 <tr>
1838 <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
1839 </tr>';
1840
1841 // Fraverse files:
1842 while(list(,$filepath)=each($files)) {
1843 $fI=pathinfo($filepath);
1844
1845 // URL of image:
1846 $iurl = $this->siteURL.t3lib_div::rawurlencodeFP(substr($filepath,strlen(PATH_site)));
1847
1848 // Show only web-images
1849 if (t3lib_div::inList('gif,jpeg,jpg,png',$fI['extension'])) {
1850 $imgInfo = @getimagesize($filepath);
1851 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
1852
1853 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
1854 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
1855 $icon = '<img'.t3lib_iconWorks::skinImg('','gfx/fileicons/'.$ficon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
1856 $filenameAndIcon=$icon.htmlspecialchars(t3lib_div::fixed_lgd(basename($filepath),$titleLen));
1857
1858 if (t3lib_div::_GP('noLimit')) {
1859 $maxW=10000;
1860 $maxH=10000;
1861 } else {
1862 $maxW=380;
1863 $maxH=500;
1864 }
1865 $IW = $imgInfo[0];
1866 $IH = $imgInfo[1];
1867 if ($IW>$maxW) {
1868 $IH=ceil($IH/$IW*$maxW);
1869 $IW=$maxW;
1870 }
1871 if ($IH>$maxH) {
1872 $IW=ceil($IW/$IH*$maxH);
1873 $IH=$maxH;
1874 }
1875
1876 // Make row:
1877 $lines[]='
1878 <tr class="bgColor4">
1879 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
1880 <td nowrap="nowrap">'.
1881 ($imgInfo[0]!=$IW ? '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('noLimit'=>'1'))).'">'.
1882 '<img'.t3lib_iconWorks::skinImg('','gfx/icon_warning2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize',1).'" alt="" />'.
1883 '</a>':'').
1884 $pDim.'&nbsp;</td>
1885 </tr>';
1886
1887 $lines[]='
1888 <tr>
1889 <td colspan="2"><img src="'.$iurl.'" width="'.$IW.'" height="'.$IH.'" border="1" alt="" /></td>
1890 </tr>';
1891 $lines[]='
1892 <tr>
1893 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
1894 </tr>';
1895 }
1896 }
1897
1898 // Finally, wrap all rows in a table tag:
1899 $out.='
1900
1901
1902 <!--
1903 File listing / Drag-n-drop
1904 -->
1905 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
1906 '.implode('',$lines).'
1907 </table>';
1908 }
1909 } else {
1910 // Print this warning if the folder is NOT a web folder:
1911 $out.=$this->barheader($GLOBALS['LANG']->getLL('files'));
1912 $out.=$this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'),'icon_warning2');
1913 }
1914 }
1915 return $out;
1916 }
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929 /******************************************************************
1930 *
1931 * Miscellaneous functions
1932 *
1933 ******************************************************************/
1934
1935
1936 /**
1937 * Verifies that a path is a web-folder:
1938 *
1939 * @param string Absolute filepath
1940 * @return boolean If the input path is found in PATH_site then it returns true.
1941 */
1942 function isWebFolder($folder) {
1943 $folder = ereg_replace('\/$','',$folder).'/';
1944 return t3lib_div::isFirstPartOfStr($folder,PATH_site) ? TRUE : FALSE;
1945 }
1946
1947 /**
1948 * Checks, if a path is within the mountpoints of the backend user
1949 *
1950 * @param string Absolute filepath
1951 * @return boolean If the input path is found in the backend users filemounts, then return true.
1952 */
1953 function checkFolder($folder) {
1954 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
1955 $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
1956
1957 return $fileProcessor->checkPathAgainstMounts(ereg_replace('\/$','',$folder).'/') ? TRUE : FALSE;
1958 }
1959
1960 /**
1961 * Prints a 'header' where string is in a tablecell
1962 *
1963 * @param string The string to print in the header. The value is htmlspecialchars()'ed before output.
1964 * @return string The header HTML (wrapped in a table)
1965 */
1966 function barheader($str) {
1967 return '
1968
1969 <!--
1970 Bar header:
1971 -->
1972 <h3 class="bgColor5">'.htmlspecialchars($str).'</h3>
1973 ';
1974 }
1975
1976 /**
1977 * Displays a message box with the input message
1978 *
1979 * @param string Input message to show (will be htmlspecialchars()'ed inside of this function)
1980 * @param string Icon filename body from gfx/ (default is "icon_note") - meant to allow change to warning type icons...
1981 * @return string HTML for the message (wrapped in a table).
1982 */
1983 function getMsgBox($in_msg,$icon='icon_note') {
1984 $msg = '<img'.t3lib_iconWorks::skinImg('','gfx/'.$icon.'.gif','width="18" height="16"').' alt="" />'.htmlspecialchars($in_msg);
1985 $msg = '
1986
1987 <!--
1988 Message box:
1989 -->
1990 <table cellspacing="0" class="bgColor4" id="typo3-msgBox">
1991 <tr>
1992 <td>'.$msg.'</td>
1993 </tr>
1994 </table>
1995 ';
1996 return $msg;
1997 }
1998
1999 /**
2000 * For RTE/link: This prints the 'currentUrl'
2001 *
2002 * @param string URL value. The value is htmlspecialchars()'ed before output.
2003 * @return string HTML content, wrapped in a table.
2004 */
2005 function printCurrentUrl($str) {
2006 return '
2007
2008 <!--
2009 Print current URL
2010 -->
2011 <table border="0" cellpadding="0" cellspacing="0" class="bgColor5" id="typo3-curUrl">
2012 <tr>
2013 <td>'.$GLOBALS['LANG']->getLL('currentLink',1).': '.htmlspecialchars(rawurldecode($str)).'</td>
2014 </tr>
2015 </table>';
2016 }
2017
2018 /**
2019 * For RTE/link: Parses the incoming URL and determines if it's a page, file, external or mail address.
2020 *
2021 * @param string HREF value tp analyse
2022 * @param string The URL of the current website (frontend)
2023 * @return array Array with URL information stored in assoc. keys: value, act (page, file, spec, mail), pageid, cElement, info
2024 */
2025 function parseCurUrl($href,$siteUrl) {
2026 $href = trim($href);
2027 if ($href) {
2028 $info=array();
2029
2030 // Default is "url":
2031 $info['value']=$href;
2032 $info['act']='url';
2033
2034 $specialParts = explode('#_SPECIAL',$href);
2035 if (count($specialParts)==2) { // Special kind (Something RTE specific: User configurable links through: "userLinks." from ->thisConfig)
2036 $info['value']='#_SPECIAL'.$specialParts[1];
2037 $info['act']='spec';
2038 } elseif (t3lib_div::isFirstPartOfStr($href,$siteUrl)) { // If URL is on the current frontend website:
2039 $rel = substr($href,strlen($siteUrl));
2040 if (@file_exists(PATH_site.rawurldecode($rel))) { // URL is a file, which exists:
2041 $info['value']=rawurldecode($rel);
2042 $info['act']='file';
2043 } else { // URL is a page (id parameter)
2044 $uP=parse_url($rel);
2045 if (!trim($uP['path'])) {
2046 $pp = explode('id=',$uP['query']);
2047 $id = $pp[1];
2048 if ($id) {
2049 // Checking if the id-parameter is an alias.
2050 if (!t3lib_div::testInt($id)) {
2051 list($idPartR) = t3lib_BEfunc::getRecordsByField('pages','alias',$id);
2052 $id=intval($idPartR['uid']);
2053 }
2054
2055 $pageRow = t3lib_BEfunc::getRecord('pages',$id);
2056 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
2057 $info['value']=$GLOBALS['LANG']->getLL('page',1)." '".htmlspecialchars(t3lib_div::fixed_lgd($pageRow['title'],$titleLen))."' (ID:".$id.($uP['fragment']?', #'.$uP['fragment']:'').')';
2058 $info['pageid']=$id;
2059 $info['cElement']=$uP['fragment'];
2060 $info['act']='page';
2061 }
2062 }
2063 }
2064 } else { // Email link:
2065 if (strtolower(substr($href,0,7))=='mailto:') {
2066 $info['value']=trim(substr($href,7));
2067 $info['act']='mail';
2068 }
2069 }
2070 $info['info'] = $info['value'];
2071 } else { // NO value inputted:
2072 $info=array();
2073 $info['info']=$GLOBALS['LANG']->getLL('none');
2074 $info['value']='';
2075 $info['act']='page';
2076 }
2077 return $info;
2078 }
2079
2080 /**
2081 * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
2082 * The files are uploaded to the tce_file.php script in the core which will handle the upload.
2083 *
2084 * @param string Absolute filepath on server to which to upload.
2085 * @return string HTML for an upload form.
2086 */
2087 function uploadForm($path) {
2088 $count=3;
2089
2090 // Create header, showing upload path:
2091 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
2092 $code=$this->barheader($GLOBALS['LANG']->getLL('uploadImage').':');
2093 $code.='
2094
2095 <!--
2096 Form, for uploading files:
2097 -->
2098 <form action="tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
2099 <table border="0" cellpadding="0" cellspacing="3" id="typo3-uplFiles">
2100 <tr>
2101 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
2102 </tr>
2103 <tr>
2104 <td>';
2105
2106 // Traverse the number of upload fields (default is 3):
2107 for ($a=1;$a<=$count;$a++) {
2108 $code.='<input type="file" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" />
2109 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($path).'" />
2110 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
2111 }
2112
2113 // Make footer of upload form, including the submit button:
2114 $redirectValue = 'browse_links.php?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
2115 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
2116 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />';
2117
2118 $code.='
2119 <div id="c-override">
2120 <input type="checkbox" name="overwriteExistingFiles" value="1" /> '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.php:overwriteExistingFiles',1).'
2121 </div>
2122 ';
2123
2124
2125 $code.='</td>
2126 </tr>
2127 </table>
2128 </form>';
2129
2130 return $code;
2131 }
2132
2133 /**
2134 * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
2135 * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
2136 *
2137 * @param string Absolute filepath on server in which to create the new folder.
2138 * @return string HTML for the create folder form.
2139 */
2140 function createFolder($path) {
2141
2142 // Create header, showing upload path:
2143 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
2144 $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
2145 $code.='
2146
2147 <!--
2148 Form, for creating new folders:
2149 -->
2150 <form action="tce_file.php" method="post" name="editform2">
2151 <table border="0" cellpadding="0" cellspacing="3" id="typo3-crFolder">
2152 <tr>
2153 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
2154 </tr>
2155 <tr>
2156 <td>';
2157
2158 // Create the new-folder name field:
2159 $a=1;
2160 $code.='<input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
2161 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($path).'" />';
2162
2163 // Make footer of upload form, including the submit button:
2164 $redirectValue = 'browse_links.php?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
2165 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
2166 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
2167
2168 $code.='</td>
2169 </tr>
2170 </table>
2171 </form>';
2172
2173 return $code;
2174 }
2175 }
2176
2177 // Include extension?
2178 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/browse_links.php']) {
2179 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/browse_links.php']);
2180 }
2181
2182
2183
2184
2185
2186
2187
2188
2189 // Make instance:
2190 $SOBE = t3lib_div::makeInstance('SC_browse_links');
2191 $SOBE->init();
2192 $SOBE->main();
2193 $SOBE->printContent();
2194 ?>