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