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