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