Fixed bug #8001: Problems using link wizard in content elements, credits Ralf Hettinger
[Packages/TYPO3.CMS.git] / typo3 / class.browse_links.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2008 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 * 155: class TBE_browser_recordList extends localRecordList
44 * 163: function TBE_browser_recordList ()
45 * 175: function listURL($altId='',$table=-1,$exclList='')
46 * 194: function ext_addP()
47 * 211: function linkWrapItems($table,$uid,$code,$row)
48 * 244: function linkWrapTable($table,$code)
49 *
50 *
51 * 261: class localPageTree extends t3lib_browseTree
52 * 268: function localPageTree()
53 * 284: function wrapTitle($title,$v,$ext_pArrPages='')
54 * 299: function printTree($treeArr='')
55 * 350: function ext_isLinkable($doktype,$uid)
56 * 364: function PM_ATagWrap($icon,$cmd,$bMark='')
57 * 381: function wrapIcon($icon,$row)
58 *
59 *
60 * 400: class rtePageTree extends localPageTree
61 *
62 *
63 * 417: class TBE_PageTree extends localPageTree
64 * 426: function ext_isLinkable($doktype,$uid)
65 * 438: function wrapTitle($title,$v,$ext_pArrPages)
66 *
67 *
68 * 464: class localFolderTree extends t3lib_folderTree
69 * 473: function localFolderTree()
70 * 485: function wrapTitle($title,$v)
71 * 500: function ext_isLinkable($v)
72 * 517: function PM_ATagWrap($icon,$cmd,$bMark='')
73 * 532: function printTree($treeArr='')
74 *
75 *
76 * 599: class rteFolderTree extends localFolderTree
77 *
78 *
79 * 615: class TBE_FolderTree extends localFolderTree
80 * 624: function ext_isLinkable($v)
81 * 637: function wrapTitle($title,$v)
82 *
83 *
84 * 658: class browse_links
85 * 764: function init()
86 * 1034: function processSessionData($data)
87 *
88 * SECTION: Main functions
89 * 1077: function main_rte($wiz=0)
90 * 1379: function main_db()
91 * 1424: function main_file()
92 *
93 * SECTION: Record listing
94 * 1534: function expandPage()
95 * 1615: function TBE_expandPage($tables)
96 *
97 * SECTION: File listing
98 * 1708: function expandFolder($expandFolder=0,$extensionList='')
99 * 1778: function TBE_expandFolder($expandFolder=0,$extensionList='',$noThumbs=0)
100 * 1801: function fileList($files, $folderName='', $noThumbs=0)
101 * 1918: function TBE_dragNDrop($expandFolder=0,$extensionList='')
102 *
103 * SECTION: Miscellaneous functions
104 * 2046: function isWebFolder($folder)
105 * 2057: function checkFolder($folder)
106 * 2070: function barheader($str)
107 * 2087: function getMsgBox($in_msg,$icon='icon_note')
108 * 2111: function printCurrentUrl($str)
109 * 2131: function parseCurUrl($href,$siteUrl)
110 * 2193: function uploadForm($path)
111 * 2247: function createFolder($path)
112 *
113 * TOTAL FUNCTIONS: 39
114 * (This index is automatically created/updated by the extension "extdeveval")
115 *
116 */
117
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
123
124 // Include classes
125 require_once (PATH_t3lib.'class.t3lib_page.php');
126 require_once (PATH_t3lib.'class.t3lib_recordlist.php');
127 require_once (PATH_typo3.'/class.db_list.inc');
128 require_once (PATH_typo3.'/class.db_list_extra.inc');
129 require_once (PATH_t3lib.'/class.t3lib_pagetree.php');
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 <kasperYYYY@typo3.com>
153 * @package TYPO3
154 * @subpackage core
155 */
156 class TBE_browser_recordList extends localRecordList {
157 var $thisScript = 'browse_links.php';
158
159 /**
160 * Initializes the script path
161 *
162 * @return void
163 */
164 function TBE_browser_recordList () {
165 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
166 }
167
168 /**
169 * Creates the URL for links
170 *
171 * @param mixed If not blank string, this is used instead of $this->id as the id value.
172 * @param string If this is "-1" then $this->table is used, otherwise the value of the input variable.
173 * @param string Commalist of fields NOT to pass as parameters (currently "sortField" and "sortRev")
174 * @return string Query-string for URL
175 */
176 function listURL($altId='',$table=-1,$exclList='') {
177 return $this->thisScript.
178 '?id='.(strcmp($altId,'')?$altId:$this->id).
179 '&table='.rawurlencode($table==-1?$this->table:$table).
180 ($this->thumbs?'&imagemode='.$this->thumbs:'').
181 ($this->searchString?'&search_field='.rawurlencode($this->searchString):'').
182 ($this->searchLevels?'&search_levels='.rawurlencode($this->searchLevels):'').
183 ((!$exclList || !t3lib_div::inList($exclList,'sortField')) && $this->sortField?'&sortField='.rawurlencode($this->sortField):'').
184 ((!$exclList || !t3lib_div::inList($exclList,'sortRev')) && $this->sortRev?'&sortRev='.rawurlencode($this->sortRev):'').
185 // extra:
186 $this->ext_addP()
187 ;
188 }
189
190 /**
191 * Returns additional, local GET parameters to include in the links of the record list.
192 *
193 * @return string
194 */
195 function ext_addP() {
196 $str = '&act='.$GLOBALS['SOBE']->browser->act.
197 '&mode='.$GLOBALS['SOBE']->browser->mode.
198 '&expandPage='.$GLOBALS['SOBE']->browser->expandPage.
199 '&bparams='.rawurlencode($GLOBALS['SOBE']->browser->bparams);
200 return $str;
201 }
202
203 /**
204 * 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...)
205 *
206 * @param string Table name
207 * @param integer UID (not used here)
208 * @param string Title string
209 * @param array Records array (from table name)
210 * @return string
211 */
212 function linkWrapItems($table,$uid,$code,$row) {
213 global $TCA, $BACK_PATH;
214
215 if (!$code) {
216 $code = '<i>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</i>';
217 } else {
218 $code = htmlspecialchars(t3lib_div::fixed_lgd_cs($code,$this->fixedL));
219 }
220
221 $title = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
222 $ficon = t3lib_iconWorks::getIcon($table,$row);
223 $aOnClick = "return insertElement('".$table."', '".$row['uid']."', 'db', ".t3lib_div::quoteJSvalue($title).", '', '', '".$ficon."');";
224 $ATag = '<a href="#" onclick="'.$aOnClick.'">';
225 $ATag_alt = substr($ATag,0,-4).',\'\',1);">';
226 $ATag_e = '</a>';
227
228 return $ATag.
229 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('addToList',1).'" alt="" />'.
230 $ATag_e.
231 $ATag_alt.
232 $code.
233 $ATag_e;
234 }
235
236 /**
237 * Local version that sets allFields to true to support userFieldSelect
238 *
239 * @return void
240 * @see fieldSelectBox
241 */
242 function generateList() {
243 $this->allFields = true;
244 parent::generateList();
245 }
246 }
247
248
249
250
251
252
253 /**
254 * Class which generates the page tree
255 *
256 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
257 * @package TYPO3
258 * @subpackage core
259 */
260 class localPageTree extends t3lib_browseTree {
261
262 /**
263 * Constructor. Just calling init()
264 *
265 * @return void
266 */
267 function localPageTree() {
268 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
269
270 $this->init();
271
272 $this->clause = ' AND doktype!=255'.$this->clause;
273 }
274
275 /**
276 * Wrapping the title in a link, if applicable.
277 *
278 * @param string Title, (must be ready for output, that means it must be htmlspecialchars()'ed).
279 * @param array The record
280 * @param boolean (Ignore)
281 * @return string Wrapping title string.
282 */
283 function wrapTitle($title,$v,$ext_pArrPages='') {
284 if ($this->ext_isLinkable($v['doktype'],$v['uid'])) {
285 $aOnClick = "return link_typo3Page('".$v['uid']."');";
286 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
287 } else {
288 return '<span style="color: #666666;">'.$title.'</span>';
289 }
290 }
291
292 /**
293 * Create the page navigation tree in HTML
294 *
295 * @param array Tree array
296 * @return string HTML output.
297 */
298 function printTree($treeArr='') {
299 global $BACK_PATH;
300 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
301 if (!is_array($treeArr)) $treeArr=$this->tree;
302
303 $out='';
304 $c=0;
305
306 foreach($treeArr as $k => $v) {
307 $c++;
308 $bgColorClass = ($c+1)%2 ? 'bgColor' : 'bgColor-10';
309 if ($GLOBALS['SOBE']->browser->curUrlInfo['act']=='page' && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']==$v['row']['uid'] && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']) {
310 $arrCol='<td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
311 $bgColorClass='bgColor4';
312 } else {
313 $arrCol='<td></td>';
314 }
315
316 $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandPage='.$v['row']['uid'].'\');';
317 $cEbullet = $this->ext_isLinkable($v['row']['doktype'],$v['row']['uid']) ?
318 '<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/arrowbullet.gif','width="18" height="16"').' alt="" /></a>' :
319 '';
320 $out.='
321 <tr class="'.$bgColorClass.'">
322 <td nowrap="nowrap"'.($v['row']['_CSSCLASS'] ? ' class="'.$v['row']['_CSSCLASS'].'"' : '').'>'.
323 $v['HTML'].
324 $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$this->ext_pArrPages).
325 '</td>'.
326 $arrCol.
327 '<td>'.$cEbullet.'</td>
328 </tr>';
329 }
330 $out='
331
332
333 <!--
334 Navigation Page Tree:
335 -->
336 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
337 '.$out.'
338 </table>';
339 return $out;
340 }
341
342 /**
343 * Returns true if a doktype can be linked.
344 *
345 * @param integer Doktype value to test
346 * @param integer uid to test.
347 * @return boolean
348 */
349 function ext_isLinkable($doktype,$uid) {
350 if ($uid && $doktype<199) {
351 return true;
352 }
353 }
354
355 /**
356 * Wrap the plus/minus icon in a link
357 *
358 * @param string HTML string to wrap, probably an image tag.
359 * @param string Command for 'PM' get var
360 * @param boolean If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
361 * @return string Link-wrapped input string
362 */
363 function PM_ATagWrap($icon,$cmd,$bMark='') {
364 if ($bMark) {
365 $anchor = '#'.$bMark;
366 $name=' name="'.$bMark.'"';
367 }
368 $aOnClick = "return jumpToUrl('".$this->thisScript.'?PM='.$cmd."','".$anchor."');";
369
370 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
371 }
372
373 /**
374 * Wrapping the image tag, $icon, for the row, $row
375 *
376 * @param string The image tag for the icon
377 * @param array The row for the current element
378 * @return string The processed icon input value.
379 */
380 function wrapIcon($icon,$row) {
381 return $this->addTagAttributes($icon,' title="id='.$row['uid'].'"');
382 }
383 }
384
385
386
387
388
389
390
391
392 /**
393 * Page tree for the RTE - totally the same, no changes needed. (Just for the sake of beauty - or confusion... :-)
394 *
395 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
396 * @package TYPO3
397 * @subpackage core
398 */
399 class rtePageTree extends localPageTree {
400 }
401
402
403
404
405
406
407
408
409 /**
410 * For TBE record browser
411 *
412 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
413 * @package TYPO3
414 * @subpackage core
415 */
416 class TBE_PageTree extends localPageTree {
417
418 /**
419 * Returns true if a doktype can be linked (which is always the case here).
420 *
421 * @param integer Doktype value to test
422 * @param integer uid to test.
423 * @return boolean
424 */
425 function ext_isLinkable($doktype,$uid) {
426 return true;
427 }
428
429 /**
430 * Wrapping the title in a link, if applicable.
431 *
432 * @param string Title, ready for output.
433 * @param array The record
434 * @param boolean If set, pages clicked will return immediately, otherwise reload page.
435 * @return string Wrapping title string.
436 */
437 function wrapTitle($title,$v,$ext_pArrPages) {
438 if ($ext_pArrPages) {
439 $ficon=t3lib_iconWorks::getIcon('pages',$v);
440 $onClick = "return insertElement('pages', '".$v['uid']."', 'db', ".t3lib_div::quoteJSvalue($v['title']).", '', '', '".$ficon."','',1);";
441 } else {
442 $onClick = htmlspecialchars('return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandPage='.$v['uid'].'\');');
443 }
444 return '<a href="#" onclick="'.$onClick.'">'.$title.'</a>';
445 }
446 }
447
448
449
450
451
452
453
454
455 /**
456 * Base extension class which generates the folder tree.
457 * Used directly by the RTE.
458 *
459 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
460 * @package TYPO3
461 * @subpackage core
462 */
463 class localFolderTree extends t3lib_folderTree {
464 var $ext_IconMode=1;
465
466
467 /**
468 * Initializes the script path
469 *
470 * @return void
471 */
472 function localFolderTree() {
473 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
474 $this->t3lib_folderTree();
475 }
476
477 /**
478 * Wrapping the title in a link, if applicable.
479 *
480 * @param string Title, ready for output.
481 * @param array The "record"
482 * @return string Wrapping title string.
483 */
484 function wrapTitle($title,$v) {
485 if ($this->ext_isLinkable($v)) {
486 $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandFolder='.rawurlencode($v['path']).'\');';
487 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
488 } else {
489 return '<span class="typo3-dimmed">'.$title.'</span>';
490 }
491 }
492
493 /**
494 * Returns true if the input "record" contains a folder which can be linked.
495 *
496 * @param array Array with information about the folder element. Contains keys like title, uid, path, _title
497 * @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
498 */
499 function ext_isLinkable($v) {
500 $webpath=t3lib_BEfunc::getPathType_web_nonweb($v['path']); // Checking, if the input path is a web-path.
501 if (strstr($v['path'],'_recycler_') || strstr($v['path'],'_temp_') || $webpath!='web') {
502 return 0;
503 }
504 return 1;
505 }
506
507 /**
508 * Wrap the plus/minus icon in a link
509 *
510 * @param string HTML string to wrap, probably an image tag.
511 * @param string Command for 'PM' get var
512 * @param boolean If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
513 * @return string Link-wrapped input string
514 * @access private
515 */
516 function PM_ATagWrap($icon,$cmd,$bMark='') {
517 if ($bMark) {
518 $anchor = '#'.$bMark;
519 $name=' name="'.$bMark.'"';
520 }
521 $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?PM='.$cmd.'\',\''.$anchor.'\');';
522 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
523 }
524
525 /**
526 * Create the folder navigation tree in HTML
527 *
528 * @param mixed Input tree array. If not array, then $this->tree is used.
529 * @return string HTML output of the tree.
530 */
531 function printTree($treeArr='') {
532 global $BACK_PATH;
533 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
534
535 if (!is_array($treeArr)) $treeArr=$this->tree;
536
537 $out='';
538 $c=0;
539
540 // Preparing the current-path string (if found in the listing we will see a red blinking arrow).
541 if (!$GLOBALS['SOBE']->browser->curUrlInfo['value']) {
542 $cmpPath='';
543 } else if (substr(trim($GLOBALS['SOBE']->browser->curUrlInfo['info']),-1)!='/') {
544 $cmpPath=PATH_site.dirname($GLOBALS['SOBE']->browser->curUrlInfo['info']).'/';
545 } else {
546 $cmpPath=PATH_site.$GLOBALS['SOBE']->browser->curUrlInfo['info'];
547 }
548
549 // Traverse rows for the tree and print them into table rows:
550 foreach($treeArr as $k => $v) {
551 $c++;
552 $bgColorClass=($c+1)%2 ? 'bgColor' : 'bgColor-10';
553
554 // Creating blinking arrow, if applicable:
555 if (($GLOBALS['SOBE']->browser->curUrlInfo['act'] == 'file' || $GLOBALS['SOBE']->browser->curUrlInfo['act'] == 'folder') && $cmpPath == $v['row']['path']) {
556 $arrCol='<td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
557 $bgColorClass='bgColor4';
558 } else {
559 $arrCol='<td></td>';
560 }
561 // Create arrow-bullet for file listing (if folder path is linkable):
562 $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandFolder='.rawurlencode($v['row']['path']).'\');';
563 $cEbullet = $this->ext_isLinkable($v['row']) ? '<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/arrowbullet.gif','width="18" height="16"').' alt="" /></a>' : '';
564
565 // Put table row with folder together:
566 $out.='
567 <tr class="'.$bgColorClass.'">
568 <td nowrap="nowrap">'.$v['HTML'].$this->wrapTitle(t3lib_div::fixed_lgd_cs($v['row']['title'],$titleLen),$v['row']).'</td>
569 '.$arrCol.'
570 <td>'.$cEbullet.'</td>
571 </tr>';
572 }
573
574 $out='
575
576 <!--
577 Folder tree:
578 -->
579 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
580 '.$out.'
581 </table>';
582 return $out;
583 }
584 }
585
586
587
588
589
590
591 /**
592 * Folder tree for the RTE - totally the same, no changes needed. (Just for the sake of beauty - or confusion... :-)
593 *
594 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
595 * @package TYPO3
596 * @subpackage core
597 */
598 class rteFolderTree extends localFolderTree {
599 }
600
601
602
603
604
605
606
607 /**
608 * For TBE File Browser
609 *
610 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
611 * @package TYPO3
612 * @subpackage core
613 */
614 class TBE_FolderTree extends localFolderTree {
615 var $ext_noTempRecyclerDirs=0; // If file-drag mode is set, temp and recycler folders are filtered out.
616
617 /**
618 * Returns true if the input "record" contains a folder which can be linked.
619 *
620 * @param array Array with information about the folder element. Contains keys like title, uid, path, _title
621 * @return boolean True is returned if the path is NOT a recycler or temp folder AND if ->ext_noTempRecyclerDirs is not set.
622 */
623 function ext_isLinkable($v) {
624 if ($this->ext_noTempRecyclerDirs && (substr($v['path'],-7)=='_temp_/' || substr($v['path'],-11)=='_recycler_/')) {
625 return 0;
626 } return 1;
627 }
628
629 /**
630 * Wrapping the title in a link, if applicable.
631 *
632 * @param string Title, ready for output.
633 * @param array The 'record'
634 * @return string Wrapping title string.
635 */
636 function wrapTitle($title,$v) {
637 if ($this->ext_isLinkable($v)) {
638 $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandFolder='.rawurlencode($v['path']).'\');';
639 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
640 } else {
641 return '<span class="typo3-dimmed">'.$title.'</span>';
642 }
643 }
644 }
645
646
647
648
649
650 /**
651 * class for the Element Browser window.
652 *
653 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
654 * @package TYPO3
655 * @subpackage core
656 */
657 class browse_links {
658
659 // Internal, static:
660 var $siteURL; // Current site URL (Frontend)
661 var $thisScript; // the script to link to
662 var $thisConfig; // RTE specific TSconfig
663 var $setTarget; // Target (RTE specific)
664 var $setClass; // CSS Class (RTE specific)
665 var $setTitle; // title (RTE specific)
666 var $doc; // Backend template object
667 var $elements = array(); // Holds information about files
668
669 // GPvars: (Input variables from outside)
670 /**
671 * The mode determines the main kind of output from the element browser.
672 * There are these options for values: rte, db, file, filedrag, wizard.
673 * "rte" will show the link selector for the Rich Text Editor (see main_rte())
674 * "db" will allow you to browse for pages or records in the page tree (for TCEforms, see main_db())
675 * "file"/"filedrag" will allow you to browse for files or folders in the folder mounts (for TCEforms, main_file())
676 * "wizard" will allow you to browse for links (like "rte") which are passed back to TCEforms (see main_rte(1))
677 *
678 * @see main()
679 */
680 var $mode;
681
682 /**
683 * Link selector action.
684 * page,file,url,mail,spec are allowed values.
685 * These are only important with the link selector function and in that case they switch between the various menu options.
686 */
687 var $act;
688
689 /**
690 * 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")
691 */
692 var $expandPage;
693
694 /**
695 * 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/"
696 */
697 var $expandFolder;
698
699
700
701 /**
702 * TYPO3 Element Browser, wizard mode parameters. There is a heap of parameters there, better debug() them out if you need something... :-)
703 */
704 var $P;
705
706 /**
707 * 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.
708 * Example value: "data[pages][39][bodytext]|||tt_content|" or "data[tt_content][NEW3fba56fde763d][image]|||gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai|"
709 *
710 * Values:
711 * 0: form field name reference, eg. "data[tt_content][123][image]"
712 * 1: old/unused?
713 * 2: old/unused?
714 * 3: allowed types. Eg. "tt_content" or "gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai"
715 * 4: IRRE uniqueness: target level object-id to perform actions/checks on, eg. "data[79][tt_address][1][<field>][<foreign_table>]"
716 * 5: IRRE uniqueness: name of function in opener window that checks if element is already used, eg. "inline.checkUniqueElement"
717 * 6: IRRE uniqueness: name of function in opener window that performs some additional(!) action, eg. "inline.setUniqueElement"
718 * 7: IRRE uniqueness: name of function in opener window that performs action instead of using addElement/insertElement, eg. "inline.importElement"
719 *
720 * $pArr = explode('|',$this->bparams);
721 * $formFieldName = $pArr[0];
722 * $allowedTablesOrFileTypes = $pArr[3];
723 */
724 var $bparams;
725
726 /**
727 * Used with the Rich Text Editor.
728 * Example value: "tt_content:NEW3fba58c969f5c:bodytext:23:text:23:"
729 */
730 var $RTEtsConfigParams;
731
732
733
734
735 /**
736 * Plus/Minus icon value. Used by the tree class to open/close notes on the trees.
737 */
738 var $PM;
739
740 /**
741 * Pointer, used when browsing a long list of records etc.
742 */
743 var $pointer;
744
745
746
747
748 /**
749 * Used with the link selector: Contains the GET input information about the CURRENT link in the RTE/TCEform field. This consists of "href", "target" and "title" keys. This information is passed around in links.
750 */
751 var $curUrlArray;
752
753 /**
754 * 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.
755 */
756 var $curUrlInfo;
757
758 /**
759 * array which holds hook objects (initialised in init() )
760 */
761 protected $hookObjects;
762
763
764 var $readOnly = FALSE; // If set, all operations that changes something should be disabled. This is used for alternativeBrowsing file mounts (see options like "options.folderTree.altElementBrowserMountPoints" in browse_links.php).
765
766
767 /**
768 * Constructor:
769 * Initializes a lot of variables, setting JavaScript functions in header etc.
770 *
771 * @return void
772 */
773 function init() {
774 global $BE_USER,$BACK_PATH;
775
776 // Main GPvars:
777 $this->pointer = t3lib_div::_GP('pointer');
778 $this->bparams = t3lib_div::_GP('bparams');
779 $this->P = t3lib_div::_GP('P');
780 $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
781 $this->expandPage = t3lib_div::_GP('expandPage');
782 $this->expandFolder = t3lib_div::_GP('expandFolder');
783 $this->PM = t3lib_div::_GP('PM');
784
785 // Find "mode"
786 $this->mode = t3lib_div::_GP('mode');
787 if (!$this->mode) {
788 $this->mode = 'rte';
789 }
790
791 // init hook objects:
792 $this->hookObjects = array();
793 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'])) {
794 foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'] as $classData) {
795 $processObject = &t3lib_div::getUserObj($classData);
796
797 if(!($processObject instanceof t3lib_browseLinksHook)) {
798 throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195039394);
799 }
800
801 $parameters = array();
802 $processObject->init($this, $parameters);
803 $this->hookObjects[] = $processObject;
804 }
805 }
806
807 // Site URL
808 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL'); // Current site url
809
810 // the script to link to
811 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
812
813 // CurrentUrl - the current link url must be passed around if it exists
814 if ($this->mode == 'wizard') {
815 $currentLinkParts = t3lib_div::trimExplode(' ',$this->P['currentValue']);
816 $initialCurUrlArray = array (
817 'href' => $currentLinkParts[0],
818 'target' => $currentLinkParts[1],
819 'class' => $currentLinkParts[2],
820 'title' => $currentLinkParts[3],
821 );
822 $this->curUrlArray = (is_array(t3lib_div::_GP('curUrl'))) ?
823 array_merge($initialCurUrlArray, t3lib_div::_GP('curUrl')) :
824 $initialCurUrlArray;
825 $this->curUrlInfo = $this->parseCurUrl($this->siteURL.'?id='.$this->curUrlArray['href'], $this->siteURL);
826 if ($this->curUrlInfo['pageid'] == 0 && $this->curUrlArray['href']) { // pageid == 0 means that this is not an internal (page) link
827 if (@file_exists(PATH_site.rawurldecode($this->curUrlArray['href']))) { // check if this is a link to a file
828 if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], PATH_site)) {
829 $currentLinkParts[0] = substr($this->curUrlArray['href'], strlen(PATH_site));
830 }
831 $this->curUrlInfo = $this->parseCurUrl($this->siteURL.$this->curUrlArray['href'], $this->siteURL);
832 } elseif (strstr($this->curUrlArray['href'], '@')) { // check for email link
833 if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], 'mailto:')) {
834 $currentLinkParts[0] = substr($this->curUrlArray['href'], 7);
835 }
836 $this->curUrlInfo = $this->parseCurUrl('mailto:'.$this->curUrlArray['href'], $this->siteURL);
837 } else { // nothing of the above. this is an external link
838 if(strpos($this->curUrlArray['href'], '://') === false) {
839 $currentLinkParts[0] = 'http://' . $this->curUrlArray['href'];
840 }
841 $this->curUrlInfo = $this->parseCurUrl($currentLinkParts[0], $this->siteURL);
842 }
843 } elseif (!$this->curUrlArray['href']) {
844 $this->curUrlInfo = array();
845 $this->act = 'page';
846 } else {
847 $this->curUrlInfo = $this->parseCurUrl($this->siteURL.'?id='.$this->curUrlArray['href'], $this->siteURL);
848 }
849 } else {
850 $this->curUrlArray = t3lib_div::_GP('curUrl');
851 if ($this->curUrlArray['all']) {
852 $this->curUrlArray=t3lib_div::get_tag_attributes($this->curUrlArray['all']);
853 }
854 $this->curUrlInfo=$this->parseCurUrl($this->curUrlArray['href'],$this->siteURL);
855 }
856
857 // Determine nature of current url:
858 $this->act=t3lib_div::_GP('act');
859 if (!$this->act) {
860 $this->act=$this->curUrlInfo['act'];
861 }
862
863 // Rich Text Editor specific configuration:
864 $addPassOnParams='';
865 if ((string)$this->mode == 'rte') {
866 $RTEtsConfigParts = explode(':',$this->RTEtsConfigParams);
867 $addPassOnParams.='&RTEtsConfigParams='.rawurlencode($this->RTEtsConfigParams);
868 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
869 $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
870 }
871
872 // Initializing the target value (RTE)
873 $this->setTarget = ($this->curUrlArray['target'] != '-') ? $this->curUrlArray['target'] : '';
874 if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target'])) {
875 $this->setTarget=$this->thisConfig['defaultLinkTarget'];
876 }
877
878 // Initializing the class value (RTE)
879 $this->setClass = ($this->curUrlArray['class'] != '-') ? $this->curUrlArray['class'] : '';
880
881 // Initializing the title value (RTE)
882 $this->setTitle = ($this->curUrlArray['title'] != '-') ? $this->curUrlArray['title'] : '';
883
884 // Creating backend template object:
885 $this->doc = t3lib_div::makeInstance('template');
886 $this->doc->docType= 'xhtml_trans';
887 $this->doc->backPath = $BACK_PATH;
888
889 // BEGIN accumulation of header JavaScript:
890 $JScode = '';
891 $JScode.= '
892 // This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
893 var add_href="'.($this->curUrlArray['href']?'&curUrl[href]='.rawurlencode($this->curUrlArray['href']):'').'";
894 var add_target="'.($this->setTarget?'&curUrl[target]='.rawurlencode($this->setTarget):'').'";
895 var add_class="'.($this->setClass ? '&curUrl[class]='.rawurlencode($this->setClass) : '').'";
896 var add_title="'.($this->setTitle?'&curUrl[title]='.rawurlencode($this->setTitle):'').'";
897 var add_params="'.($this->bparams?'&bparams='.rawurlencode($this->bparams):'').'";
898
899 var cur_href="'.($this->curUrlArray['href']?$this->curUrlArray['href']:'').'";
900 var cur_target="'.($this->setTarget?$this->setTarget:'').'";
901 var cur_class = "'.($this->setClass ? $this->setClass : '-').'";
902 var cur_title="'.($this->setTitle?$this->setTitle:'').'";
903
904 function browse_links_setTarget(target) { //
905 cur_target=target;
906 add_target="&curUrl[target]="+escape(target);
907 }
908 function browse_links_setClass(cssClass) { //
909 cur_class = cssClass;
910 add_class = "&curUrl[class]=" + escape(cssClass);
911 }
912 function browse_links_setTitle(title) { //
913 cur_title=title;
914 add_title="&curUrl[title]="+escape(title);
915 }
916 function browse_links_setValue(value) { //
917 cur_href=value;
918 add_href="&curUrl[href]="+value;
919 }
920 ';
921
922 if ($this->mode == 'wizard') { // Functions used, if the link selector is in wizard mode (= TCEforms fields)
923 unset($this->P['fieldChangeFunc']['alert']);
924 reset($this->P['fieldChangeFunc']);
925 $update='';
926 while(list($k,$v)=each($this->P['fieldChangeFunc'])) {
927 $update.= '
928 window.opener.'.$v;
929 }
930
931 $P2=array();
932 $P2['itemName']=$this->P['itemName'];
933 $P2['formName']=$this->P['formName'];
934 $P2['fieldChangeFunc']=$this->P['fieldChangeFunc'];
935 $P2['params']['allowedExtensions']=$this->P['params']['allowedExtensions'];
936 $P2['params']['blindLinkOptions']=$this->P['params']['blindLinkOptions'];
937 $addPassOnParams.=t3lib_div::implodeArrayForUrl('P',$P2);
938
939 $JScode.='
940 function link_typo3Page(id,anchor) { //
941 updateValueInMainForm(id + (anchor ? anchor : ""));
942 close();
943 return false;
944 }
945 function link_folder(folder) { //
946 updateValueInMainForm(folder);
947 close();
948 return false;
949 }
950 function link_current() { //
951 if (cur_href!="http://" && cur_href!="mailto:") {
952 returnBeforeCleaned = cur_href;
953 if (returnBeforeCleaned.substr(0, 7) == "http://") {
954 returnToMainFormValue = returnBeforeCleaned.substr(7);
955 } else if (returnBeforeCleaned.substr(0, 7) == "mailto:") {
956 if (returnBeforeCleaned.substr(0, 14) == "mailto:mailto:") {
957 returnToMainFormValue = returnBeforeCleaned.substr(14);
958 } else {
959 returnToMainFormValue = returnBeforeCleaned.substr(7);
960 }
961 } else {
962 returnToMainFormValue = returnBeforeCleaned;
963 }
964 updateValueInMainForm(returnToMainFormValue);
965 close();
966 }
967 return false;
968 }
969 function checkReference() { //
970 if (window.opener && window.opener.document && window.opener.document.'.$this->P['formName'].' && window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"] ) {
971 return window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"];
972 } else {
973 close();
974 }
975 }
976 function updateValueInMainForm(input) { //
977 var field = checkReference();
978 if (field) {
979 if (cur_target == "" && (cur_title != "" || cur_class != "-")) {
980 cur_target = "-";
981 }
982 if (cur_title == "" && cur_class == "-") {
983 cur_class = "";
984 }
985 input = input + " " + cur_target + " " + cur_class + " " + cur_title;
986 field.value = input;
987 '.$update.'
988 }
989 }
990 ';
991 } else { // Functions used, if the link selector is in RTE mode:
992 $JScode.='
993 function link_typo3Page(id,anchor) { //
994 var theLink = \''.$this->siteURL.'?id=\'+id+(anchor?anchor:"");
995 self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
996 return false;
997 }
998 function link_folder(folder) { //
999 var theLink = \''.$this->siteURL.'\'+folder;
1000 self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
1001 return false;
1002 }
1003 function link_spec(theLink) { //
1004 self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
1005 return false;
1006 }
1007 function link_current() { //
1008 if (cur_href!="http://" && cur_href!="mailto:") {
1009 self.parent.parent.renderPopup_addLink(cur_href, cur_target, cur_class, cur_title);
1010 }
1011 return false;
1012 }
1013 ';
1014 }
1015
1016 // General "jumpToUrl" function:
1017 $JScode.='
1018 function jumpToUrl(URL,anchor) { //
1019 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
1020 var add_mode = URL.indexOf("mode=")==-1 ? "&mode='.$this->mode.'" : "";
1021 var theLocation = URL + add_act + add_mode + add_href + add_target + add_class + add_title + add_params'.($addPassOnParams?'+"'.$addPassOnParams.'"':'').'+(anchor?anchor:"");
1022 window.location.href = theLocation;
1023 return false;
1024 }
1025 ';
1026
1027
1028 /**
1029 * Splits parts of $this->bparams
1030 * @see $bparams
1031 */
1032 $pArr = explode('|',$this->bparams);
1033
1034 // This is JavaScript especially for the TBE Element Browser!
1035 $formFieldName = 'data['.$pArr[0].']['.$pArr[1].']['.$pArr[2].']';
1036
1037 // insertElement - Call check function (e.g. for uniqueness handling):
1038 if ($pArr[4] && $pArr[5]) {
1039 $JScodeCheck = '
1040 // Call a check function in the opener window (e.g. for uniqueness handling):
1041 if (parent.window.opener) {
1042 var res = parent.window.opener.'.$pArr[5].'("'.addslashes($pArr[4]).'",table,uid,type);
1043 if (!res.passed) {
1044 if (res.message) alert(res.message);
1045 performAction = false;
1046 }
1047 } else {
1048 alert("Error - reference to main window is not set properly!");
1049 parent.close();
1050 }
1051 ';
1052 }
1053 // insertElement - Call helper function:
1054 if ($pArr[4] && $pArr[6]) {
1055 $JScodeHelper = '
1056 // Call helper function to manage data in the opener window:
1057 if (parent.window.opener) {
1058 parent.window.opener.'.$pArr[6].'("'.addslashes($pArr[4]).'",table,uid,type,"'.addslashes($pArr[0]).'");
1059 } else {
1060 alert("Error - reference to main window is not set properly!");
1061 parent.close();
1062 }
1063 ';
1064 }
1065 // insertElement - perform action commands:
1066 if ($pArr[4] && $pArr[7]) {
1067 // Call user defined action function:
1068 $JScodeAction = '
1069 if (parent.window.opener) {
1070 parent.window.opener.'.$pArr[7].'("'.addslashes($pArr[4]).'",table,uid,type);
1071 focusOpenerAndClose(close);
1072 } else {
1073 alert("Error - reference to main window is not set properly!");
1074 parent.close();
1075 }
1076 ';
1077 } else if ($pArr[0] && !$pArr[1] && !$pArr[2]) {
1078 $JScodeAction = '
1079 addElement(filename,table+"_"+uid,fp,close);
1080 ';
1081 } else {
1082 $JScodeAction = '
1083 if (setReferences()) {
1084 parent.window.opener.group_change("add","'.$pArr[0].'","'.$pArr[1].'","'.$pArr[2].'",elRef,targetDoc);
1085 } else {
1086 alert("Error - reference to main window is not set properly!");
1087 }
1088 focusOpenerAndClose(close);
1089 ';
1090 }
1091
1092 $JScode.='
1093 var elRef="";
1094 var targetDoc="";
1095
1096 function launchView(url) { //
1097 var thePreviewWindow="";
1098 thePreviewWindow = window.open("'.$BACK_PATH.'show_item.php?table="+url,"ShowItem","height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
1099 if (thePreviewWindow && thePreviewWindow.focus) {
1100 thePreviewWindow.focus();
1101 }
1102 }
1103 function setReferences() { //
1104 if (parent.window.opener && parent.window.opener.content && parent.window.opener.content.document.editform && parent.window.opener.content.document.editform["'.$formFieldName.'"]) {
1105 targetDoc = parent.window.opener.content.document;
1106 elRef = targetDoc.editform["'.$formFieldName.'"];
1107 return true;
1108 } else {
1109 return false;
1110 }
1111 }
1112 function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close) { //
1113 var performAction = true;
1114 '.$JScodeCheck.'
1115 // Call performing function and finish this action:
1116 if (performAction) {
1117 '.$JScodeHelper.$JScodeAction.'
1118 }
1119 return false;
1120 }
1121 function addElement(elName,elValue,altElValue,close) { //
1122 if (parent.window.opener && parent.window.opener.setFormValueFromBrowseWin) {
1123 parent.window.opener.setFormValueFromBrowseWin("'.$pArr[0].'",altElValue?altElValue:elValue,elName);
1124 focusOpenerAndClose(close);
1125 } else {
1126 alert("Error - reference to main window is not set properly!");
1127 parent.close();
1128 }
1129 }
1130 function focusOpenerAndClose(close) { //
1131 BrowseLinks.focusOpenerAndClose(close);
1132 }
1133 ';
1134
1135 // Finally, add the accumulated JavaScript to the template object:
1136 $this->doc->JScode = '<script type="text/javascript" src="contrib/prototype/prototype.js"></script>'."\n";
1137 $this->doc->JScode.= '<script type="text/javascript" src="js/browse_links.js"></script>'."\n";
1138 $this->doc->JScode.= $this->doc->wrapScriptTags($JScode);
1139
1140 // Debugging:
1141 if (FALSE) debug(array(
1142 'pointer' => $this->pointer,
1143 'act' => $this->act,
1144 'mode' => $this->mode,
1145 'curUrlInfo' => $this->curUrlInfo,
1146 'curUrlArray' => $this->curUrlArray,
1147 'P' => $this->P,
1148 'bparams' => $this->bparams,
1149 'RTEtsConfigParams' => $this->RTEtsConfigParams,
1150 'expandPage' => $this->expandPage,
1151 'expandFolder' => $this->expandFolder,
1152 'PM' => $this->PM,
1153 ),'Internal variables of Script Class:');
1154 }
1155
1156
1157 /**
1158 * Session data for this class can be set from outside with this method.
1159 * Call after init()
1160 *
1161 * @param array Session data array
1162 * @return array Session data and boolean which indicates that data needs to be stored in session because it's changed
1163 */
1164 function processSessionData($data) {
1165 $store = false;
1166
1167 switch((string)$this->mode) {
1168 case 'db':
1169 if (isset($this->expandPage)) {
1170 $data['expandPage']=$this->expandPage;
1171 $store = true;
1172 } else {
1173 $this->expandPage=$data['expandPage'];
1174 }
1175 break;
1176 case 'file':
1177 case 'filedrag':
1178 case 'folder':
1179 if (isset($this->expandFolder)) {
1180 $data['expandFolder']=$this->expandFolder;
1181 $store = true;
1182 } else {
1183 $this->expandFolder=$data['expandFolder'];
1184 }
1185 break;
1186 }
1187
1188 return array($data, $store);
1189 }
1190
1191
1192
1193
1194 /******************************************************************
1195 *
1196 * Main functions
1197 *
1198 ******************************************************************/
1199
1200 /**
1201 * Rich Text Editor (RTE) link selector (MAIN function)
1202 * Generates the link selector for the Rich Text Editor.
1203 * Can also be used to select links for the TCEforms (see $wiz)
1204 *
1205 * @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
1206 * @return string Modified content variable.
1207 */
1208 function main_rte($wiz=0) {
1209 global $LANG, $BACK_PATH;
1210
1211 // Starting content:
1212 $content=$this->doc->startPage('RTE link');
1213
1214 // Initializing the action value, possibly removing blinded values etc:
1215 $allowedItems = array_diff(
1216 explode(',','page,file,folder,url,mail,spec'),
1217 t3lib_div::trimExplode(',',$this->thisConfig['blindLinkOptions'],1)
1218 );
1219 $allowedItems = array_diff(
1220 $allowedItems,
1221 t3lib_div::trimExplode(',',$this->P['params']['blindLinkOptions'])
1222 );
1223
1224 //call hook for extra options
1225 foreach($this->hookObjects as $hookObject) {
1226 $allowedItems = $hookObject->addAllowedItems($allowedItems);
1227 }
1228
1229 reset($allowedItems);
1230 if (!in_array($this->act,$allowedItems)) $this->act = current($allowedItems);
1231
1232 // Making menu in top:
1233 $menuDef = array();
1234 if (!$wiz) {
1235 $menuDef['removeLink']['isActive'] = $this->act=='removeLink';
1236 $menuDef['removeLink']['label'] = $LANG->getLL('removeLink',1);
1237 $menuDef['removeLink']['url'] = '#';
1238 $menuDef['removeLink']['addParams'] = 'onclick="self.parent.parent.renderPopup_unLink();return false;"';
1239 }
1240 if (in_array('page',$allowedItems)) {
1241 $menuDef['page']['isActive'] = $this->act=='page';
1242 $menuDef['page']['label'] = $LANG->getLL('page',1);
1243 $menuDef['page']['url'] = '#';
1244 $menuDef['page']['addParams'] = 'onclick="jumpToUrl(\'?act=page\');return false;"';
1245 }
1246 if (in_array('file',$allowedItems)){
1247 $menuDef['file']['isActive'] = $this->act=='file';
1248 $menuDef['file']['label'] = $LANG->getLL('file',1);
1249 $menuDef['file']['url'] = '#';
1250 $menuDef['file']['addParams'] = 'onclick="jumpToUrl(\'?act=file\');return false;"';
1251 }
1252 if (in_array('folder',$allowedItems)){
1253 $menuDef['folder']['isActive'] = $this->act == 'folder';
1254 $menuDef['folder']['label'] = $LANG->getLL('folder', 1);
1255 $menuDef['folder']['url'] = '#';
1256 $menuDef['folder']['addParams'] = 'onclick="jumpToUrl(\'?act=folder\');return false;"';
1257 }
1258 if (in_array('url',$allowedItems)) {
1259 $menuDef['url']['isActive'] = $this->act=='url';
1260 $menuDef['url']['label'] = $LANG->getLL('extUrl',1);
1261 $menuDef['url']['url'] = '#';
1262 $menuDef['url']['addParams'] = 'onclick="jumpToUrl(\'?act=url\');return false;"';
1263 }
1264 if (in_array('mail',$allowedItems)) {
1265 $menuDef['mail']['isActive'] = $this->act=='mail';
1266 $menuDef['mail']['label'] = $LANG->getLL('email',1);
1267 $menuDef['mail']['url'] = '#';
1268 $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(\'?act=mail\');return false;"';
1269 }
1270 if (is_array($this->thisConfig['userLinks.']) && in_array('spec',$allowedItems)) {
1271 $menuDef['spec']['isActive'] = $this->act=='spec';
1272 $menuDef['spec']['label'] = $LANG->getLL('special',1);
1273 $menuDef['spec']['url'] = '#';
1274 $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(\'?act=spec\');return false;"';
1275 }
1276
1277 // call hook for extra options
1278 foreach($this->hookObjects as $hookObject) {
1279 $menuDef = $hookObject->modifyMenuDefinition($menuDef);
1280 }
1281
1282 $content .= $this->doc->getTabMenuRaw($menuDef);
1283
1284 // Adding the menu and header to the top of page:
1285 $content.=$this->printCurrentUrl($this->curUrlInfo['info']).'<br />';
1286
1287 // Depending on the current action we will create the actual module content for selecting a link:
1288 switch($this->act) {
1289 case 'mail':
1290 $extUrl='
1291
1292 <!--
1293 Enter mail address:
1294 -->
1295 <form action="" name="lurlform" id="lurlform">
1296 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
1297 <tr>
1298 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('emailAddress', 1) . ':</td>
1299 <td><input type="text" name="lemail"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='mail'?$this->curUrlInfo['info']:'').'" /> '.
1300 '<input type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', 1) . '" onclick="browse_links_setTarget(\'\');browse_links_setValue(\'mailto:\'+document.lurlform.lemail.value); return link_current();" /></td>
1301 </tr>
1302 </table>
1303 </form>';
1304 $content.=$extUrl;
1305 break;
1306 case 'url':
1307 $extUrl='
1308
1309 <!--
1310 Enter External URL:
1311 -->
1312 <form action="" name="lurlform" id="lurlform">
1313 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
1314 <tr>
1315 <td style="width: 96px;">URL:</td>
1316 <td><input type="text" name="lurl"'.$this->doc->formWidth(30).' value="'.htmlspecialchars($this->curUrlInfo['act']=='url'?$this->curUrlInfo['info']:'http://').'" /> '.
1317 '<input type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', 1) . '" onclick="browse_links_setValue(document.lurlform.lurl.value); return link_current();" /></td>
1318 </tr>
1319 </table>
1320 </form>';
1321 $content.=$extUrl;
1322 break;
1323 case 'file':
1324 case 'folder':
1325 $foldertree = t3lib_div::makeInstance('rteFolderTree');
1326 $foldertree->thisScript = $this->thisScript;
1327 $tree = $foldertree->getBrowsableTree();
1328
1329 if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act'] != $this->act) {
1330 $cmpPath = '';
1331 } elseif (substr(trim($this->curUrlInfo['info']), -1) != '/') {
1332 $cmpPath = PATH_site.dirname($this->curUrlInfo['info']).'/';
1333 if (!isset($this->expandFolder)) {
1334 $this->expandFolder = $cmpPath;
1335 }
1336 } else {
1337 $cmpPath = PATH_site.$this->curUrlInfo['info'];
1338 if (!isset($this->expandFolder) && $this->curUrlInfo['act'] == 'folder') {
1339 $this->expandFolder = $cmpPath;
1340 }
1341 }
1342
1343 list(, , $specUid) = explode('_', $this->PM);
1344 $files = $this->expandFolder(
1345 $foldertree->specUIDmap[$specUid],
1346 $this->P['params']['allowedExtensions']
1347 );
1348 $content.= '
1349
1350 <!--
1351 Wrapper table for folder tree / file/folder list:
1352 -->
1353 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
1354 <tr>
1355 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1356 <td class="c-wCell" valign="top">'.$files.'</td>
1357 </tr>
1358 </table>
1359 ';
1360 break;
1361 case 'spec':
1362 if (is_array($this->thisConfig['userLinks.'])) {
1363 $subcats=array();
1364 $v=$this->thisConfig['userLinks.'];
1365 reset($v);
1366 while(list($k2)=each($v)) {
1367 $k2i = intval($k2);
1368 if (substr($k2,-1)=='.' && is_array($v[$k2i.'.'])) {
1369
1370 // Title:
1371 $title = trim($v[$k2i]);
1372 if (!$title) {
1373 $title=$v[$k2i.'.']['url'];
1374 } else {
1375 $title=$LANG->sL($title);
1376 }
1377 // Description:
1378 $description=$v[$k2i.'.']['description'] ? $LANG->sL($v[$k2i.'.']['description'],1).'<br />' : '';
1379
1380 // URL + onclick event:
1381 $onClickEvent='';
1382 if (isset($v[$k2i.'.']['target'])) $onClickEvent.="browse_links_setTarget('".$v[$k2i.'.']['target']."');";
1383 $v[$k2i.'.']['url'] = str_replace('###_URL###',$this->siteURL,$v[$k2i.'.']['url']);
1384 if (substr($v[$k2i.'.']['url'],0,7)=='http://' || substr($v[$k2i.'.']['url'],0,7)=='mailto:') {
1385 $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i.'.']['url'])."');link_current();";
1386 } else {
1387 $onClickEvent.="link_spec(unescape('".$this->siteURL.rawurlencode($v[$k2i.'.']['url'])."'));";
1388 }
1389
1390 // Link:
1391 $A=array('<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">','</a>');
1392
1393 // Adding link to menu of user defined links:
1394 $subcats[$k2i]='
1395 <tr>
1396 <td class="bgColor4">'.$A[0].'<strong>'.htmlspecialchars($title).($this->curUrlInfo['info']==$v[$k2i.'.']['url']?'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" />':'').'</strong><br />'.$description.$A[1].'</td>
1397 </tr>';
1398 }
1399 }
1400
1401 // Sort by keys:
1402 ksort($subcats);
1403
1404 // Add menu to content:
1405 $content.= '
1406
1407 <!--
1408 Special userdefined menu:
1409 -->
1410 <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
1411 <tr>
1412 <td class="bgColor5" class="c-wCell" valign="top"><strong>'.$LANG->getLL('special',1).'</strong></td>
1413 </tr>
1414 '.implode('',$subcats).'
1415 </table>
1416 ';
1417 }
1418 break;
1419 case 'page':
1420 $pagetree = t3lib_div::makeInstance('rtePageTree');
1421 $pagetree->thisScript = $this->thisScript;
1422 $tree=$pagetree->getBrowsableTree();
1423 $cElements = $this->expandPage();
1424 $content.= '
1425
1426 <!--
1427 Wrapper table for page tree / record list:
1428 -->
1429 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
1430 <tr>
1431 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('pageTree').':').$tree.'</td>
1432 <td class="c-wCell" valign="top">'.$cElements.'</td>
1433 </tr>
1434 </table>
1435 ';
1436 break;
1437 default:
1438 //call hook
1439 foreach($this->hookObjects as $hookObject) {
1440 $content .= $hookObject->getTab($this->act);
1441 }
1442 break;
1443 }
1444
1445 $content .= '
1446
1447 <!--
1448 Selecting class for link:
1449 -->
1450 <form action="" name="lclassform" id="lclassform">
1451 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkClass">
1452 <tr>
1453 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('class', 1) . '</td>
1454 <td><input type="text" name="lclass" onchange="browse_links_setClass(this.value);" value="' . htmlspecialchars($this->setClass) . '"' . $this->doc->formWidth(10) . ' /></td>
1455 </tr>
1456 </table>
1457 </form>
1458
1459 <!--
1460 Selecting title for link:
1461 -->
1462 <form action="" name="ltitleform" id="ltitleform">
1463 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTitle">
1464 <tr>
1465 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('title', 1) . '</td>
1466 <td><input type="text" name="ltitle" onchange="browse_links_setTitle(this.value);" value="' . htmlspecialchars($this->setTitle) . '"' . $this->doc->formWidth(10) . ' /></td>
1467 </tr>
1468 </table>
1469 </form>
1470 ';
1471
1472 // Target:
1473 if ($this->act!='mail') {
1474 $ltarget='
1475
1476
1477
1478 <!--
1479 Selecting target for link:
1480 -->
1481 <form action="" name="ltargetform" id="ltargetform">
1482 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
1483 <tr>
1484 <td>'.$GLOBALS['LANG']->getLL('target',1).':</td>
1485 <td><input type="text" name="ltarget" onchange="browse_links_setTarget(this.value);" value="' . htmlspecialchars($this->setTarget) . '"' . $this->doc->formWidth(10) . ' /></td>
1486 <td>
1487 <select name="ltarget_type" onchange="browse_links_setTarget(this.options[this.selectedIndex].value);document.ltargetform.ltarget.value=this.options[this.selectedIndex].value;this.selectedIndex=0;">
1488 <option></option>
1489 <option value="_top">'.$GLOBALS['LANG']->getLL('top',1).'</option>
1490 <option value="_blank">'.$GLOBALS['LANG']->getLL('newWindow',1).'</option>
1491 </select>
1492 </td>
1493 <td>';
1494 if (($this->curUrlInfo['act'] == 'page' || $this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder') && $this->curUrlArray['href'] && $this->curUrlInfo['act'] == $this->act) {
1495 $ltarget.='
1496 <input type="submit" value="'.$GLOBALS['LANG']->getLL('update',1).'" onclick="return link_current();" />';
1497 }
1498
1499 $selectJS = '
1500 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) {
1501 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;
1502 browse_links_setTarget(document.ltargetform.ltarget.value);
1503 browse_links_setClass(document.lclassform.lclass.value);
1504 browse_links_setTitle(document.ltitleform.ltitle.value);
1505 document.ltargetform.popup_width.selectedIndex=0;
1506 document.ltargetform.popup_height.selectedIndex=0;
1507 }
1508 ';
1509
1510 $ltarget.=' </td>
1511 </tr>
1512 <tr>
1513 <td>'.$GLOBALS['LANG']->getLL('target_popUpWindow',1).':</td>
1514 <td colspan="3">
1515 <select name="popup_width" onchange="'.htmlspecialchars($selectJS).'">
1516 <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_width',1).'</option>
1517 <option value="300">300</option>
1518 <option value="400">400</option>
1519 <option value="500">500</option>
1520 <option value="600">600</option>
1521 <option value="700">700</option>
1522 <option value="800">800</option>
1523 </select>
1524 x
1525 <select name="popup_height" onchange="'.htmlspecialchars($selectJS).'">
1526 <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_height',1).'</option>
1527 <option value="200">200</option>
1528 <option value="300">300</option>
1529 <option value="400">400</option>
1530 <option value="500">500</option>
1531 <option value="600">600</option>
1532 </select>
1533 </td>
1534 </tr>
1535 </table>
1536 </form>';
1537
1538 // Add "target selector" box to content:
1539 $content.=$ltarget;
1540
1541 // Add some space
1542 $content.='<br /><br />';
1543 }
1544
1545 // End page, return content:
1546 $content.= $this->doc->endPage();
1547 $content = $this->doc->insertStylesAndJS($content);
1548 return $content;
1549 }
1550
1551 /**
1552 * TYPO3 Element Browser: Showing a page tree and allows you to browse for records
1553 *
1554 * @return string HTML content for the module
1555 */
1556 function main_db() {
1557
1558 // Starting content:
1559 $content=$this->doc->startPage('TBE record selector');
1560
1561 // Init variable:
1562 $pArr = explode('|',$this->bparams);
1563
1564 // Making the browsable pagetree:
1565 $pagetree = t3lib_div::makeInstance('TBE_PageTree');
1566 $pagetree->thisScript=$this->thisScript;
1567 $pagetree->ext_pArrPages = !strcmp($pArr[3],'pages')?1:0;
1568 $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
1569 $pagetree->addField('nav_title');
1570 $tree=$pagetree->getBrowsableTree();
1571
1572 // Making the list of elements, if applicable:
1573 $cElements = $this->TBE_expandPage($pArr[3]);
1574
1575 // Putting the things together, side by side:
1576 $content.= '
1577
1578 <!--
1579 Wrapper table for page tree / record list:
1580 -->
1581 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBrecords">
1582 <tr>
1583 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('pageTree').':').$tree.'</td>
1584 <td class="c-wCell" valign="top">'.$cElements.'</td>
1585 </tr>
1586 </table>
1587 ';
1588
1589 // Add some space
1590 $content.='<br /><br />';
1591
1592 // End page, return content:
1593 $content.= $this->doc->endPage();
1594 $content = $this->doc->insertStylesAndJS($content);
1595 return $content;
1596 }
1597
1598 /**
1599 * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for files.
1600 *
1601 * @return string HTML content for the module
1602 */
1603 function main_file() {
1604 global $BE_USER;
1605
1606 // Starting content:
1607 $content.=$this->doc->startPage('TBE file selector');
1608
1609 // Init variable:
1610 $pArr = explode('|',$this->bparams);
1611
1612 // Create upload/create folder forms, if a path is given:
1613 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
1614 $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
1615 $path=$this->expandFolder;
1616 if (!$path || !@is_dir($path)) {
1617 $path = $fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
1618 }
1619 if ($path!='/' && @is_dir($path) && !$this->readOnly && count($GLOBALS['FILEMOUNTS'])) {
1620 $uploadForm=$this->uploadForm($path);
1621 $createFolder=$this->createFolder($path);
1622 } else {
1623 $createFolder='';
1624 $uploadForm='';
1625 }
1626 if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) $content.=$uploadForm;
1627
1628 // Getting flag for showing/not showing thumbnails:
1629 $noThumbs = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
1630
1631 if (!$noThumbs) {
1632 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
1633 $_MOD_MENU = array('displayThumbs' => '');
1634 $_MCONF['name']='file_list';
1635 $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']);
1636 $addParams = '&act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
1637 $thumbNailCheck = t3lib_BEfunc::getFuncCheck('','SET[displayThumbs]',$_MOD_SETTINGS['displayThumbs'],$this->thisScript,$addParams,'id="checkDisplayThumbs"').' <label for="checkDisplayThumbs">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.php:displayThumbs',1).'</label>';
1638 } else {
1639 $thumbNailCheck='';
1640 }
1641 $noThumbs = $noThumbs ? $noThumbs : !$_MOD_SETTINGS['displayThumbs'];
1642
1643 // Create folder tree:
1644 $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
1645 $foldertree->thisScript=$this->thisScript;
1646 $foldertree->ext_noTempRecyclerDirs = ($this->mode == 'filedrag');
1647 $tree=$foldertree->getBrowsableTree();
1648
1649 list(,,$specUid) = explode('_',$this->PM);
1650
1651 if ($this->mode=='filedrag') {
1652 $files = $this->TBE_dragNDrop($foldertree->specUIDmap[$specUid],$pArr[3]);
1653 } else {
1654 $files = $this->TBE_expandFolder($foldertree->specUIDmap[$specUid],$pArr[3],$noThumbs);
1655 }
1656
1657 // Putting the parts together, side by side:
1658 $content.= '
1659
1660 <!--
1661 Wrapper table for folder tree / file list:
1662 -->
1663 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
1664 <tr>
1665 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1666 <td class="c-wCell" valign="top">'.$files.'</td>
1667 </tr>
1668 </table>
1669 ';
1670 $content.= $thumbNailCheck;
1671
1672 // Adding create folder + upload forms if applicable:
1673 if (!$BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) $content.=$uploadForm;
1674 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) $content.=$createFolder;
1675
1676 // Add some space
1677 $content.='<br /><br />';
1678
1679 // Setup indexed elements:
1680 $this->doc->JScode.= $this->doc->wrapScriptTags('BrowseLinks.addElements('.t3lib_div::array2json($this->elements).');');
1681 // Ending page, returning content:
1682 $content.= $this->doc->endPage();
1683 $content = $this->doc->insertStylesAndJS($content);
1684
1685 return $content;
1686 }
1687
1688 /**
1689 * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for folders.
1690 *
1691 * @return string HTML content for the module
1692 */
1693 function main_folder() {
1694 global $BE_USER;
1695
1696 // Starting content:
1697 $content = $this->doc->startPage('TBE folder selector');
1698
1699 // Init variable:
1700 $parameters = explode('|', $this->bparams);
1701
1702 // Create upload/create folder forms, if a path is given:
1703 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
1704 $fileProcessor->init(
1705 $GLOBALS['FILEMOUNTS'],
1706 $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']
1707 );
1708
1709 $path = $this->expandFolder;
1710 if(!$path || !@is_dir($path)) {
1711 $path = $fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
1712 }
1713 if($path != '/' && @is_dir($path)) {
1714 $createFolder = $this->createFolder($path);
1715 } else {
1716 $createFolder='';
1717 }
1718
1719 // Create folder tree:
1720 $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
1721 $foldertree->thisScript = $this->thisScript;
1722 $foldertree->ext_noTempRecyclerDirs = ($this->mode == 'filedrag');
1723 $tree = $foldertree->getBrowsableTree(false);
1724
1725 list(, , $specUid) = explode('_', $this->PM);
1726
1727 if($this->mode == 'filedrag') {
1728 $folders = $this->TBE_dragNDrop(
1729 $foldertree->specUIDmap[$specUid],
1730 $parameters[3]
1731 );
1732 } else {
1733 $folders = $this->TBE_expandSubFolders($foldertree->specUIDmap[$specUid]);
1734 }
1735
1736 // Putting the parts together, side by side:
1737 $content.= '
1738
1739 <!--
1740 Wrapper table for folder tree / folder list:
1741 -->
1742 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
1743 <tr>
1744 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1745 <td class="c-wCell" valign="top">'.$folders.'</td>
1746 </tr>
1747 </table>
1748 ';
1749
1750 // Adding create folder if applicable:
1751 if($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
1752 $content .= $createFolder;
1753 }
1754
1755 // Add some space
1756 $content .= '<br /><br />';
1757
1758 // Ending page, returning content:
1759 $content.= $this->doc->endPage();
1760 $content = $this->doc->insertStylesAndJS($content);
1761
1762 return $content;
1763 }
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781 /******************************************************************
1782 *
1783 * Record listing
1784 *
1785 ******************************************************************/
1786 /**
1787 * For RTE: This displays all content elements on a page and lets you create a link to the element.
1788 *
1789 * @return string HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...)
1790 */
1791 function expandPage() {
1792 global $BE_USER, $BACK_PATH;
1793
1794 $out='';
1795 $expPageId = $this->expandPage; // Set page id (if any) to expand
1796
1797 // If there is an anchor value (content element reference) in the element reference, then force an ID to expand:
1798 if (!$this->expandPage && $this->curUrlInfo['cElement']) {
1799 $expPageId = $this->curUrlInfo['pageid']; // Set to the current link page id.
1800 }
1801
1802 // Draw the record list IF there is a page id to expand:
1803 if ($expPageId && t3lib_div::testInt($expPageId) && $BE_USER->isInWebMount($expPageId)) {
1804
1805 // Set header:
1806 $out.=$this->barheader($GLOBALS['LANG']->getLL('contentElements').':');
1807
1808 // Create header for listing, showing the page title/icon:
1809 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1810 $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages',$expPageId);
1811 $picon=t3lib_iconWorks::getIconImage('pages',$mainPageRec,'','');
1812 $picon.= htmlspecialchars(t3lib_div::fixed_lgd_cs($mainPageRec['title'],$titleLen));
1813 $out.=$picon.'<br />';
1814
1815 // Look up tt_content elements from the expanded page:
1816 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1817 'uid,header,hidden,starttime,endtime,fe_group,CType,colpos,bodytext',
1818 'tt_content',
1819 'pid='.intval($expPageId).
1820 t3lib_BEfunc::deleteClause('tt_content').
1821 t3lib_BEfunc::versioningPlaceholderClause('tt_content'),
1822 '',
1823 'colpos,sorting'
1824 );
1825 $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1826
1827 // Traverse list of records:
1828 $c=0;
1829 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1830 $c++;
1831 $icon=t3lib_iconWorks::getIconImage('tt_content',$row,$BACK_PATH,'');
1832 if ($this->curUrlInfo['act']=='page' && $this->curUrlInfo['cElement']==$row['uid']) {
1833 $arrCol='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
1834 } else {
1835 $arrCol='';
1836 }
1837 // Putting list element HTML together:
1838 $out.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join'.($c==$cc?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
1839 $arrCol.
1840 '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.$row['uid'].'\');">'.
1841 $icon.
1842 htmlspecialchars(t3lib_div::fixed_lgd_cs($row['header'],$titleLen)).
1843 '</a><br />';
1844
1845 // Finding internal anchor points:
1846 if (t3lib_div::inList('text,textpic', $row['CType'])) {
1847 $split = preg_split('/(<a[^>]+name=[\'"]?([^"\'>[:space:]]+)[\'"]?[^>]*>)/i', $row['bodytext'], -1, PREG_SPLIT_DELIM_CAPTURE);
1848
1849 foreach($split as $skey => $sval) {
1850 if (($skey%3)==2) {
1851 // Putting list element HTML together:
1852 $sval = substr($sval,0,100);
1853 $out.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/line.gif','width="18" height="16"').' alt="" />'.
1854 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join'.($skey+3>count($split)?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
1855 '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.rawurlencode($sval).'\');">'.
1856 htmlspecialchars(' <A> '.$sval).
1857 '</a><br />';
1858 }
1859 }
1860 }
1861 }
1862 }
1863 return $out;
1864 }
1865
1866 /**
1867 * For TYPO3 Element Browser: This lists all content elements from the given list of tables
1868 *
1869 * @param string Commalist of tables. Set to "*" if you want all tables.
1870 * @return string HTML output.
1871 */
1872 function TBE_expandPage($tables) {
1873 global $TCA,$BE_USER, $BACK_PATH;
1874
1875 $out='';
1876 if ($this->expandPage>=0 && t3lib_div::testInt($this->expandPage) && $BE_USER->isInWebMount($this->expandPage)) {
1877
1878 // Set array with table names to list:
1879 if (!strcmp(trim($tables),'*')) {
1880 $tablesArr = array_keys($TCA);
1881 } else {
1882 $tablesArr = t3lib_div::trimExplode(',',$tables,1);
1883 }
1884 reset($tablesArr);
1885
1886 // Headline for selecting records:
1887 $out.=$this->barheader($GLOBALS['LANG']->getLL('selectRecords').':');
1888
1889 // Create the header, showing the current page for which the listing is. Includes link to the page itself, if pages are amount allowed tables.
1890 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1891 $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages',$this->expandPage);
1892 $ATag='';
1893 $ATag_e='';
1894 $ATag2='';
1895 if (in_array('pages',$tablesArr)) {
1896 $ficon=t3lib_iconWorks::getIcon('pages',$mainPageRec);
1897 $ATag="<a href=\"#\" onclick=\"return insertElement('pages', '".$mainPageRec['uid']."', 'db', ".t3lib_div::quoteJSvalue($mainPageRec['title']).", '', '', '".$ficon."','',1);\">";
1898 $ATag2="<a href=\"#\" onclick=\"return insertElement('pages', '".$mainPageRec['uid']."', 'db', ".t3lib_div::quoteJSvalue($mainPageRec['title']).", '', '', '".$ficon."','',0);\">";
1899 $ATag_alt=substr($ATag,0,-4).",'',1);\">";
1900 $ATag_e='</a>';
1901 }
1902 $picon=t3lib_iconWorks::getIconImage('pages',$mainPageRec,$BACK_PATH,'');
1903 $pBicon=$ATag2?'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' alt="" />':'';
1904 $pText=htmlspecialchars(t3lib_div::fixed_lgd_cs($mainPageRec['title'],$titleLen));
1905 $out.=$picon.$ATag2.$pBicon.$ATag_e.$ATag.$pText.$ATag_e.'<br />';
1906
1907 // Initialize the record listing:
1908 $id = $this->expandPage;
1909 $pointer = t3lib_div::intInRange($this->pointer,0,100000);
1910 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
1911 $pageinfo = t3lib_BEfunc::readPageAccess($id,$perms_clause);
1912 $table='';
1913
1914 // Generate the record list:
1915 $dblist = t3lib_div::makeInstance('TBE_browser_recordList');
1916 $dblist->thisScript=$this->thisScript;
1917 $dblist->backPath = $GLOBALS['BACK_PATH'];
1918 $dblist->thumbs = 0;
1919 $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageinfo);
1920 $dblist->noControlPanels=1;
1921 $dblist->clickMenuEnabled=0;
1922 $dblist->tableList=implode(',',$tablesArr);
1923
1924 $dblist->start($id,t3lib_div::_GP('table'),$pointer,
1925 t3lib_div::_GP('search_field'),
1926 t3lib_div::_GP('search_levels'),
1927 t3lib_div::_GP('showLimit')
1928 );
1929 $dblist->setDispFields();
1930 $dblist->generateList();
1931 $dblist->writeBottom();
1932
1933 // Add the HTML for the record list to output variable:
1934 $out.=$dblist->HTMLcode;
1935
1936 // Add support for fieldselectbox in singleTableMode
1937 if ($dblist->table) {
1938 $out.= $dblist->fieldSelectBox($dblist->table);
1939 }
1940
1941 $out.=$dblist->getSearchBox();
1942 }
1943
1944 // Return accumulated content:
1945 return $out;
1946 }
1947
1948
1949 /**
1950 * Render list of folders inside a folder.
1951 *
1952 * @param string string of the current folder
1953 * @return string HTML output
1954 */
1955 function TBE_expandSubFolders($expandFolder=0) {
1956 $content = '';
1957
1958 $expandFolder = $expandFolder ?
1959 $expandFolder :
1960 $this->expandFolder;
1961
1962 if($expandFolder && $this->checkFolder($expandFolder)) {
1963 if(t3lib_div::isFirstPartOfStr($expandFolder, PATH_site)) {
1964 $rootFolder = substr($expandFolder, strlen(PATH_site));
1965 }
1966
1967 $folders = array();
1968
1969 // Listing the folders:
1970 $folders = t3lib_div::get_dirs($expandFolder);
1971 if(count($folders) > 0) {
1972 foreach($folders as $index => $folder) {
1973 $folders[$index] = $rootFolder.$folder.'/';
1974 }
1975 }
1976 $content.= $this->folderList($rootFolder, $folders);
1977 }
1978
1979 // Return accumulated content for folderlisting:
1980 return $content;
1981 }
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993 /******************************************************************
1994 *
1995 * File listing
1996 *
1997 ******************************************************************/
1998 /**
1999 * For RTE: This displays all files from folder. No thumbnails shown
2000 *
2001 * @param string The folder path to expand
2002 * @param string List of fileextensions to show
2003 * @return string HTML output
2004 */
2005 function expandFolder($expandFolder=0,$extensionList='') {
2006 global $BACK_PATH;
2007
2008 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
2009 $out='';
2010 if ($expandFolder && $this->checkFolder($expandFolder)) {
2011
2012 // Create header for filelisting:
2013 $out.=$this->barheader($GLOBALS['LANG']->getLL('files').':');
2014
2015 // Prepare current path value for comparison (showing red arrow)
2016 if (!$this->curUrlInfo['value']) {
2017 $cmpPath='';
2018 } else {
2019 $cmpPath=PATH_site.$this->curUrlInfo['info'];
2020 }
2021
2022
2023 // Create header element; The folder from which files are listed.
2024 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
2025 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
2026 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen));
2027 $picon='<a href="#" onclick="return link_folder(\''.t3lib_div::rawUrlEncodeFP(substr($expandFolder,strlen(PATH_site))).'\');">'.$picon.'</a>';
2028 if ($this->curUrlInfo['act'] == 'folder' && $cmpPath == $expandFolder) {
2029 $out.= '<img'.t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/blinkarrow_left.gif', 'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />';
2030 }
2031 $out.=$picon.'<br />';
2032
2033 // Get files from the folder:
2034 if ($this->mode == 'wizard' && $this->act == 'folder') {
2035 $files = t3lib_div::get_dirs($expandFolder);
2036 } else {
2037 $files = t3lib_div::getFilesInDir($expandFolder, $extensionList, 1, 1); // $extensionList='', $prependPath=0, $order='')
2038 }
2039
2040 $c=0;
2041 $cc=count($files);
2042 if (is_array($files)) {
2043 foreach($files as $filepath) {
2044 $c++;
2045 $fI=pathinfo($filepath);
2046
2047 if ($this->mode == 'wizard' && $this->act == 'folder') {
2048 $filepath = $expandFolder.$filepath.'/';
2049 $icon = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />';
2050 } else {
2051 // File icon:
2052 $icon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
2053
2054 // Get size and icon:
2055 $size = ' (' . t3lib_div::formatSize(filesize($filepath)) . 'bytes)';
2056 $icon = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/fileicons/' . $icon . '', 'width="18" height="16"') . ' title="' . htmlspecialchars($fI['basename'] . $size) . '" alt="" />';
2057 }
2058
2059 // If the listed file turns out to be the CURRENT file, then show blinking arrow:
2060 if (($this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder') && $cmpPath == $filepath) {
2061 $arrCol='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
2062 } else {
2063 $arrCol='';
2064 }
2065
2066 // Put it all together for the file element:
2067 $out.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join'.($c==$cc?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
2068 $arrCol.
2069 '<a href="#" onclick="return link_folder(\''.t3lib_div::rawUrlEncodeFP(substr($filepath,strlen(PATH_site))).'\');">'.
2070 $icon.
2071 htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen)).
2072 '</a><br />';
2073 }
2074 }
2075 }
2076 return $out;
2077 }
2078
2079 /**
2080 * For TYPO3 Element Browser: Expand folder of files.
2081 *
2082 * @param string The folder path to expand
2083 * @param string List of fileextensions to show
2084 * @param boolean Whether to show thumbnails or not. If set, no thumbnails are shown.
2085 * @return string HTML output
2086 */
2087 function TBE_expandFolder($expandFolder=0,$extensionList='',$noThumbs=0) {
2088 global $LANG;
2089
2090 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
2091 $out='';
2092 if ($expandFolder && $this->checkFolder($expandFolder)) {
2093 // Listing the files:
2094 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
2095 $out.= $this->fileList($files, $expandFolder, $noThumbs);
2096 }
2097
2098 // Return accumulated content for filelisting:
2099 return $out;
2100 }
2101
2102 /**
2103 * Render list of files.
2104 *
2105 * @param array List of files. See t3lib_div::getFilesInDir
2106 * @param string If set a header with a folder icon and folder name are shown
2107 * @param boolean Whether to show thumbnails or not. If set, no thumbnails are shown.
2108 * @return string HTML output
2109 */
2110 function fileList($files, $folderName='', $noThumbs=0) {
2111 global $LANG, $BACK_PATH;
2112
2113 $out='';
2114
2115 // Listing the files:
2116 if (is_array($files)) {
2117
2118 // Create headline (showing number of files):
2119 $filesCount = count($files);
2120 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):', $filesCount));
2121 $out.=$this->getBulkSelector($filesCount);
2122
2123 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
2124
2125 // Create the header of current folder:
2126 if($folderName) {
2127 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
2128 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($folderName),$titleLen));
2129 $out.=$picon.'<br />';
2130 }
2131
2132 // Init graphic object for reading file dimensions:
2133 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
2134 $imgObj->init();
2135 $imgObj->mayScaleUp=0;
2136 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
2137
2138 // Traverse the file list:
2139 $lines=array();
2140 foreach($files as $filepath) {
2141 $fI=pathinfo($filepath);
2142
2143 // Thumbnail/size generation:
2144 if (t3lib_div::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),strtolower($fI['extension'])) && !$noThumbs) {
2145 $imgInfo = $imgObj->getImageDimensions($filepath);
2146 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
2147 $clickIcon = t3lib_BEfunc::getThumbNail($BACK_PATH.'thumbs.php',$filepath,'hspace="5" vspace="5" border="1"');
2148 } else {
2149 $clickIcon = '';
2150 $pDim = '';
2151 }
2152
2153 // Create file icon:
2154 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
2155 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
2156 $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" class="absmiddle" alt="" />';
2157
2158 // Create links for adding the file:
2159 if (strstr($filepath,',') || strstr($filepath,'|')) { // In case an invalid character is in the filepath, display error message:
2160 $eMsg = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'),', |'));
2161 $ATag = $ATag_alt = "<a href=\"#\" onclick=\"alert(".$eMsg.");return false;\">";
2162 $bulkCheckBox = '';
2163 } else { // If filename is OK, just add it:
2164 $filesIndex = count($this->elements);
2165 $this->elements['file_'.$filesIndex] = array(
2166 'md5' => t3lib_div::shortMD5($filepath),
2167 'type' => 'file',
2168 'fileName' => $fI['basename'],
2169 'filePath' => $filepath,
2170 'fileExt' => $fI['extension'],
2171 'fileIcon' => $ficon,
2172 );
2173 $ATag = "<a href=\"#\" onclick=\"return BrowseLinks.File.insertElement('file_$filesIndex');\">";
2174 $ATag_alt = substr($ATag,0,-4).",1);\">";
2175 $bulkCheckBox = '<input type="checkbox" class="typo3-bulk-item" name="file_'.$filesIndex.'" value="0" /> ';
2176 }
2177 $ATag_e='</a>';
2178
2179 // Create link to showing details about the file in a window:
2180 $Ahref = $BACK_PATH.'show_item.php?table='.rawurlencode($filepath).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
2181 $ATag2='<a href="'.htmlspecialchars($Ahref).'">';
2182 $ATag2_e='</a>';
2183
2184 // Combine the stuff:
2185 $filenameAndIcon=$bulkCheckBox.$ATag_alt.$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen)).$ATag_e;
2186
2187 // Show element:
2188 if ($pDim) { // Image...
2189 $lines[]='
2190 <tr class="bgColor4">
2191 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
2192 <td>'.$ATag.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$ATag_e.'</td>
2193 <td nowrap="nowrap">'.($ATag2.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/zoom2.gif','width="12" height="12"').' title="'.$LANG->getLL('info',1).'" alt="" /> '.$LANG->getLL('info',1).$ATag2_e).'</td>
2194 <td nowrap="nowrap">&nbsp;'.$pDim.'</td>
2195 </tr>';
2196 $lines[]='
2197 <tr>
2198 <td colspan="4">'.$ATag_alt.$clickIcon.$ATag_e.'</td>
2199 </tr>';
2200 } else {
2201 $lines[]='
2202 <tr class="bgColor4">
2203 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
2204 <td>'.$ATag.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$ATag_e.'</td>
2205 <td nowrap="nowrap">'.($ATag2.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/zoom2.gif','width="12" height="12"').' title="'.$LANG->getLL('info',1).'" alt="" /> '.$LANG->getLL('info',1).$ATag2_e).'</td>
2206 <td>&nbsp;</td>
2207 </tr>';
2208 }
2209 $lines[]='
2210 <tr>
2211 <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
2212 </tr>';
2213 }
2214
2215 // Wrap all the rows in table tags:
2216 $out.='
2217
2218
2219
2220 <!--
2221 File listing
2222 -->
2223 <table border="0" cellpadding="0" cellspacing="1" id="typo3-fileList">
2224 '.implode('',$lines).'
2225 </table>';
2226 }
2227 // Return accumulated content for filelisting:
2228 return $out;
2229 }
2230
2231 /**
2232 * Render list of folders.
2233 *
2234 * @param array List of folders. See t3lib_div::get_dirs
2235 * @param string If set a header with a folder icon and folder name are shown
2236 * @return string HTML output
2237 */
2238 function folderList($baseFolder, $folders) {
2239 global $LANG, $BACK_PATH;
2240
2241 $content = '';
2242
2243 // Create headline (showing number of folders):
2244 $content.=$this->barheader(
2245 sprintf($GLOBALS['LANG']->getLL('folders').' (%s):',count($folders))
2246 );
2247
2248 $titleLength = intval($GLOBALS['BE_USER']->uc['titleLen']);
2249
2250 // Create the header of current folder:
2251 if($baseFolder) {
2252 if (strstr($baseFolder, ',') || strstr($baseFolder, '|')) {
2253 // In case an invalid character is in the filepath, display error message:
2254 $errorMessage = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'),', |'));
2255 $aTag = $aTag_alt = "<a href=\"#\" onclick=\"alert(".$errorMessage.");return false;\">";
2256 } else {
2257 // If foldername is OK, just add it:
2258 $aTag = "<a href=\"#\" onclick=\"return insertElement('','".rawurlencode($baseFolder)."', 'folder', '".rawurlencode($baseFolder)."', unescape('".rawurlencode($baseFolder)."'), '".$fI['extension']."', '".$ficon."');\">";
2259 $aTag_alt = substr($aTag,0,-4).",'',1);\">";
2260 }
2261 $aTag_e = '</a>';
2262
2263 // add the foder icon
2264 $folderIcon = $aTag_alt;
2265 $folderIcon.= '<img'.t3lib_iconWorks::skinImg(
2266 $BACK_PATH,
2267 'gfx/i/_icon_webfolders.gif','width="18" height="16"'
2268 ).' alt="" />';
2269 $folderIcon.= htmlspecialchars(
2270 t3lib_div::fixed_lgd_cs(basename($baseFolder),$titleLength)
2271 );
2272 $folderIcon.= $aTag_e;
2273
2274 $content.=$folderIcon.'<br />';
2275 }
2276
2277 // Listing the folders:
2278 if(is_array($folders)) {
2279 if(count($folders) > 0) {
2280 // Traverse the folder list:
2281 $lines = array();
2282 foreach($folders as $folderPath) {
2283 $pathInfo = pathinfo($folderPath);
2284
2285 // Create folder icon:
2286 $icon = '<img src="clear.gif" width="16" height="16" alt="" /><img'.t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/i/_icon_webfolders.gif','width="16" height="16"').' title="'.htmlspecialchars($pathInfo['basename'].$size).'" class="absmiddle" alt="" />';
2287
2288 // Create links for adding the folder:
2289 if($this->P['itemName'] != '' && $this->P['formName'] != '') {
2290 $aTag = "<a href=\"#\" onclick=\"return set_folderpath(unescape('".rawurlencode($folderPath)."'));\">";
2291 } else {
2292 $aTag = "<a href=\"#\" onclick=\"return insertElement('','".rawurlencode($folderPath)."', 'folder', '".rawurlencode($folderPath)."', unescape('".rawurlencode($folderPath)."'), '".$pathInfo['extension']."', '".$ficon."');\">";
2293 }
2294
2295 if (strstr($folderPath,',') || strstr($folderPath,'|')) {
2296 // In case an invalid character is in the filepath, display error message:
2297 $errorMessage = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'),', |'));
2298 $aTag = $aTag_alt = "<a href=\"#\" onclick=\"alert(".$errorMessage.");return false;\">";
2299 } else {
2300 // If foldername is OK, just add it:
2301 $aTag_alt = substr($aTag,0,-4).",'',1);\">";
2302 }
2303 $aTag_e='</a>';
2304
2305 // Combine icon and folderpath:
2306 $foldernameAndIcon = $aTag_alt.$icon.htmlspecialchars(
2307 t3lib_div::fixed_lgd_cs(basename($folderPath),$titleLength)
2308 ).$aTag_e;
2309
2310 if($this->P['itemName'] != '') {
2311 $lines[] = '
2312 <tr class="bgColor4">
2313 <td nowrap="nowrap">'.$foldernameAndIcon.'&nbsp;</td>
2314 <td>&nbsp;</td>
2315 </tr>';
2316 } else {
2317 $lines[] = '
2318 <tr class="bgColor4">
2319 <td nowrap="nowrap">'.$foldernameAndIcon.'&nbsp;</td>
2320 <td>'.$aTag.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$aTag_e.'</td>
2321 <td>&nbsp;</td>
2322 </tr>';
2323 }
2324
2325 $lines[] = '
2326 <tr>
2327 <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
2328 </tr>';
2329 }
2330 }
2331
2332 // Wrap all the rows in table tags:
2333 $content.='
2334
2335 <!--
2336 Folder listing
2337 -->
2338 <table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList">
2339 '.implode('', $lines).'
2340 </table>';
2341 }
2342
2343 // Return accumulated content for folderlisting:
2344 return $content;
2345 }
2346
2347 /**
2348 * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
2349 * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
2350 *
2351 * @param string The folder path to expand
2352 * @param string List of fileextensions to show
2353 * @return string HTML output
2354 */
2355 function TBE_dragNDrop($expandFolder=0,$extensionList='') {
2356 global $BACK_PATH;
2357
2358 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
2359 $out='';
2360 if ($expandFolder && $this->checkFolder($expandFolder)) {
2361 if ($this->isWebFolder($expandFolder)) {
2362
2363 // Read files from directory:
2364 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
2365 if (is_array($files)) {
2366 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
2367
2368 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
2369 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
2370 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen));
2371 $out.=$picon.'<br />';
2372
2373 // Init row-array:
2374 $lines=array();
2375
2376 // Add "drag-n-drop" message:
2377 $lines[]='
2378 <tr>
2379 <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
2380 </tr>';
2381
2382 // Fraverse files:
2383 while(list(,$filepath)=each($files)) {
2384 $fI = pathinfo($filepath);
2385
2386 // URL of image:
2387 $iurl = $this->siteURL.t3lib_div::rawurlencodeFP(substr($filepath,strlen(PATH_site)));
2388
2389 // Show only web-images
2390 if (t3lib_div::inList('gif,jpeg,jpg,png',strtolower($fI['extension']))) {
2391 $imgInfo = @getimagesize($filepath);
2392 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
2393
2394 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
2395 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
2396 $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
2397 $filenameAndIcon=$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen));
2398
2399 if (t3lib_div::_GP('noLimit')) {
2400 $maxW=10000;
2401 $maxH=10000;
2402 } else {
2403 $maxW=380;
2404 $maxH=500;
2405 }
2406 $IW = $imgInfo[0];
2407 $IH = $imgInfo[1];
2408 if ($IW>$maxW) {
2409 $IH=ceil($IH/$IW*$maxW);
2410 $IW=$maxW;
2411 }
2412 if ($IH>$maxH) {
2413 $IW=ceil($IW/$IH*$maxH);
2414 $IH=$maxH;
2415 }
2416
2417 // Make row:
2418 $lines[]='
2419 <tr class="bgColor4">
2420 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
2421 <td nowrap="nowrap">'.
2422 ($imgInfo[0]!=$IW ? '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('noLimit'=>'1'))).'">'.
2423 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/icon_warning2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize',1).'" alt="" />'.
2424 '</a>':'').
2425 $pDim.'&nbsp;</td>
2426 </tr>';
2427
2428 $lines[]='
2429 <tr>
2430 <td colspan="2"><img src="'.$iurl.'" width="'.$IW.'" height="'.$IH.'" border="1" alt="" /></td>
2431 </tr>';
2432 $lines[]='
2433 <tr>
2434 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
2435 </tr>';
2436 }
2437 }
2438
2439 // Finally, wrap all rows in a table tag:
2440 $out.='
2441
2442
2443 <!--
2444 File listing / Drag-n-drop
2445 -->
2446 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
2447 '.implode('',$lines).'
2448 </table>';
2449 }
2450 } else {
2451 // Print this warning if the folder is NOT a web folder:
2452 $out.=$this->barheader($GLOBALS['LANG']->getLL('files'));
2453 $out.=$this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'),'icon_warning2');
2454 }
2455 }
2456 return $out;
2457 }
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470 /******************************************************************
2471 *
2472 * Miscellaneous functions
2473 *
2474 ******************************************************************/
2475
2476
2477 /**
2478 * Verifies that a path is a web-folder:
2479 *
2480 * @param string Absolute filepath
2481 * @return boolean If the input path is found in PATH_site then it returns true.
2482 */
2483 function isWebFolder($folder) {
2484 $folder = ereg_replace('\/$','',$folder).'/';
2485 return t3lib_div::isFirstPartOfStr($folder,PATH_site) ? TRUE : FALSE;
2486 }
2487
2488 /**
2489 * Checks, if a path is within the mountpoints of the backend user
2490 *
2491 * @param string Absolute filepath
2492 * @return boolean If the input path is found in the backend users filemounts, then return true.
2493 */
2494 function checkFolder($folder) {
2495 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
2496 $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
2497
2498 return $fileProcessor->checkPathAgainstMounts(ereg_replace('\/$','',$folder).'/') ? TRUE : FALSE;
2499 }
2500
2501 /**
2502 * Prints a 'header' where string is in a tablecell
2503 *
2504 * @param string The string to print in the header. The value is htmlspecialchars()'ed before output.
2505 * @return string The header HTML (wrapped in a table)
2506 */
2507 function barheader($str) {
2508 return '
2509
2510 <!--
2511 Bar header:
2512 -->
2513 <h3 class="bgColor5">'.htmlspecialchars($str).'</h3>
2514 ';
2515 }
2516
2517 /**
2518 * Displays a message box with the input message
2519 *
2520 * @param string Input message to show (will be htmlspecialchars()'ed inside of this function)
2521 * @param string Icon filename body from gfx/ (default is "icon_note") - meant to allow change to warning type icons...
2522 * @return string HTML for the message (wrapped in a table).
2523 */
2524 function getMsgBox($in_msg,$icon='icon_note') {
2525 global $BACK_PATH;
2526
2527 $msg = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/'.$icon.'.gif','width="18" height="16"').' alt="" />'.htmlspecialchars($in_msg);
2528 $msg = '
2529
2530 <!--
2531 Message box:
2532 -->
2533 <table cellspacing="0" class="bgColor4" id="typo3-msgBox">
2534 <tr>
2535 <td>'.$msg.'</td>
2536 </tr>
2537 </table>
2538 ';
2539 return $msg;
2540 }
2541
2542 /**
2543 * For RTE/link: This prints the 'currentUrl'
2544 *
2545 * @param string URL value. The value is htmlspecialchars()'ed before output.
2546 * @return string HTML content, wrapped in a table.
2547 */
2548 function printCurrentUrl($str) {
2549 return '
2550
2551 <!--
2552 Print current URL
2553 -->
2554 <table border="0" cellpadding="0" cellspacing="0" class="bgColor5" id="typo3-curUrl">
2555 <tr>
2556 <td>'.$GLOBALS['LANG']->getLL('currentLink',1).': '.htmlspecialchars(rawurldecode($str)).'</td>
2557 </tr>
2558 </table>';
2559 }
2560
2561 /**
2562 * For RTE/link: Parses the incoming URL and determines if it's a page, file, external or mail address.
2563 *
2564 * @param string HREF value tp analyse
2565 * @param string The URL of the current website (frontend)
2566 * @return array Array with URL information stored in assoc. keys: value, act (page, file, spec, mail), pageid, cElement, info
2567 */
2568 function parseCurUrl($href,$siteUrl) {
2569 $href = trim($href);
2570 if ($href) {
2571 $info=array();
2572
2573 // Default is "url":
2574 $info['value']=$href;
2575 $info['act']='url';
2576
2577 $specialParts = explode('#_SPECIAL',$href);
2578 if (count($specialParts)==2) { // Special kind (Something RTE specific: User configurable links through: "userLinks." from ->thisConfig)
2579 $info['value']='#_SPECIAL'.$specialParts[1];
2580 $info['act']='spec';
2581 } elseif (t3lib_div::isFirstPartOfStr($href,$siteUrl)) { // If URL is on the current frontend website:
2582 $rel = substr($href,strlen($siteUrl));
2583 if (@file_exists(PATH_site.rawurldecode($rel))) { // URL is a file, which exists:
2584 $info['value']=rawurldecode($rel);
2585 if (@is_dir(PATH_site . $info['value'])) {
2586 $info['act'] = 'folder';
2587 } else {
2588 $info['act'] = 'file';
2589 }
2590 } else { // URL is a page (id parameter)
2591 $uP=parse_url($rel);
2592 if (!trim($uP['path'])) {
2593 $pp = explode('id=',$uP['query']);
2594 $id = $pp[1];
2595 if ($id) {
2596 // Checking if the id-parameter is an alias.
2597 if (!t3lib_div::testInt($id)) {
2598 list($idPartR) = t3lib_BEfunc::getRecordsByField('pages','alias',$id);
2599 $id=intval($idPartR['uid']);
2600 }
2601
2602 $pageRow = t3lib_BEfunc::getRecordWSOL('pages',$id);
2603 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
2604 $info['value']=$GLOBALS['LANG']->getLL('page',1)." '".htmlspecialchars(t3lib_div::fixed_lgd_cs($pageRow['title'],$titleLen))."' (ID:".$id.($uP['fragment']?', #'.$uP['fragment']:'').')';
2605 $info['pageid']=$id;
2606 $info['cElement']=$uP['fragment'];
2607 $info['act']='page';
2608 }
2609 }
2610 }
2611 } else { // Email link:
2612 if (strtolower(substr($href,0,7))=='mailto:') {
2613 $info['value']=trim(substr($href,7));
2614 $info['act']='mail';
2615 }
2616 }
2617 $info['info'] = $info['value'];
2618 } else { // NO value inputted:
2619 $info=array();
2620 $info['info']=$GLOBALS['LANG']->getLL('none');
2621 $info['value']='';
2622 $info['act']='page';
2623 }
2624
2625 // let the hook have a look
2626 foreach($this->hookObjects as $hookObject) {
2627 $info = $hookObject->parseCurrentUrl($href, $siteUrl, $info);
2628 }
2629
2630 return $info;
2631 }
2632
2633 /**
2634 * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
2635 * The files are uploaded to the tce_file.php script in the core which will handle the upload.
2636 *
2637 * @param string Absolute filepath on server to which to upload.
2638 * @return string HTML for an upload form.
2639 */
2640 function uploadForm($path) {
2641 global $BACK_PATH;
2642 $count=3;
2643
2644 // Create header, showing upload path:
2645 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
2646 $code=$this->barheader($GLOBALS['LANG']->getLL('uploadImage').':');
2647 $code.='
2648
2649 <!--
2650 Form, for uploading files:
2651 -->
2652 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
2653 <table border="0" cellpadding="0" cellspacing="3" id="typo3-uplFiles">
2654 <tr>
2655 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
2656 </tr>
2657 <tr>
2658 <td>';
2659
2660 // Traverse the number of upload fields (default is 3):
2661 for ($a=1;$a<=$count;$a++) {
2662 $code.='<input type="file" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" />
2663 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($path).'" />
2664 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
2665 }
2666
2667 // Make footer of upload form, including the submit button:
2668 $redirectValue = $this->thisScript.'?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
2669 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
2670 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />';
2671
2672 $code.='
2673 <div id="c-override">
2674 <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> <label for="overwriteExistingFiles">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'</label>
2675 </div>
2676 ';
2677
2678
2679 $code.='</td>
2680 </tr>
2681 </table>
2682 </form>';
2683
2684 return $code;
2685 }
2686
2687 /**
2688 * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
2689 * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
2690 *
2691 * @param string Absolute filepath on server in which to create the new folder.
2692 * @return string HTML for the create folder form.
2693 */
2694 function createFolder($path) {
2695 global $BACK_PATH;
2696 // Create header, showing upload path:
2697 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
2698 $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
2699 $code.='
2700
2701 <!--
2702 Form, for creating new folders:
2703 -->
2704 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform2">
2705 <table border="0" cellpadding="0" cellspacing="3" id="typo3-crFolder">
2706 <tr>
2707 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
2708 </tr>
2709 <tr>
2710 <td>';
2711
2712 // Create the new-folder name field:
2713 $a=1;
2714 $code.='<input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
2715 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($path).'" />';
2716
2717 // Make footer of upload form, including the submit button:
2718 $redirectValue = $this->thisScript.'?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
2719 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
2720 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
2721
2722 $code.='</td>
2723 </tr>
2724 </table>
2725 </form>';
2726
2727 return $code;
2728 }
2729
2730 /**
2731 * Get the HTML data required for a bulk selection of files of the TYPO3 Element Browser.
2732 *
2733 * @param integer $filesCount: Number of files currently displayed
2734 * @return string HTML data required for a bulk selection of files - if $filesCount is 0, nothing is returned
2735 */
2736 function getBulkSelector($filesCount) {
2737 if ($filesCount) {
2738 $labelToggleSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.php:toggleSelection',1);
2739 $labelImportSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.php:importSelection',1);
2740
2741 $out = $this->doc->spacer(15).'<div>' .
2742 '<a href="#" onclick="BrowseLinks.Selector.toggle()">' .
2743 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/clip_select.gif','width="12" height="12"').' title="'.$labelToggleSelection.'" alt="" /> ' .
2744 $labelToggleSelection.'</a>'.$this->doc->spacer(5) .
2745 '<a href="#" onclick="BrowseLinks.Selector.handle()">' .
2746 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/import.gif','width="12" height="12"').' title="'.$labelImportSelection.'" alt="" /> ' .
2747 $labelImportSelection.'</a>' .
2748 '</div>'.$this->doc->spacer(15);
2749 }
2750 return $out;
2751 }
2752 }
2753
2754 // Include extension?
2755 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.browse_links.php']) {
2756 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.browse_links.php']);
2757 }
2758
2759
2760 ?>