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