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