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