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