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