*** empty log message ***
[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::getRecordWSOL('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).
1518 t3lib_BEfunc::deleteClause('tt_content').
1519 t3lib_BEfunc::versioningPlaceholderClause('tt_content'),
1520 '',
1521 'colpos,sorting'
1522 );
1523 $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1524
1525 // Traverse list of records:
1526 $c=0;
1527 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1528 $c++;
1529 $icon=t3lib_iconWorks::getIconImage('tt_content',$row,'','');
1530 if ($this->curUrlInfo['act']=='page' && $this->curUrlInfo['cElement']==$row['uid']) {
1531 $arrCol='<img'.t3lib_iconWorks::skinImg('','gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
1532 } else {
1533 $arrCol='';
1534 }
1535 // Putting list element HTML together:
1536 $out.='<img'.t3lib_iconWorks::skinImg('','gfx/ol/join'.($c==$cc?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
1537 $arrCol.
1538 '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.$row['uid'].'\');">'.
1539 $icon.
1540 htmlspecialchars(t3lib_div::fixed_lgd_cs($row['header'],$titleLen)).
1541 '</a><br />';
1542
1543 // Finding internal anchor points:
1544 if (t3lib_div::inList('text,textpic', $row['CType'])) {
1545 $split = preg_split('/(<a[^>]+name=[\'"]?([^"\'>[:space:]]+)[\'"]?[^>]*>)/i', $row['bodytext'], -1, PREG_SPLIT_DELIM_CAPTURE);
1546
1547 foreach($split as $skey => $sval) {
1548 if (($skey%3)==2) {
1549 // Putting list element HTML together:
1550 $sval = substr($sval,0,100);
1551 $out.='<img'.t3lib_iconWorks::skinImg('','gfx/ol/line.gif','width="18" height="16"').' alt="" />'.
1552 '<img'.t3lib_iconWorks::skinImg('','gfx/ol/join'.($skey+3>count($split)?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
1553 '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.rawurlencode($sval).'\');">'.
1554 htmlspecialchars(' <A> '.$sval).
1555 '</a><br />';
1556 }
1557 }
1558 }
1559 }
1560 }
1561 return $out;
1562 }
1563
1564 /**
1565 * For TYPO3 Element Browser: This lists all content elements from the given list of tables
1566 *
1567 * @param string Commalist of tables. Set to "*" if you want all tables.
1568 * @return string HTML output.
1569 */
1570 function TBE_expandPage($tables) {
1571 global $TCA,$BE_USER;
1572
1573 $out='';
1574 if ($this->expandPage>=0 && t3lib_div::testInt($this->expandPage) && $BE_USER->isInWebMount($this->expandPage)) {
1575
1576 // Set array with table names to list:
1577 if (!strcmp(trim($tables),'*')) {
1578 $tablesArr = array_keys($TCA);
1579 } else {
1580 $tablesArr = t3lib_div::trimExplode(',',$tables,1);
1581 }
1582 reset($tablesArr);
1583
1584 // Headline for selecting records:
1585 $out.=$this->barheader($GLOBALS['LANG']->getLL('selectRecords').':');
1586
1587 // Create the header, showing the current page for which the listing is. Includes link to the page itself, if pages are amount allowed tables.
1588 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1589 $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages',$this->expandPage);
1590 $ATag='';
1591 $ATag_e='';
1592 $ATag2='';
1593 if (in_array('pages',$tablesArr)) {
1594 $ficon=t3lib_iconWorks::getIcon('pages',$mainPageRec);
1595 $ATag="<a href=\"#\" onclick=\"return insertElement('pages', '".$mainPageRec['uid']."', 'db', unescape('".rawurlencode($mainPageRec['title'])."'), '', '', '".$ficon."','',1);\">";
1596 $ATag2="<a href=\"#\" onclick=\"return insertElement('pages', '".$mainPageRec['uid']."', 'db', unescape('".rawurlencode($mainPageRec['title'])."'), '', '', '".$ficon."','',0);\">";
1597 $ATag_alt=substr($ATag,0,-4).",'',1);\">";
1598 $ATag_e='</a>';
1599 }
1600 $picon=t3lib_iconWorks::getIconImage('pages',$mainPageRec,'','');
1601 $pBicon=$ATag2?'<img'.t3lib_iconWorks::skinImg('','gfx/plusbullet2.gif','width="18" height="16"').' alt="" />':'';
1602 $pText=htmlspecialchars(t3lib_div::fixed_lgd_cs($mainPageRec['title'],$titleLen));
1603 $out.=$picon.$ATag2.$pBicon.$ATag_e.$ATag.$pText.$ATag_e.'<br />';
1604
1605 // Initialize the record listing:
1606 $id = $this->expandPage;
1607 $pointer = t3lib_div::intInRange($this->pointer,0,100000);
1608 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
1609 $pageinfo = t3lib_BEfunc::readPageAccess($id,$perms_clause);
1610 $table='';
1611
1612 // Generate the record list:
1613 $dblist = t3lib_div::makeInstance('TBE_browser_recordList');
1614 $dblist->script='browse_links.php';
1615 $dblist->backPath = $GLOBALS['BACK_PATH'];
1616 $dblist->thumbs = 0;
1617 $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageinfo);
1618 $dblist->noControlPanels=1;
1619 $dblist->clickMenuEnabled=0;
1620 $dblist->tableList=implode(',',$tablesArr);
1621
1622 $dblist->start($id,t3lib_div::_GP('table'),$pointer,
1623 t3lib_div::_GP('search_field'),
1624 t3lib_div::_GP('search_levels'),
1625 t3lib_div::_GP('showLimit')
1626 );
1627 $dblist->setDispFields();
1628 $dblist->generateList();
1629 $dblist->writeBottom();
1630
1631 // Add the HTML for the record list to output variable:
1632 $out.=$dblist->HTMLcode;
1633 $out.=$dblist->getSearchBox();
1634 }
1635
1636 // Return accumulated content:
1637 return $out;
1638 }
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651 /******************************************************************
1652 *
1653 * File listing
1654 *
1655 ******************************************************************/
1656 /**
1657 * For RTE: This displays all files from folder. No thumbnails shown
1658 *
1659 * @param string The folder path to expand
1660 * @param string List of fileextensions to show
1661 * @return string HTML output
1662 */
1663 function expandFolder($expandFolder=0,$extensionList='') {
1664
1665 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
1666 $out='';
1667 if ($expandFolder && $this->checkFolder($expandFolder)) {
1668
1669 // Create header for filelisting:
1670 $out.=$this->barheader($GLOBALS['LANG']->getLL('files').':');
1671
1672 // Prepare current path value for comparison (showing red arrow)
1673 if (!$this->curUrlInfo['value']) {
1674 $cmpPath='';
1675 } else {
1676 $cmpPath=PATH_site.$this->curUrlInfo['info'];
1677 }
1678
1679
1680 // Create header element; The folder from which files are listed.
1681 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1682 $picon='<img'.t3lib_iconWorks::skinImg('','gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
1683 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen));
1684 $picon='<a href="#" onclick="return link_folder(\''.t3lib_div::rawUrlEncodeFP(substr($expandFolder,strlen(PATH_site))).'\');">'.$picon.'</a>';
1685 $out.=$picon.'<br />';
1686
1687 // Get files from the folder:
1688 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
1689 $c=0;
1690 $cc=count($files);
1691
1692 if (is_array($files)) {
1693 foreach($files as $filepath) {
1694 $c++;
1695 $fI=pathinfo($filepath);
1696
1697 // File icon:
1698 $icon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
1699
1700 // If the listed file turns out to be the CURRENT file, then show blinking arrow:
1701 if ($this->curUrlInfo['act']=="file" && $cmpPath==$filepath) {
1702 $arrCol='<img'.t3lib_iconWorks::skinImg('','gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
1703 } else {
1704 $arrCol='';
1705 }
1706
1707 // Get size and icon:
1708 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes)';
1709 $icon = '<img'.t3lib_iconWorks::skinImg('','gfx/fileicons/'.$icon.'','width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
1710
1711 // Put it all together for the file element:
1712 $out.='<img'.t3lib_iconWorks::skinImg('','gfx/ol/join'.($c==$cc?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
1713 $arrCol.
1714 '<a href="#" onclick="return link_folder(\''.t3lib_div::rawUrlEncodeFP(substr($filepath,strlen(PATH_site))).'\');">'.
1715 $icon.
1716 htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen)).
1717 '</a><br />';
1718 }
1719 }
1720 }
1721 return $out;
1722 }
1723
1724 /**
1725 * For TYPO3 Element Browser: Expand folder of files.
1726 *
1727 * @param string The folder path to expand
1728 * @param string List of fileextensions to show
1729 * @param boolean Whether to show thumbnails or not. If set, no thumbnails are shown.
1730 * @return string HTML output
1731 */
1732 function TBE_expandFolder($expandFolder=0,$extensionList='',$noThumbs=0) {
1733 global $LANG;
1734
1735 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
1736 $out='';
1737 if ($expandFolder && $this->checkFolder($expandFolder)) {
1738 // Listing the files:
1739 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
1740 $out.= $this->fileList($files, $expandFolder, $noThumbs);
1741 }
1742
1743 // Return accumulated content for filelisting:
1744 return $out;
1745 }
1746
1747 /**
1748 * Render list of files.
1749 *
1750 * @param array List of files. See t3lib_div::getFilesInDir
1751 * @param string If set a header with a folder icon and folder name are shown
1752 * @param boolean Whether to show thumbnails or not. If set, no thumbnails are shown.
1753 * @return string HTML output
1754 */
1755 function fileList($files, $folderName='', $noThumbs=0) {
1756 global $LANG;
1757
1758 $out='';
1759
1760 // Listing the files:
1761 if (is_array($files)) {
1762
1763 // Create headline (showing number of files):
1764 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
1765
1766 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1767
1768 // Create the header of current folder:
1769 if($folderName) {
1770 $picon='<img'.t3lib_iconWorks::skinImg('','gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
1771 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($folderName),$titleLen));
1772 $out.=$picon.'<br />';
1773 }
1774
1775 // Init graphic object for reading file dimensions:
1776 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
1777 $imgObj->init();
1778 $imgObj->mayScaleUp=0;
1779 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
1780
1781 // Traverse the file list:
1782 $lines=array();
1783 foreach($files as $filepath) {
1784 $fI=pathinfo($filepath);
1785
1786 // Thumbnail/size generation:
1787 if (t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],$fI['extension']) && !$noThumbs) {
1788 $imgInfo = $imgObj->getImageDimensions($filepath);
1789 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
1790 $clickIcon = t3lib_BEfunc::getThumbNail('thumbs.php',$filepath,'hspace="5" vspace="5" border="1"');
1791 } else {
1792 $clickIcon = '';
1793 $pDim = '';
1794 }
1795
1796 // Create file icon:
1797 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
1798 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
1799 $icon = '<img'.t3lib_iconWorks::skinImg('','gfx/fileicons/'.$ficon,'width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" class="absmiddle" alt="" />';
1800
1801 // Create links for adding the file:
1802 if (strstr($filepath,',') || strstr($filepath,'|')) { // In case an invalid character is in the filepath, display error message:
1803 $eMsg = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'),', |'));
1804 $ATag = $ATag_alt = "<a href=\"#\" onclick=\"alert(".$eMsg.");return false;\">";
1805 } else { // If filename is OK, just add it:
1806 $ATag = "<a href=\"#\" onclick=\"return insertElement('','".t3lib_div::shortMD5($filepath)."', 'file', '".rawurlencode($fI['basename'])."', unescape('".rawurlencode($filepath)."'), '".$fI['extension']."', '".$ficon."');\">";
1807 $ATag_alt = substr($ATag,0,-4).",'',1);\">";
1808 }
1809 $ATag_e='</a>';
1810
1811 // Create link to showing details about the file in a window:
1812 $Ahref = 'show_item.php?table='.rawurlencode($filepath).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
1813 $ATag2='<a href="'.htmlspecialchars($Ahref).'">';
1814 $ATag2_e='</a>';
1815
1816 // Combine the stuff:
1817 $filenameAndIcon=$ATag_alt.$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen)).$ATag_e;
1818
1819 // Show element:
1820 if ($pDim) { // Image...
1821 $lines[]='
1822 <tr class="bgColor4">
1823 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
1824 <td>'.$ATag.'<img'.t3lib_iconWorks::skinImg('','gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$ATag_e.'</td>
1825 <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>
1826 <td nowrap="nowrap">&nbsp;'.$pDim.'</td>
1827 </tr>';
1828 $lines[]='
1829 <tr>
1830 <td colspan="4">'.$ATag_alt.$clickIcon.$ATag_e.'</td>
1831 </tr>';
1832 } else {
1833 $lines[]='
1834 <tr class="bgColor4">
1835 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
1836 <td>'.$ATag.'<img'.t3lib_iconWorks::skinImg('','gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$ATag_e.'</td>
1837 <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>
1838 <td>&nbsp;</td>
1839 </tr>';
1840 }
1841 $lines[]='
1842 <tr>
1843 <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
1844 </tr>';
1845 }
1846
1847 // Wrap all the rows in table tags:
1848 $out.='
1849
1850
1851
1852 <!--
1853 File listing
1854 -->
1855 <table border="0" cellpadding="0" cellspacing="1" id="typo3-fileList">
1856 '.implode('',$lines).'
1857 </table>';
1858 }
1859
1860 // Return accumulated content for filelisting:
1861 return $out;
1862 }
1863
1864 /**
1865 * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
1866 * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
1867 *
1868 * @param string The folder path to expand
1869 * @param string List of fileextensions to show
1870 * @return string HTML output
1871 */
1872 function TBE_dragNDrop($expandFolder=0,$extensionList='') {
1873
1874 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
1875 $out='';
1876 if ($expandFolder && $this->checkFolder($expandFolder)) {
1877 if ($this->isWebFolder($expandFolder)) {
1878
1879 // Read files from directory:
1880 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
1881 if (is_array($files)) {
1882 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
1883
1884 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1885 $picon='<img'.t3lib_iconWorks::skinImg('','gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
1886 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen));
1887 $out.=$picon.'<br />';
1888
1889 // Init row-array:
1890 $lines=array();
1891
1892 // Add "drag-n-drop" message:
1893 $lines[]='
1894 <tr>
1895 <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
1896 </tr>';
1897
1898 // Fraverse files:
1899 while(list(,$filepath)=each($files)) {
1900 $fI=pathinfo($filepath);
1901
1902 // URL of image:
1903 $iurl = $this->siteURL.t3lib_div::rawurlencodeFP(substr($filepath,strlen(PATH_site)));
1904
1905 // Show only web-images
1906 if (t3lib_div::inList('gif,jpeg,jpg,png',$fI['extension'])) {
1907 $imgInfo = @getimagesize($filepath);
1908 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
1909
1910 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
1911 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
1912 $icon = '<img'.t3lib_iconWorks::skinImg('','gfx/fileicons/'.$ficon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
1913 $filenameAndIcon=$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen));
1914
1915 if (t3lib_div::_GP('noLimit')) {
1916 $maxW=10000;
1917 $maxH=10000;
1918 } else {
1919 $maxW=380;
1920 $maxH=500;
1921 }
1922 $IW = $imgInfo[0];
1923 $IH = $imgInfo[1];
1924 if ($IW>$maxW) {
1925 $IH=ceil($IH/$IW*$maxW);
1926 $IW=$maxW;
1927 }
1928 if ($IH>$maxH) {
1929 $IW=ceil($IW/$IH*$maxH);
1930 $IH=$maxH;
1931 }
1932
1933 // Make row:
1934 $lines[]='
1935 <tr class="bgColor4">
1936 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
1937 <td nowrap="nowrap">'.
1938 ($imgInfo[0]!=$IW ? '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('noLimit'=>'1'))).'">'.
1939 '<img'.t3lib_iconWorks::skinImg('','gfx/icon_warning2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize',1).'" alt="" />'.
1940 '</a>':'').
1941 $pDim.'&nbsp;</td>
1942 </tr>';
1943
1944 $lines[]='
1945 <tr>
1946 <td colspan="2"><img src="'.$iurl.'" width="'.$IW.'" height="'.$IH.'" border="1" alt="" /></td>
1947 </tr>';
1948 $lines[]='
1949 <tr>
1950 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
1951 </tr>';
1952 }
1953 }
1954
1955 // Finally, wrap all rows in a table tag:
1956 $out.='
1957
1958
1959 <!--
1960 File listing / Drag-n-drop
1961 -->
1962 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
1963 '.implode('',$lines).'
1964 </table>';
1965 }
1966 } else {
1967 // Print this warning if the folder is NOT a web folder:
1968 $out.=$this->barheader($GLOBALS['LANG']->getLL('files'));
1969 $out.=$this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'),'icon_warning2');
1970 }
1971 }
1972 return $out;
1973 }
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986 /******************************************************************
1987 *
1988 * Miscellaneous functions
1989 *
1990 ******************************************************************/
1991
1992
1993 /**
1994 * Verifies that a path is a web-folder:
1995 *
1996 * @param string Absolute filepath
1997 * @return boolean If the input path is found in PATH_site then it returns true.
1998 */
1999 function isWebFolder($folder) {
2000 $folder = ereg_replace('\/$','',$folder).'/';
2001 return t3lib_div::isFirstPartOfStr($folder,PATH_site) ? TRUE : FALSE;
2002 }
2003
2004 /**
2005 * Checks, if a path is within the mountpoints of the backend user
2006 *
2007 * @param string Absolute filepath
2008 * @return boolean If the input path is found in the backend users filemounts, then return true.
2009 */
2010 function checkFolder($folder) {
2011 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
2012 $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
2013
2014 return $fileProcessor->checkPathAgainstMounts(ereg_replace('\/$','',$folder).'/') ? TRUE : FALSE;
2015 }
2016
2017 /**
2018 * Prints a 'header' where string is in a tablecell
2019 *
2020 * @param string The string to print in the header. The value is htmlspecialchars()'ed before output.
2021 * @return string The header HTML (wrapped in a table)
2022 */
2023 function barheader($str) {
2024 return '
2025
2026 <!--
2027 Bar header:
2028 -->
2029 <h3 class="bgColor5">'.htmlspecialchars($str).'</h3>
2030 ';
2031 }
2032
2033 /**
2034 * Displays a message box with the input message
2035 *
2036 * @param string Input message to show (will be htmlspecialchars()'ed inside of this function)
2037 * @param string Icon filename body from gfx/ (default is "icon_note") - meant to allow change to warning type icons...
2038 * @return string HTML for the message (wrapped in a table).
2039 */
2040 function getMsgBox($in_msg,$icon='icon_note') {
2041 $msg = '<img'.t3lib_iconWorks::skinImg('','gfx/'.$icon.'.gif','width="18" height="16"').' alt="" />'.htmlspecialchars($in_msg);
2042 $msg = '
2043
2044 <!--
2045 Message box:
2046 -->
2047 <table cellspacing="0" class="bgColor4" id="typo3-msgBox">
2048 <tr>
2049 <td>'.$msg.'</td>
2050 </tr>
2051 </table>
2052 ';
2053 return $msg;
2054 }
2055
2056 /**
2057 * For RTE/link: This prints the 'currentUrl'
2058 *
2059 * @param string URL value. The value is htmlspecialchars()'ed before output.
2060 * @return string HTML content, wrapped in a table.
2061 */
2062 function printCurrentUrl($str) {
2063 return '
2064
2065 <!--
2066 Print current URL
2067 -->
2068 <table border="0" cellpadding="0" cellspacing="0" class="bgColor5" id="typo3-curUrl">
2069 <tr>
2070 <td>'.$GLOBALS['LANG']->getLL('currentLink',1).': '.htmlspecialchars(rawurldecode($str)).'</td>
2071 </tr>
2072 </table>';
2073 }
2074
2075 /**
2076 * For RTE/link: Parses the incoming URL and determines if it's a page, file, external or mail address.
2077 *
2078 * @param string HREF value tp analyse
2079 * @param string The URL of the current website (frontend)
2080 * @return array Array with URL information stored in assoc. keys: value, act (page, file, spec, mail), pageid, cElement, info
2081 */
2082 function parseCurUrl($href,$siteUrl) {
2083 $href = trim($href);
2084 if ($href) {
2085 $info=array();
2086
2087 // Default is "url":
2088 $info['value']=$href;
2089 $info['act']='url';
2090
2091 $specialParts = explode('#_SPECIAL',$href);
2092 if (count($specialParts)==2) { // Special kind (Something RTE specific: User configurable links through: "userLinks." from ->thisConfig)
2093 $info['value']='#_SPECIAL'.$specialParts[1];
2094 $info['act']='spec';
2095 } elseif (t3lib_div::isFirstPartOfStr($href,$siteUrl)) { // If URL is on the current frontend website:
2096 $rel = substr($href,strlen($siteUrl));
2097 if (@file_exists(PATH_site.rawurldecode($rel))) { // URL is a file, which exists:
2098 $info['value']=rawurldecode($rel);
2099 $info['act']='file';
2100 } else { // URL is a page (id parameter)
2101 $uP=parse_url($rel);
2102 if (!trim($uP['path'])) {
2103 $pp = explode('id=',$uP['query']);
2104 $id = $pp[1];
2105 if ($id) {
2106 // Checking if the id-parameter is an alias.
2107 if (!t3lib_div::testInt($id)) {
2108 list($idPartR) = t3lib_BEfunc::getRecordsByField('pages','alias',$id);
2109 $id=intval($idPartR['uid']);
2110 }
2111
2112 $pageRow = t3lib_BEfunc::getRecordWSOL('pages',$id);
2113 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
2114 $info['value']=$GLOBALS['LANG']->getLL('page',1)." '".htmlspecialchars(t3lib_div::fixed_lgd_cs($pageRow['title'],$titleLen))."' (ID:".$id.($uP['fragment']?', #'.$uP['fragment']:'').')';
2115 $info['pageid']=$id;
2116 $info['cElement']=$uP['fragment'];
2117 $info['act']='page';
2118 }
2119 }
2120 }
2121 } else { // Email link:
2122 if (strtolower(substr($href,0,7))=='mailto:') {
2123 $info['value']=trim(substr($href,7));
2124 $info['act']='mail';
2125 }
2126 }
2127 $info['info'] = $info['value'];
2128 } else { // NO value inputted:
2129 $info=array();
2130 $info['info']=$GLOBALS['LANG']->getLL('none');
2131 $info['value']='';
2132 $info['act']='page';
2133 }
2134 return $info;
2135 }
2136
2137 /**
2138 * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
2139 * The files are uploaded to the tce_file.php script in the core which will handle the upload.
2140 *
2141 * @param string Absolute filepath on server to which to upload.
2142 * @return string HTML for an upload form.
2143 */
2144 function uploadForm($path) {
2145 $count=3;
2146
2147 // Create header, showing upload path:
2148 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
2149 $code=$this->barheader($GLOBALS['LANG']->getLL('uploadImage').':');
2150 $code.='
2151
2152 <!--
2153 Form, for uploading files:
2154 -->
2155 <form action="tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
2156 <table border="0" cellpadding="0" cellspacing="3" id="typo3-uplFiles">
2157 <tr>
2158 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
2159 </tr>
2160 <tr>
2161 <td>';
2162
2163 // Traverse the number of upload fields (default is 3):
2164 for ($a=1;$a<=$count;$a++) {
2165 $code.='<input type="file" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" />
2166 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($path).'" />
2167 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
2168 }
2169
2170 // Make footer of upload form, including the submit button:
2171 $redirectValue = 'browse_links.php?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
2172 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
2173 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />';
2174
2175 $code.='
2176 <div id="c-override">
2177 <input type="checkbox" name="overwriteExistingFiles" value="1" /> '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'
2178 </div>
2179 ';
2180
2181
2182 $code.='</td>
2183 </tr>
2184 </table>
2185 </form>';
2186
2187 return $code;
2188 }
2189
2190 /**
2191 * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
2192 * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
2193 *
2194 * @param string Absolute filepath on server in which to create the new folder.
2195 * @return string HTML for the create folder form.
2196 */
2197 function createFolder($path) {
2198
2199 // Create header, showing upload path:
2200 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
2201 $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
2202 $code.='
2203
2204 <!--
2205 Form, for creating new folders:
2206 -->
2207 <form action="tce_file.php" method="post" name="editform2">
2208 <table border="0" cellpadding="0" cellspacing="3" id="typo3-crFolder">
2209 <tr>
2210 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
2211 </tr>
2212 <tr>
2213 <td>';
2214
2215 // Create the new-folder name field:
2216 $a=1;
2217 $code.='<input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
2218 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($path).'" />';
2219
2220 // Make footer of upload form, including the submit button:
2221 $redirectValue = 'browse_links.php?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
2222 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
2223 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
2224
2225 $code.='</td>
2226 </tr>
2227 </table>
2228 </form>';
2229
2230 return $code;
2231 }
2232 }
2233
2234 // Include extension?
2235 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/browse_links.php']) {
2236 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/browse_links.php']);
2237 }
2238
2239
2240
2241
2242
2243
2244
2245
2246 // Make instance:
2247 $SOBE = t3lib_div::makeInstance('SC_browse_links');
2248 $SOBE->init();
2249 $SOBE->main();
2250 $SOBE->printContent();
2251 ?>