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