2 namespace TYPO3\CMS\Recordlist\Browser
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use TYPO3\CMS\Backend\Form\FormEngine
;
18 use TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList
;
19 use TYPO3\CMS\Backend\Template\DocumentTemplate
;
20 use TYPO3\CMS\Backend\Tree\View\ElementBrowserFolderTreeView
;
21 use TYPO3\CMS\Backend\Tree\View\ElementBrowserPageTreeView
;
22 use TYPO3\CMS\Backend\Utility\BackendUtility
;
23 use TYPO3\CMS\Backend\Utility\IconUtility
;
24 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication
;
25 use TYPO3\CMS\Core\Database\DatabaseConnection
;
26 use TYPO3\CMS\Core\ElementBrowser\ElementBrowserHookInterface
;
27 use TYPO3\CMS\Core\Imaging\Icon
;
28 use TYPO3\CMS\Core\Imaging\IconFactory
;
29 use TYPO3\CMS\Core\Messaging\FlashMessage
;
30 use TYPO3\CMS\Core\Page\PageRenderer
;
31 use TYPO3\CMS\Core\
Resource\Exception
;
32 use TYPO3\CMS\Core\
Resource\File
;
33 use TYPO3\CMS\Core\
Resource\FileInterface
;
34 use TYPO3\CMS\Core\
Resource\Filter\FileExtensionFilter
;
35 use TYPO3\CMS\Core\
Resource\Folder
;
36 use TYPO3\CMS\Core\
Resource\InaccessibleFolder
;
37 use TYPO3\CMS\Core\
Resource\ProcessedFile
;
38 use TYPO3\CMS\Core\
Resource\ResourceFactory
;
39 use TYPO3\CMS\Core\Utility\File\BasicFileUtility
;
40 use TYPO3\CMS\Core\Utility\GeneralUtility
;
41 use TYPO3\CMS\Core\Utility\StringUtility
;
42 use TYPO3\CMS\Core\Utility\MathUtility
;
43 use TYPO3\CMS\Frontend\Service\TypoLinkCodecService
;
44 use TYPO3\CMS\Lang\LanguageService
;
47 * class for the Element Browser window.
49 class ElementBrowser
{
52 * Optional instance of a record list that TBE_expandPage() should
53 * use to render the records in a page
55 * @var ElementBrowserRecordList
57 protected $recordList = NULL;
60 * Current site URL (Frontend)
68 * the script to link to
75 * RTE specific TSconfig
82 * Target (RTE specific)
89 * CSS Class (RTE specific)
96 * title (RTE specific)
108 * Backend template object
110 * @var DocumentTemplate
115 * Holds information about files
119 public $elements = array();
122 * The mode determines the main kind of output from the element browser.
123 * There are these options for values: rte, db, file, filedrag, wizard.
124 * "rte" will show the link selector for the Rich Text Editor (see main_rte())
125 * "db" will allow you to browse for pages or records in the page tree (for TCEforms, see main_db())
126 * "file"/"filedrag" will allow you to browse for files or folders in the folder mounts (for TCEforms, main_file())
127 * "wizard" will allow you to browse for links (like "rte") which are passed back to TCEforms (see main_rte(1))
135 * Link selector action.
136 * page,file,url,mail are allowed values.
137 * These are only important with the link selector function and in that case they switch
138 * between the various menu options.
145 * When you click a page title/expand icon to see the content of a certain page, this
146 * value will contain that value (the ID of the expanded page). If the value is NOT set,
147 * then it will be restored from the module session data (see main(), mode="db")
154 * When you click a folder name/expand icon to see the content of a certain file folder,
155 * this value will contain that value (the path of the expanded file folder). If the
156 * value is NOT set, then it will be restored from the module session data (see main(),
157 * mode="file"/"filedrag"). Example value: "/www/htdocs/typo3/32/3dsplm/fileadmin/css/"
161 public $expandFolder;
164 * the folder object of a parent folder that was selected
168 protected $selectedFolder;
171 * TYPO3 Element Browser, wizard mode parameters. There is a heap of parameters there,
172 * better debug() them out if you need something... :-)
179 * Active with TYPO3 Element Browser: Contains the name of the form field for which this window
180 * opens - thus allows us to make references back to the main window in which the form is.
181 * Example value: "data[pages][39][bodytext]|||tt_content|"
182 * or "data[tt_content][NEW3fba56fde763d][image]|||gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai|"
185 * 0: form field name reference, eg. "data[tt_content][123][image]"
186 * 1: htmlArea RTE parameters: editorNo:contentTypo3Language:contentTypo3Charset
187 * 2: RTE config parameters: RTEtsConfigParams
188 * 3: allowed types. Eg. "tt_content" or "gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai"
189 * 4: IRRE uniqueness: target level object-id to perform actions/checks on, eg. "data[79][tt_address][1][<field>][<foreign_table>]"
190 * 5: IRRE uniqueness: name of function in opener window that checks if element is already used, eg. "inline.checkUniqueElement"
191 * 6: IRRE uniqueness: name of function in opener window that performs some additional(!) action, eg. "inline.setUniqueElement"
192 * 7: IRRE uniqueness: name of function in opener window that performs action instead of using addElement/insertElement, eg. "inline.importElement"
194 * $pArr = explode('|', $this->bparams);
195 * $formFieldName = $pArr[0];
196 * $allowedTablesOrFileTypes = $pArr[3];
203 * Used with the Rich Text Editor.
204 * Example value: "tt_content:NEW3fba58c969f5c:bodytext:23:text:23:"
208 public $RTEtsConfigParams;
211 * Plus/Minus icon value. Used by the tree class to open/close notes on the trees.
218 * Pointer, used when browsing a long list of records etc.
225 * Used with the link selector: Contains the GET input information about the CURRENT link
226 * in the RTE/TCEform field. This consists of "href", "target" and "title" keys.
227 * This information is passed around in links.
234 * Used with the link selector: Contains a processed version of the input values from curUrlInfo.
235 * This is splitted into pageid, content element id, label value etc.
236 * This is used for the internal processing of that information.
243 * array which holds hook objects (initialised in init())
245 * @var ElementBrowserHookInterface[]
247 protected $hookObjects = array();
250 * @var BasicFileUtility
252 public $fileProcessor;
257 protected $pageRenderer = NULL;
262 protected $iconFactory;
267 public function __construct() {
268 $this->iconFactory
= GeneralUtility
::makeInstance(IconFactory
::class);
269 $this->pageRenderer
= $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
270 $this->pageRenderer
->loadJquery();
271 $this->pageRenderer
->loadRequireJsModule('TYPO3/CMS/Recordlist/FieldSelectBox');
275 * Sets the script url depending on being a module or script request
277 protected function determineScriptUrl() {
278 if ($routePath = GeneralUtility
::_GP('route')) {
279 $router = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\Router
::class);
280 $route = $router->match($routePath);
281 $uriBuilder = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder
::class);
282 $this->thisScript
= (string)$uriBuilder->buildUriFromRoute($route->getOption('_identifier'));
283 } elseif ($moduleName = GeneralUtility
::_GP('M')) {
284 $this->thisScript
= BackendUtility
::getModuleUrl($moduleName);
286 $this->thisScript
= GeneralUtility
::getIndpEnv('SCRIPT_NAME');
291 * Calculate path to this script.
292 * This method is public, to be used in hooks of this class only.
296 public function getThisScript() {
297 return strpos($this->thisScript
, '?') === FALSE ?
$this->thisScript
. '?' : $this->thisScript
. '&';
302 * Initializes a lot of variables, setting JavaScript functions in header etc.
305 * @throws \UnexpectedValueException
307 public function init() {
308 $this->initVariables();
310 $this->RTEtsConfigParams
= GeneralUtility
::_GP('RTEtsConfigParams');
311 $this->initConfiguration();
312 $this->initDocumentTemplate();
313 // init hook objects:
314 $this->initHookObjects('typo3/class.browse_links.php');
316 $this->initCurrentUrl();
318 // Determine nature of current url:
319 $this->act
= GeneralUtility
::_GP('act');
321 $this->act
= $this->curUrlInfo
['act'];
324 // Initializing the target value (RTE)
325 $this->setTarget
= $this->curUrlArray
['target'] != '-' ?
$this->curUrlArray
['target'] : '';
326 if ($this->thisConfig
['defaultLinkTarget'] && !isset($this->curUrlArray
['target'])) {
327 $this->setTarget
= $this->thisConfig
['defaultLinkTarget'];
329 // Initializing the class value (RTE)
330 $this->setClass
= $this->curUrlArray
['class'] != '-' ?
$this->curUrlArray
['class'] : '';
331 // Initializing the title value (RTE)
332 $this->setTitle
= $this->curUrlArray
['title'] != '-' ?
$this->curUrlArray
['title'] : '';
333 // Initializing the params value
334 $this->setParams
= $this->curUrlArray
['params'] != '-' ?
$this->curUrlArray
['params'] : '';
336 // Finally, add the accumulated JavaScript to the template object:
337 // also unset the default jumpToUrl() function before
338 unset($this->doc
->JScodeArray
['jumpToUrl']);
339 $this->doc
->JScode
.= $this->doc
->wrapScriptTags($this->getJSCode());
343 * Initialize class variables
347 public function initVariables() {
349 $this->pointer
= GeneralUtility
::_GP('pointer');
350 $this->bparams
= GeneralUtility
::_GP('bparams');
351 $this->P
= GeneralUtility
::_GP('P');
352 $this->expandPage
= GeneralUtility
::_GP('expandPage');
353 $this->expandFolder
= GeneralUtility
::_GP('expandFolder');
354 $this->PM
= GeneralUtility
::_GP('PM');
358 $this->siteURL
= GeneralUtility
::getIndpEnv('TYPO3_SITE_URL');
359 $this->determineScriptUrl();
362 $this->mode
= GeneralUtility
::_GP('mode');
367 // Init fileProcessor
368 $this->fileProcessor
= GeneralUtility
::makeInstance(BasicFileUtility
::class);
369 $this->fileProcessor
->init(array(), $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
373 * Initializes the configuration variables
377 public function initConfiguration() {
378 // Rich Text Editor specific configuration:
379 if ((string)$this->mode
=== 'rte') {
380 $this->thisConfig
= $this->getRTEConfig();
385 * Initialize document template object
389 protected function initDocumentTemplate() {
390 // Creating backend template object:
391 $this->doc
= GeneralUtility
::makeInstance(DocumentTemplate
::class);
392 $this->doc
->bodyTagId
= 'typo3-browse-links-php';
393 $pageRenderer = $this->getPageRenderer();
394 $pageRenderer->loadJquery();
395 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/BrowseLinks');
396 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LegacyTree');
400 * Initialize hook objects implementing the interface
402 * @param string $hookKey the hook key
403 * @throws \UnexpectedValueException
406 protected function initHookObjects($hookKey) {
407 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][$hookKey]['browseLinksHook'])) {
408 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][$hookKey]['browseLinksHook'] as $classData) {
409 $processObject = GeneralUtility
::getUserObj($classData);
410 if (!$processObject instanceof ElementBrowserHookInterface
) {
411 throw new \
UnexpectedValueException('$processObject must implement interface ' . ElementBrowserHookInterface
::class, 1195039394);
413 $parameters = array();
414 $processObject->init($this, $parameters);
415 $this->hookObjects
[] = $processObject;
421 * Initialize $this->curUrlArray and $this->curUrlInfo based on script parameters
425 protected function initCurrentUrl() {
426 // CurrentUrl - the current link url must be passed around if it exists
427 if ($this->mode
=== 'wizard') {
428 $currentValues = GeneralUtility
::trimExplode(LF
, trim($this->P
['currentValue']));
429 if (!empty($currentValues)) {
430 $currentValue = array_pop($currentValues);
434 $currentLinkParts = GeneralUtility
::makeInstance(TypoLinkCodecService
::class)->decode($currentValue);
436 $initialCurUrlArray = array(
437 'href' => $currentLinkParts['url'],
438 'target' => $currentLinkParts['target'],
439 'class' => $currentLinkParts['class'],
440 'title' => $currentLinkParts['title'],
441 'params' => $currentLinkParts['additionalParams']
443 $this->curUrlArray
= is_array(GeneralUtility
::_GP('curUrl'))
444 ?
array_merge($initialCurUrlArray, GeneralUtility
::_GP('curUrl'))
445 : $initialCurUrlArray;
446 // Additional fields for page links
447 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendUrlArray'])
448 && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendUrlArray'])
454 // the hook expects old numerical indexes
455 $currentLinkParts['url'],
456 $currentLinkParts['target'],
457 $currentLinkParts['class'],
458 $currentLinkParts['title'],
459 $currentLinkParts['additionalParams']
462 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendUrlArray'] as $objRef) {
463 $processor =& GeneralUtility
::getUserObj($objRef);
464 $processor->extendUrlArray($_params, $this);
467 $this->curUrlInfo
= $this->parseCurUrl($this->siteURL
. '?id=' . $this->curUrlArray
['href'], $this->siteURL
);
468 // pageid == 0 means that this is not an internal (page) link
469 if ($this->curUrlInfo
['pageid'] == 0 && $this->curUrlArray
['href']) {
470 // Check if there is the FAL API
471 if (GeneralUtility
::isFirstPartOfStr($this->curUrlArray
['href'], 'file:')) {
472 $this->curUrlInfo
= $this->parseCurUrl($this->curUrlArray
['href'], $this->siteURL
);
473 } elseif (file_exists(PATH_site
. rawurldecode($this->curUrlArray
['href']))) {
474 $this->curUrlInfo
= $this->parseCurUrl($this->siteURL
. $this->curUrlArray
['href'], $this->siteURL
);
475 } elseif (strstr($this->curUrlArray
['href'], '@')) {
476 $this->curUrlInfo
= $this->parseCurUrl('mailto:' . $this->curUrlArray
['href'], $this->siteURL
);
478 // nothing of the above. this is an external link
479 if (strpos($this->curUrlArray
['href'], '://') === FALSE) {
480 $currentLinkParts['url'] = 'http://' . $this->curUrlArray
['href'];
482 $this->curUrlInfo
= $this->parseCurUrl($currentLinkParts['url'], $this->siteURL
);
484 } elseif (!$this->curUrlArray
['href']) {
485 $this->curUrlInfo
= array();
488 $this->curUrlInfo
= $this->parseCurUrl($this->siteURL
. '?id=' . $this->curUrlArray
['href'], $this->siteURL
);
491 $this->curUrlArray
= GeneralUtility
::_GP('curUrl');
492 if ($this->curUrlArray
['all']) {
493 $this->curUrlArray
= GeneralUtility
::get_tag_attributes($this->curUrlArray
['all']);
495 $this->curUrlInfo
= $this->parseCurUrl($this->curUrlArray
['href'], $this->siteURL
);
500 * Get the RTE configuration from Page TSConfig
502 * @return array[] RTE configuration array
504 protected function getRTEConfig() {
505 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams
);
506 $RTEsetup = $this->getBackendUser()->getTSConfig('RTE', BackendUtility
::getPagesTSconfig($RTEtsConfigParts[5]));
507 return BackendUtility
::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
511 * Generate JS code to be used on the link insert/modify dialogue
513 * @return string the generated JS code
515 public function getJsCode() {
516 // Rich Text Editor specific configuration:
517 $addPassOnParams = '';
518 if ((string)$this->mode
== 'rte') {
519 $addPassOnParams .= '&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams
);
521 // BEGIN accumulation of header JavaScript:
523 // This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
524 var add_href=' . GeneralUtility
::quoteJSvalue($this->curUrlArray
['href'] ?
'&curUrl[href]=' . rawurlencode($this->curUrlArray
['href']) : '') . ';
525 var add_target=' . GeneralUtility
::quoteJSvalue($this->setTarget ?
'&curUrl[target]=' . rawurlencode($this->setTarget
) : '') . ';
526 var add_class=' . GeneralUtility
::quoteJSvalue($this->setClass ?
'&curUrl[class]=' . rawurlencode($this->setClass
) : '') . ';
527 var add_title=' . GeneralUtility
::quoteJSvalue($this->setTitle ?
'&curUrl[title]=' . rawurlencode($this->setTitle
) : '') . ';
528 var add_params=' . GeneralUtility
::quoteJSvalue($this->bparams ?
'&bparams=' . rawurlencode($this->bparams
) : '') . ';
530 var cur_href=' . GeneralUtility
::quoteJSvalue($this->curUrlArray
['href'] ?
: '') . ';
531 var cur_target=' . GeneralUtility
::quoteJSvalue($this->setTarget ?
: '') . ';
532 var cur_class=' . GeneralUtility
::quoteJSvalue($this->setClass ?
: '') . ';
533 var cur_title=' . GeneralUtility
::quoteJSvalue($this->setTitle ?
: '') . ';
534 var cur_params=' . GeneralUtility
::quoteJSvalue($this->setParams ?
: '') . ';
536 function browse_links_setTarget(target) { //
538 add_target="&curUrl[target]="+escape(target);
540 function browse_links_setClass(cssClass) { //
541 cur_class = cssClass;
542 add_class = "&curUrl[class]=" + escape(cssClass);
544 function browse_links_setTitle(title) { //
546 add_title="&curUrl[title]="+escape(title);
548 function browse_links_setValue(value) { //
550 add_href="&curUrl[href]="+value;
552 function browse_links_setParams(params) { //
554 add_params="&curUrl[params]="+escape(params);
556 ' . $this->doc
->redirectUrls();
557 // Functions used, if the link selector is in wizard mode (= TCEforms fields)
558 if ($this->mode
== 'wizard') {
559 if (!$this->areFieldChangeFunctionsValid() && !$this->areFieldChangeFunctionsValid(TRUE)) {
560 $this->P
['fieldChangeFunc'] = array();
562 unset($this->P
['fieldChangeFunc']['alert']);
564 foreach ($this->P
['fieldChangeFunc'] as $v) {
566 window.opener.' . $v;
569 $P2['uid'] = $this->P
['uid'];
570 $P2['pid'] = $this->P
['pid'];
571 $P2['itemName'] = $this->P
['itemName'];
572 $P2['formName'] = $this->P
['formName'];
573 $P2['fieldChangeFunc'] = $this->P
['fieldChangeFunc'];
574 $P2['fieldChangeFuncHash'] = GeneralUtility
::hmac(serialize($this->P
['fieldChangeFunc']));
575 $P2['params']['allowedExtensions'] = isset($this->P
['params']['allowedExtensions']) ?
$this->P
['params']['allowedExtensions'] : '';
576 $P2['params']['blindLinkOptions'] = isset($this->P
['params']['blindLinkOptions']) ?
$this->P
['params']['blindLinkOptions'] : '';
577 $P2['params']['blindLinkFields'] = isset($this->P
['params']['blindLinkFields']) ?
$this->P
['params']['blindLinkFields']: '';
578 $addPassOnParams .= GeneralUtility
::implodeArrayForUrl('P', $P2);
580 function link_typo3Page(id,anchor) { //
581 updateValueInMainForm(id + (anchor ? anchor : ""));
585 function link_folder(folder) { //
586 updateValueInMainForm(folder);
590 function link_current() { //
591 if (cur_href!="http://" && cur_href!="mailto:") {
592 returnBeforeCleaned = cur_href;
593 if (returnBeforeCleaned.substr(0, 7) == "http://") {
594 returnToMainFormValue = returnBeforeCleaned.substr(7);
595 } else if (returnBeforeCleaned.substr(0, 7) == "mailto:") {
596 if (returnBeforeCleaned.substr(0, 14) == "mailto:mailto:") {
597 returnToMainFormValue = returnBeforeCleaned.substr(14);
599 returnToMainFormValue = returnBeforeCleaned.substr(7);
602 returnToMainFormValue = returnBeforeCleaned;
604 updateValueInMainForm(returnToMainFormValue);
609 function checkReference() { //
610 if (window.opener && window.opener.document && window.opener.document.' . $this->P
['formName']
611 . ' && window.opener.document.' . $this->P
['formName'] . '["' . $this->P
['itemName'] . '"] ) {
612 return window.opener.document.' . $this->P
['formName'] . '["' . $this->P
['itemName'] . '"];
617 function updateValueInMainForm(input) { //
618 var field = checkReference();
620 if (cur_target == "" && (cur_class != "" || cur_title != "" || cur_params != "")) {
623 if (cur_class == "" && (cur_title != "" || cur_params != "")) {
626 cur_class = cur_class.replace(/[\'\\"]/g, "");
627 if (cur_class.indexOf(" ") != -1) {
628 cur_class = "\\"" + cur_class + "\\"";
630 if (cur_title == "" && cur_params != "") {
633 // replace each \ with \\
634 cur_title = cur_title.replace(/\\\\/g, "\\\\\\\\");
635 // replace each " with \"
636 cur_title = cur_title.replace(/\\"/g, "\\\\\\"");
637 if (cur_title.indexOf(" ") != -1) {
638 cur_title = "\\"" + cur_title + "\\"";
641 cur_params = cur_params.replace(/\\bid\\=.*?(\\&|$)/, "");
643 input = input + " " + cur_target + " " + cur_class + " " + cur_title + " " + cur_params;
644 input = input.replace(/^\s+|\s+$/g, "");
645 if(field.value && field.className.search(/textarea/) != -1) {
646 field.value += "\\n" + input;
650 if (typeof field.onchange === \'function\') {
658 // Functions used, if the link selector is in RTE mode:
660 function link_typo3Page(id,anchor) { //
661 var theLink = \'' . $this->siteURL
. '?id=\'+id+(anchor?anchor:"");
662 self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
665 function link_folder(folder) { //
666 var theLink = \'' . $this->siteURL
. '\'+folder;
667 self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
670 function link_current() { //
671 if (cur_href!="http://" && cur_href!="mailto:") {
672 self.parent.parent.renderPopup_addLink(cur_href, cur_target, cur_class, cur_title);
678 // General "jumpToUrl" function:
680 function jumpToUrl(URL,anchor) { //
681 if (URL.charAt(0) === \'?\') {
682 URL = ' . GeneralUtility
::quoteJSvalue($this->getThisScript()) . ' + URL.substring(1);
684 var add_act = URL.indexOf("act=")==-1 ? "&act=' . $this->act
. '" : "";
685 var add_mode = URL.indexOf("mode=")==-1 ? "&mode=' . $this->mode
. '" : "";
686 var theLocation = URL + add_act + add_mode + add_href + add_target + add_class + add_title + add_params'
687 . ($addPassOnParams ?
'+' . GeneralUtility
::quoteJSvalue($addPassOnParams) : '')
688 . '+(typeof(anchor)=="string"?anchor:"");
689 window.location.href = theLocation;
694 * Splits parts of $this->bparams
698 $pArr = explode('|', $this->bparams
);
699 // This is JavaScript especially for the TBE Element Browser!
700 $formFieldName = 'data[' . $pArr[0] . '][' . $pArr[1] . '][' . $pArr[2] . ']';
701 // insertElement - Call check function (e.g. for uniqueness handling):
703 if ($pArr[4] && $pArr[5]) {
705 // Call a check function in the opener window (e.g. for uniqueness handling):
706 if (parent.window.opener) {
707 var res = parent.window.opener.' . $pArr[5] . '("' . addslashes($pArr[4]) . '",table,uid,type);
709 if (res.message) alert(res.message);
710 performAction = false;
713 alert("Error - reference to main window is not set properly!");
718 // insertElement - Call helper function:
720 if ($pArr[4] && $pArr[6]) {
722 // Call helper function to manage data in the opener window:
723 if (parent.window.opener) {
724 parent.window.opener.' . $pArr[6] . '("' . addslashes($pArr[4]) . '",table,uid,type,"' . addslashes($pArr[0]) . '");
726 alert("Error - reference to main window is not set properly!");
731 // insertElement - perform action commands:
732 $JScodeActionMultiple = '';
733 if ($pArr[4] && $pArr[7]) {
734 // Call user defined action function:
736 if (parent.window.opener) {
737 parent.window.opener.' . $pArr[7] . '("' . addslashes($pArr[4]) . '",table,uid,type);
738 if (close) { focusOpenerAndClose(close); }
740 alert("Error - reference to main window is not set properly!");
741 if (close) { parent.close(); }
744 $JScodeActionMultiple = '
745 // Call helper function to manage data in the opener window:
746 if (parent.window.opener) {
747 parent.window.opener.' . $pArr[7] . 'Multiple("' . addslashes($pArr[4]) . '",table,uid,type,"'
748 . addslashes($pArr[0]) . '");
750 alert("Error - reference to main window is not set properly!");
754 } elseif ($pArr[0] && !$pArr[1] && !$pArr[2]) {
756 addElement(filename,table+"_"+uid,fp,close);
760 if (setReferences()) {
761 parent.window.opener.group_change("add","' . $pArr[0] . '","' . $pArr[1] . '","' . $pArr[2]
762 . '",elRef,targetDoc);
764 alert("Error - reference to main window is not set properly!");
766 focusOpenerAndClose(close);
773 function launchView(url) { //
774 var thePreviewWindow="";
775 thePreviewWindow = window.open(' . GeneralUtility
::quoteJSvalue(BackendUtility
::getModuleUrl('show_item') . '&table=') . '+url,"ShowItem",'
776 . '"height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
777 if (thePreviewWindow && thePreviewWindow.focus) {
778 thePreviewWindow.focus();
781 function setReferences() { //
782 if (parent.window.opener && parent.window.opener.content && parent.window.opener.content.document.editform'
783 . '&& parent.window.opener.content.document.editform["' . $formFieldName . '"]) {
784 targetDoc = parent.window.opener.content.document;
785 elRef = targetDoc.editform["' . $formFieldName . '"];
791 function insertElement(table, uid, type, filename, fp, filetype, imagefile, action, close) { //
792 var performAction = true;
794 // Call performing function and finish this action:
796 ' . $JScodeHelper . $JScodeAction . '
800 var _hasActionMultipleCode = ' . (!empty($JScodeActionMultiple) ?
'true' : 'false') . ';
801 function insertMultiple(table, uid) {
803 ' . $JScodeActionMultiple . '
806 function addElement(elName, elValue, altElValue, close) { //
807 if (parent.window.opener && parent.window.opener.setFormValueFromBrowseWin) {
808 parent.window.opener.setFormValueFromBrowseWin("' . $pArr[0] . '",altElValue?altElValue:elValue,elName);
809 focusOpenerAndClose(close);
811 alert("Error - reference to main window is not set properly!");
815 function focusOpenerAndClose(close) { //
816 BrowseLinks.focusOpenerAndClose(close);
819 // extends JavaScript code
820 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendJScode'])
821 && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendJScode'])
827 'wizardUpdate' => $update,
828 'addPassOnParams' => $addPassOnParams
830 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendJScode'] as $objRef) {
831 $processor =& GeneralUtility
::getUserObj($objRef);
832 $JScode .= $processor->extendJScode($_params, $this);
839 * Session data for this class can be set from outside with this method.
842 * @param mixed[] $data Session data array
843 * @return array[] Session data and boolean which indicates that data needs to be stored in session because it's changed
845 public function processSessionData($data) {
847 switch ((string)$this->mode
) {
849 if (isset($this->expandPage
)) {
850 $data['expandPage'] = $this->expandPage
;
853 $this->expandPage
= $data['expandPage'];
861 if (isset($this->expandFolder
)) {
862 $data['expandFolder'] = $this->expandFolder
;
865 $this->expandFolder
= $data['expandFolder'];
869 return array($data, $store);
872 /******************************************************************
876 ******************************************************************/
878 * Rich Text Editor (RTE) link selector (MAIN function)
879 * Generates the link selector for the Rich Text Editor.
880 * Can also be used to select links for the TCEforms (see $wiz)
882 * @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
883 * @return string Modified content variable.
885 public function main_rte($wiz = FALSE) {
886 // needs to be executed before doc->startPage()
887 if (in_array($this->act
, array('file', 'folder'))) {
888 $this->doc
->getDragDropCode('folders', 'Tree.ajaxID = "SC_alt_file_navframe::expandCollapse"');
889 } elseif ($this->act
=== 'page') {
890 $this->doc
->getDragDropCode('pages');
893 $content = $this->doc
->startPage('RTE link');
894 // Add the FlashMessages if any
895 $content .= $this->doc
->getFlashMessages();
897 $allowedItems = $this->getAllowedItems('page,file,folder,url,mail');
899 // Removing link fields if configured
900 $blindLinkFields = isset($this->thisConfig
['blindLinkFields'])
901 ? GeneralUtility
::trimExplode(',', $this->thisConfig
['blindLinkFields'], TRUE)
903 $pBlindLinkFields = isset($this->P
['params']['blindLinkFields'])
904 ? GeneralUtility
::trimExplode(',', $this->P
['params']['blindLinkFields'], TRUE)
906 $allowedFields = array_diff(array('target', 'title', 'class', 'params'), $blindLinkFields, $pBlindLinkFields);
908 $content .= $this->doc
->getTabMenuRaw($this->buildMenuArray($wiz, $allowedItems));
909 // Adding the menu and header to the top of page:
910 $content .= $this->printCurrentUrl($this->curUrlInfo
['info']) . '<br />';
911 // Depending on the current action we will create the actual module content for selecting a link:
912 switch ($this->act
) {
914 $content .= $this->getEmailSelectorHtml();
917 $content .= $this->getExternalUrlSelectorHtml();
921 $content .= $this->getFileSelectorHtml();
924 $content .= $this->getPageSelectorHtml();
928 foreach ($this->hookObjects
as $hookObject) {
929 $content .= $hookObject->getTab($this->act
);
932 $lang = $this->getLanguageService();
933 if (in_array('params', $allowedFields, TRUE) && $this->act
!== 'url') {
936 Selecting params for link:
938 <form action="" name="lparamsform" id="lparamsform">
939 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkParams">
941 <td style="width: 96px;">' . $lang->getLL('params', TRUE) . '</td>
942 <td><input type="text" name="lparams" class="typo3-link-input" onchange="'
943 . 'browse_links_setParams(this.value);" value="' . htmlspecialchars($this->setParams
)
950 if (in_array('class', $allowedFields, TRUE)) {
953 Selecting class for link:
955 <form action="" name="lclassform" id="lclassform">
956 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkClass">
958 <td style="width: 96px;">' . $lang->getLL('class', TRUE) . '</td>
959 <td><input type="text" name="lclass" class="typo3-link-input" onchange="'
960 . 'browse_links_setClass(this.value);" value="' . htmlspecialchars($this->setClass
)
967 if (in_array('title', $allowedFields, TRUE)) {
970 Selecting title for link:
972 <form action="" name="ltitleform" id="ltitleform">
973 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTitle">
975 <td style="width: 96px;">' . $lang->getLL('title', TRUE) . '</td>
976 <td><input type="text" name="ltitle" class="typo3-link-input" onchange="'
977 . 'browse_links_setTitle(this.value);" value="' . htmlspecialchars($this->setTitle
)
984 // additional fields for page links
985 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['addFields_PageLink'])
986 && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['addFields_PageLink'])
992 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['addFields_PageLink'] as $objRef) {
993 $processor =& GeneralUtility
::getUserObj($objRef);
994 $content .= $processor->addFields($_params, $this);
998 if ($this->act
!= 'mail' && in_array('target', $allowedFields, TRUE)) {
1002 Selecting target for link:
1004 <form action="" name="ltargetform" id="ltargetform">
1005 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
1007 <td>' . $lang->getLL('target', TRUE) . ':</td>
1008 <td><input type="text" name="ltarget" onchange="browse_links_setTarget(this.value);" value="'
1009 . htmlspecialchars($this->setTarget
) . '"' . $this->doc
->formWidth(10) . ' /></td>
1011 <select name="ltarget_type" onchange="browse_links_setTarget('
1012 . 'this.options[this.selectedIndex].value);document.ltargetform.ltarget.value='
1013 . 'this.options[this.selectedIndex].value;this.selectedIndex=0;">
1015 <option value="_top">' . $lang->getLL('top', TRUE) . '</option>
1016 <option value="_blank">' . $lang->getLL('newWindow', TRUE) . '</option>
1020 if (($this->curUrlInfo
['act'] == 'page' ||
$this->curUrlInfo
['act'] == 'file' ||
$this->curUrlInfo
['act'] == 'folder')
1021 && $this->curUrlArray
['href'] && $this->curUrlInfo
['act'] == $this->act
1024 <input class="btn btn-default" type="submit" value="' . $lang->getLL('update', TRUE)
1025 . '" onclick="return link_current();" />';
1028 if (document.ltargetform.popup_width.options[document.ltargetform.popup_width.selectedIndex].value>0'
1029 . ' && document.ltargetform.popup_height.options[document.ltargetform.popup_height.selectedIndex].value>0) {
1030 document.ltargetform.ltarget.value = document.ltargetform.popup_width.options['
1031 . 'document.ltargetform.popup_width.selectedIndex].value+"x"'
1032 . '+document.ltargetformbrowse_links_setTarget.popup_height.options['
1033 . 'document.ltargetform.popup_height.selectedIndex].value;
1034 browse_links_setTarget(document.ltargetform.ltarget.value);
1035 browse_links_setClass(document.lclassform.lclass.value);
1036 browse_links_setTitle(document.ltitleform.ltitle.value);
1037 browse_links_setParams(document.lparamsform.lparams.value);
1038 document.ltargetform.popup_width.selectedIndex=0;
1039 document.ltargetform.popup_height.selectedIndex=0;
1045 <td>' . $lang->getLL('target_popUpWindow', TRUE) . ':</td>
1047 <select name="popup_width" onchange="' . htmlspecialchars($selectJS) . '">
1048 <option value="0">' . $lang->getLL('target_popUpWindow_width', TRUE) . '</option>
1049 <option value="300">300</option>
1050 <option value="400">400</option>
1051 <option value="500">500</option>
1052 <option value="600">600</option>
1053 <option value="700">700</option>
1054 <option value="800">800</option>
1057 <select name="popup_height" onchange="' . htmlspecialchars($selectJS) . '">
1058 <option value="0">' . $lang->getLL('target_popUpWindow_height', TRUE) . '</option>
1059 <option value="200">200</option>
1060 <option value="300">300</option>
1061 <option value="400">400</option>
1062 <option value="500">500</option>
1063 <option value="600">600</option>
1069 // Add "target selector" box to content:
1070 $content .= $ltarget;
1072 $content .= '<br /><br />';
1074 // End page, return content:
1075 $content .= $this->doc
->endPage();
1076 $content = $this->doc
->insertStylesAndJS($content);
1081 * Get the allowed items or tabs
1083 * @param string $items initial list of possible items
1084 * @return array the allowed items
1086 public function getAllowedItems($items) {
1087 // Initializing the action value, possibly removing blinded values etc:
1088 $blindLinkOptions = isset($this->thisConfig
['blindLinkOptions'])
1089 ? GeneralUtility
::trimExplode(',', $this->thisConfig
['blindLinkOptions'], TRUE)
1091 $pBlindLinkOptions = isset($this->P
['params']['blindLinkOptions'])
1092 ? GeneralUtility
::trimExplode(',', $this->P
['params']['blindLinkOptions'])
1094 $allowedItems = array_diff(explode(',', $items), $blindLinkOptions, $pBlindLinkOptions);
1096 // Call hook for extra options
1097 foreach ($this->hookObjects
as $hookObject) {
1098 $allowedItems = $hookObject->addAllowedItems($allowedItems);
1100 return $allowedItems;
1104 * Returns an array definition of the top menu
1107 * @param $allowedItems
1110 protected function buildMenuArray($wiz, $allowedItems) {
1111 // Making menu in top:
1113 $lang = $this->getLanguageService();
1115 $menuDef['removeLink']['isActive'] = $this->act
=== 'removeLink';
1116 $menuDef['removeLink']['label'] = $lang->getLL('removeLink', TRUE);
1117 $menuDef['removeLink']['url'] = '#';
1118 $menuDef['removeLink']['addParams'] = 'onclick="self.parent.parent.renderPopup_unLink();return false;"';
1120 if (in_array('page', $allowedItems)) {
1121 $menuDef['page']['isActive'] = $this->act
=== 'page';
1122 $menuDef['page']['label'] = $lang->getLL('page', TRUE);
1123 $menuDef['page']['url'] = '#';
1124 $menuDef['page']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility
::quoteJSvalue('?act=page') . ');return false;"';
1126 if (in_array('file', $allowedItems)) {
1127 $menuDef['file']['isActive'] = $this->act
=== 'file';
1128 $menuDef['file']['label'] = $lang->getLL('file', TRUE);
1129 $menuDef['file']['url'] = '#';
1130 $menuDef['file']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility
::quoteJSvalue('?act=file') . ');return false;"';
1132 if (in_array('folder', $allowedItems)) {
1133 $menuDef['folder']['isActive'] = $this->act
=== 'folder';
1134 $menuDef['folder']['label'] = $lang->getLL('folder', TRUE);
1135 $menuDef['folder']['url'] = '#';
1136 $menuDef['folder']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility
::quoteJSvalue('?act=folder') . ');return false;"';
1138 if (in_array('url', $allowedItems)) {
1139 $menuDef['url']['isActive'] = $this->act
=== 'url';
1140 $menuDef['url']['label'] = $lang->getLL('extUrl', TRUE);
1141 $menuDef['url']['url'] = '#';
1142 $menuDef['url']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility
::quoteJSvalue('?act=url') . ');return false;"';
1144 if (in_array('mail', $allowedItems)) {
1145 $menuDef['mail']['isActive'] = $this->act
=== 'mail';
1146 $menuDef['mail']['label'] = $lang->getLL('email', TRUE);
1147 $menuDef['mail']['url'] = '#';
1148 $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility
::quoteJSvalue('?act=mail') . ');return false;"';
1150 // Call hook for extra options
1151 foreach ($this->hookObjects
as $hookObject) {
1152 $menuDef = $hookObject->modifyMenuDefinition($menuDef);
1158 * Returns HTML of the email link from
1162 protected function getEmailSelectorHtml() {
1163 $lang = $this->getLanguageService();
1168 <form action="" name="lurlform" id="lurlform">
1169 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
1171 <td style="width: 96px;">
1172 ' . $lang->getLL('emailAddress', TRUE) . ':
1175 <input type="text" name="lemail"' . $this->doc
->formWidth(20) . ' value="'
1176 . htmlspecialchars(($this->curUrlInfo
['act'] === 'mail' ?
$this->curUrlInfo
['info'] : ''))
1178 <input class="btn btn-default" type="submit" value="' . $lang->getLL('setLink', TRUE)
1179 . '" onclick="browse_links_setTarget(\'\');browse_links_setValue(\'mailto:\'+'
1180 . 'document.lurlform.lemail.value); return link_current();" />
1189 * Returns HTML of the external url link from
1193 protected function getExternalUrlSelectorHtml() {
1199 <form action="" name="lurlform" id="lurlform">
1200 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
1202 <td style="width: 96px;">URL:</td>
1203 <td><input type="text" name="lurl"' . $this->doc
->formWidth(30) . ' value="'
1204 . htmlspecialchars(($this->curUrlInfo
['act'] === 'url' ?
$this->curUrlInfo
['info'] : 'http://'))
1205 . '" /> ' . '<input class="btn btn-default" type="submit" value="' . $this->getLanguageService()->getLL('setLink', TRUE)
1206 . '" onclick="browse_links_setValue(document.lurlform.lurl.value); return link_current();" /></td>
1214 * Returns HTML of the file/folder link selector
1216 * @param string $treeClassName
1219 protected function getFileSelectorHtml($treeClassName = ElementBrowserFolderTreeView
::class) {
1220 /** @var ElementBrowserFolderTreeView $folderTree */
1221 $folderTree = GeneralUtility
::makeInstance($treeClassName);
1222 $folderTree->thisScript
= $this->thisScript
;
1223 $tree = $folderTree->getBrowsableTree();
1224 $backendUser = $this->getBackendUser();
1225 if (!$this->curUrlInfo
['value'] ||
$this->curUrlInfo
['act'] != $this->act
) {
1228 $cmpPath = $this->curUrlInfo
['value'];
1229 if (!isset($this->expandFolder
)) {
1230 $this->expandFolder
= $cmpPath;
1233 // Create upload/create folder forms, if a path is given
1234 $selectedFolder = FALSE;
1235 if ($this->expandFolder
) {
1236 $fileOrFolderObject = NULL;
1238 $fileOrFolderObject = ResourceFactory
::getInstance()->retrieveFileOrFolderObject($this->expandFolder
);
1239 } catch (\Exception
$e) {
1240 // No path is selected
1243 if ($fileOrFolderObject instanceof Folder
) {
1245 $selectedFolder = $fileOrFolderObject;
1246 } elseif ($fileOrFolderObject instanceof FileInterface
) {
1249 $selectedFolder = $fileOrFolderObject->getParentFolder();
1250 } catch (\Exception
$e) {
1251 // Accessing the parent folder failed for some reason. e.g. permissions
1255 // If no folder is selected, get the user's default upload folder
1256 if (!$selectedFolder) {
1258 $selectedFolder = $backendUser->getDefaultUploadFolder();
1259 } catch (\Exception
$e) {
1260 // The configured default user folder does not exist
1263 // Build the file upload and folder creation form
1267 if ($selectedFolder) {
1268 $uploadForm = ($this->act
=== 'file') ?
$this->uploadForm($selectedFolder) : '';
1269 $createFolder = $this->createFolder($selectedFolder);
1271 // Insert the upload form on top, if so configured
1272 if ($backendUser->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
1273 $content .= $uploadForm;
1276 // Render the filelist if there is a folder selected
1278 if ($selectedFolder) {
1279 $allowedExtensions = isset($this->P
['params']['allowedExtensions']) ?
$this->P
['params']['allowedExtensions'] : '';
1280 $files = $this->expandFolder($selectedFolder, $allowedExtensions);
1282 // Create folder tree:
1285 Wrapper table for folder tree / file/folder list:
1287 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
1289 <td class="c-wCell" valign="top">'
1290 . $this->barheader(($this->getLanguageService()->getLL('folderTree') . ':')) . $tree . '</td>
1291 <td class="c-wCell" valign="top">' . $files . '</td>
1295 // Adding create folder + upload form if applicable
1296 if (!$backendUser->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
1297 $content .= $uploadForm;
1299 $content .= '<br />' . $createFolder . '<br />';
1304 * Returns HTML of the page link selector
1306 * @param string $treeClassName name of the class used for page tree rendering
1309 protected function getPageSelectorHtml($treeClassName = ElementBrowserPageTreeView
::class) {
1310 $backendUser = $this->getBackendUser();
1312 /** @var ElementBrowserPageTreeView $pageTree */
1313 $pageTree = GeneralUtility
::makeInstance($treeClassName);
1314 $pageTree->thisScript
= $this->thisScript
;
1315 $pageTree->ext_showPageId
= $backendUser->getTSConfigVal('options.pageTree.showPageIdWithTitle');
1316 $pageTree->ext_showNavTitle
= $backendUser->getTSConfigVal('options.pageTree.showNavTitle');
1317 $pageTree->addField('nav_title');
1318 $tree = $pageTree->getBrowsableTree();
1319 $cElements = $this->expandPage();
1320 $dbmount = $this->getTemporaryTreeMountCancelNotice();
1324 Wrapper table for page tree / record list:
1326 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
1328 <td class="c-wCell" valign="top">'
1329 . $this->barheader(($this->getLanguageService()->getLL('pageTree') . ':'))
1332 <td class="c-wCell" valign="top">' . $cElements . '</td>
1340 * TYPO3 Element Browser: Showing a page tree and allows you to browse for records
1342 * @return string HTML content for the module
1344 public function main_db() {
1345 // Starting content:
1346 $content = $this->doc
->startPage('TBE record selector');
1348 $pArr = explode('|', $this->bparams
);
1350 $backendUser = $this->getBackendUser();
1352 // Making the browsable pagetree:
1353 /** @var \TYPO3\CMS\Recordlist\Tree\View\ElementBrowserPageTreeView $pageTree */
1354 $pageTree = GeneralUtility
::makeInstance(\TYPO3\CMS\Recordlist\Tree\View\ElementBrowserPageTreeView
::class);
1355 $pageTree->thisScript
= $this->thisScript
;
1356 $pageTree->ext_pArrPages
= $tables === 'pages' ?
1 : 0;
1357 $pageTree->ext_showNavTitle
= $backendUser->getTSConfigVal('options.pageTree.showNavTitle');
1358 $pageTree->ext_showPageId
= $backendUser->getTSConfigVal('options.pageTree.showPageIdWithTitle');
1359 $pageTree->addField('nav_title');
1362 if (($tables !== '') && ($tables !== '*')) {
1363 $tablesArr = GeneralUtility
::trimExplode(',', $tables, TRUE);
1364 $onlyRootLevel = TRUE;
1365 foreach ($tablesArr as $currentTable) {
1366 $tableTca = $GLOBALS['TCA'][$currentTable];
1367 if (isset($tableTca)) {
1368 if (!isset($tableTca['ctrl']['rootLevel']) ||
((int)$tableTca['ctrl']['rootLevel']) != 1) {
1369 $onlyRootLevel = FALSE;
1373 if ($onlyRootLevel) {
1375 // page to work on will be root
1376 $this->expandPage
= 0;
1380 $tree = $pageTree->getBrowsableTree();
1381 // Making the list of elements, if applicable:
1382 $cElements = $this->TBE_expandPage($tables);
1383 // Putting the things together, side by side:
1387 Wrapper table for page tree / record list:
1389 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBrecords">
1392 $content .= '<td class="c-wCell" valign="top">'
1393 . $this->barheader(($this->getLanguageService()->getLL('pageTree') . ':'))
1394 . $this->getTemporaryTreeMountCancelNotice()
1397 $content .= '<td class="c-wCell" valign="top">' . $cElements . '</td>
1402 $content .= '<br /><br />';
1403 // End page, return content:
1404 $content .= $this->doc
->endPage();
1405 $content = $this->doc
->insertStylesAndJS($content);
1410 * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for files.
1412 * @return string HTML content for the module
1414 public function main_file() {
1415 // include JS files and set prefs for foldertree
1416 $this->doc
->getDragDropCode('folders', 'Tree.ajaxID = "SC_alt_file_navframe::expandCollapse"');
1417 // Starting content:
1418 $content = $this->doc
->startPage('TBE file selector');
1419 // Add the FlashMessages if any
1420 $content .= $this->doc
->getFlashMessages();
1422 $pArr = explode('|', $this->bparams
);
1423 // The key number 3 of the pArr contains the "allowed" string. Disallowed is not passed to
1424 // the element browser at all but only filtered out in TCEMain afterwards
1425 $allowed = $pArr[3];
1426 if ($allowed !== 'sys_file' && $allowed !== '*' && !empty($allowed)) {
1427 $allowedFileExtensions = $allowed;
1429 $backendUser = $this->getBackendUser();
1431 if (isset($allowedFileExtensions)) {
1432 // Create new filter object
1433 $filterObject = GeneralUtility
::makeInstance(FileExtensionFilter
::class);
1434 $filterObject->setAllowedFileExtensions($allowedFileExtensions);
1435 // Set file extension filters on all storages
1436 $storages = $backendUser->getFileStorages();
1437 /** @var $storage \TYPO3\CMS\Core\Resource\ResourceStorage */
1438 foreach ($storages as $storage) {
1439 $storage->addFileAndFolderNameFilter(array($filterObject, 'filterFileList'));
1442 // Create upload/create folder forms, if a path is given
1443 $this->selectedFolder
= FALSE;
1444 if ($this->expandFolder
) {
1445 $fileOrFolderObject = NULL;
1447 // Try to fetch the folder the user had open the last time he browsed files
1448 // Fallback to the default folder in case the last used folder is not existing
1450 $fileOrFolderObject = ResourceFactory
::getInstance()->retrieveFileOrFolderObject($this->expandFolder
);
1451 } catch (Exception
$accessException) {
1452 // We're just catching the exception here, nothing to be done if folder does not exist or is not accessible.
1455 if ($fileOrFolderObject instanceof Folder
) {
1457 $this->selectedFolder
= $fileOrFolderObject;
1458 } elseif ($fileOrFolderObject instanceof FileInterface
) {
1460 $this->selectedFolder
= $fileOrFolderObject->getParentFolder();
1463 // Or get the user's default upload folder
1464 if (!$this->selectedFolder
) {
1466 $this->selectedFolder
= $backendUser->getDefaultUploadFolder();
1467 } catch (\Exception
$e) {
1468 // The configured default user folder does not exist
1471 // Build the file upload and folder creation form
1474 if ($this->selectedFolder
) {
1475 $uploadForm = $this->uploadForm($this->selectedFolder
);
1476 $createFolder = $this->createFolder($this->selectedFolder
);
1478 // Insert the upload form on top, if so configured
1479 if ($backendUser->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
1480 $content .= $uploadForm;
1482 // Getting flag for showing/not showing thumbnails:
1483 $noThumbs = $backendUser->getTSConfigVal('options.noThumbsInEB');
1484 $_MOD_SETTINGS = array();
1486 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
1487 $_MOD_MENU = array('displayThumbs' => '');
1488 $_MCONF['name'] = 'file_list';
1489 $_MOD_SETTINGS = BackendUtility
::getModuleData($_MOD_MENU, GeneralUtility
::_GP('SET'), $_MCONF['name']);
1491 $noThumbs = $noThumbs ?
: !$_MOD_SETTINGS['displayThumbs'];
1492 // Create folder tree:
1493 /** @var ElementBrowserFolderTreeView $folderTree */
1494 $folderTree = GeneralUtility
::makeInstance(ElementBrowserFolderTreeView
::class);
1495 $folderTree->thisScript
= $this->thisScript
;
1496 $folderTree->ext_noTempRecyclerDirs
= $this->mode
== 'filedrag';
1497 $tree = $folderTree->getBrowsableTree();
1498 if ($this->selectedFolder
) {
1499 if ($this->mode
== 'filedrag') {
1500 $files = $this->TBE_dragNDrop($this->selectedFolder
, $pArr[3]);
1502 $files = $this->TBE_expandFolder($this->selectedFolder
, $pArr[3], $noThumbs);
1508 // Putting the parts together, side by side:
1512 Wrapper table for folder tree / filelist:
1514 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
1516 <td class="c-wCell" valign="top">' . $this->barheader(($this->getLanguageService()->getLL('folderTree') . ':'))
1518 <td class="c-wCell" valign="top">' . $files . '</td>
1522 // Adding create folder + upload forms if applicable:
1523 if (!$backendUser->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
1524 $content .= $uploadForm;
1526 $content .= $createFolder;
1528 $content .= '<br /><br />';
1529 // Setup indexed elements:
1530 $this->doc
->JScode
.= $this->doc
->wrapScriptTags('
1531 require(["TYPO3/CMS/Backend/BrowseLinks"], function(BrowseLinks) {
1532 BrowseLinks.addElements(' . json_encode($this->elements
) . ');
1534 // Ending page, returning content:
1535 $content .= $this->doc
->endPage();
1536 $content = $this->doc
->insertStylesAndJS($content);
1541 * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for folders.
1543 * @return string HTML content for the module
1545 public function main_folder() {
1547 // Setting prefs for foldertree
1548 $this->doc
->getDragDropCode('folders', 'Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";');
1549 // Starting content:
1550 $content = $this->doc
->startPage('TBE folder selector');
1551 // Add the FlashMessages if any
1552 $content .= $this->doc
->getFlashMessages();
1554 $parameters = explode('|', $this->bparams
);
1555 if ($this->expandFolder
) {
1556 $this->selectedFolder
= ResourceFactory
::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder
);
1558 if ($this->selectedFolder
) {
1559 $createFolder = $this->createFolder($this->selectedFolder
);
1563 // Create folder tree:
1564 /** @var ElementBrowserFolderTreeView $folderTree */
1565 $folderTree = GeneralUtility
::makeInstance(ElementBrowserFolderTreeView
::class);
1566 $folderTree->thisScript
= $this->thisScript
;
1567 $folderTree->ext_noTempRecyclerDirs
= $this->mode
=== 'filedrag';
1568 $tree = $folderTree->getBrowsableTree();
1570 if ($this->selectedFolder
) {
1571 if ($this->mode
== 'filedrag') {
1572 $folders = $this->TBE_dragNDrop($this->selectedFolder
, $parameters[3]);
1574 $folders = $this->TBE_expandSubFolders($this->selectedFolder
);
1577 // Putting the parts together, side by side:
1581 Wrapper table for folder tree / folder list:
1583 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
1585 <td class="c-wCell" valign="top">' . $this->barheader(($this->getLanguageService()->getLL('folderTree') . ':'))
1587 <td class="c-wCell" valign="top">' . $folders . '</td>
1591 // Adding create folder if applicable:
1592 $content .= $createFolder;
1594 $content .= '<br /><br />';
1595 // Ending page, returning content:
1596 $content .= $this->doc
->endPage();
1597 $content = $this->doc
->insertStylesAndJS($content);
1601 /******************************************************************
1605 ******************************************************************/
1607 * For RTE: This displays all content elements on a page and lets you create a link to the element.
1609 * @return string HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...)
1611 public function expandPage() {
1613 // Set page id (if any) to expand
1614 $expPageId = $this->expandPage
;
1615 // If there is an anchor value (content element reference) in the element reference, then force an ID to expand:
1616 if (!$this->expandPage
&& $this->curUrlInfo
['cElement']) {
1617 // Set to the current link page id.
1618 $expPageId = $this->curUrlInfo
['pageid'];
1620 // Draw the record list IF there is a page id to expand:
1622 && MathUtility
::canBeInterpretedAsInteger($expPageId)
1623 && $this->getBackendUser()->isInWebMount($expPageId)
1626 $out .= $this->barheader($this->getLanguageService()->getLL('contentElements') . ':');
1627 // Create header for listing, showing the page title/icon:
1628 $mainPageRec = BackendUtility
::getRecordWSOL('pages', $expPageId);
1629 $db = $this->getDatabaseConnection();
1631 <ul class="list-tree list-tree-root list-tree-root-clean">
1632 <li class="list-tree-control-open">
1633 <span class="list-tree-group">
1634 <span class="list-tree-icon">' . IconUtility
::getSpriteIconForRecord('pages', $mainPageRec) . '</span>
1635 <span class="list-tree-title">' . BackendUtility
::getRecordTitle('pages', $mainPageRec, TRUE) . '</span>
1640 // Look up tt_content elements from the expanded page:
1641 $res = $db->exec_SELECTquery(
1642 'uid,header,hidden,starttime,endtime,fe_group,CType,colPos,bodytext',
1644 'pid=' . (int)$expPageId . BackendUtility
::deleteClause('tt_content')
1645 . BackendUtility
::versioningPlaceholderClause('tt_content'),
1649 $cc = $db->sql_num_rows($res);
1650 // Traverse list of records:
1652 while ($row = $db->sql_fetch_assoc($res)) {
1654 $icon = IconUtility
::getSpriteIconForRecord('tt_content', $row);
1656 if ($this->curUrlInfo
['act'] == 'page' && $this->curUrlInfo
['cElement'] == $row['uid']) {
1657 $selected = ' class="active"';
1659 // Putting list element HTML together:
1661 <li' . $selected . '>
1662 <span class="list-tree-group">
1663 <span class="list-tree-icon">
1666 <span class="list-tree-title">
1667 <a href="#" onclick="return link_typo3Page(\'' . $expPageId . '\',\'#' . $row['uid'] . '\');">
1668 ' . BackendUtility
::getRecordTitle('tt_content', $row, TRUE) . '
1685 * For TYPO3 Element Browser: This lists all content elements from the given list of tables
1687 * @param string $tables Comma separated list of tables. Set to "*" if you want all tables.
1688 * @return string HTML output.
1690 public function TBE_expandPage($tables) {
1691 $backendUser = $this->getBackendUser();
1692 if (!MathUtility
::canBeInterpretedAsInteger($this->expandPage
)
1693 ||
$this->expandPage
< 0
1694 ||
!$backendUser->isInWebMount($this->expandPage
)
1698 // Set array with table names to list:
1699 if (trim($tables) === '*') {
1700 $tablesArr = array_keys($GLOBALS['TCA']);
1702 $tablesArr = GeneralUtility
::trimExplode(',', $tables, TRUE);
1705 // Headline for selecting records:
1706 $out = $this->barheader($this->getLanguageService()->getLL('selectRecords') . ':');
1707 // Create the header, showing the current page for which the listing is.
1708 // Includes link to the page itself, if pages are amount allowed tables.
1709 $titleLen = (int)$backendUser->uc
['titleLen'];
1710 $mainPageRec = BackendUtility
::getRecordWSOL('pages', $this->expandPage
);
1715 if (is_array($mainPageRec)) {
1716 $picon = IconUtility
::getSpriteIconForRecord('pages', $mainPageRec);
1717 if (in_array('pages', $tablesArr)) {
1718 $ATag = '<a href="#" onclick="return insertElement(\'pages\', \'' . $mainPageRec['uid'] . '\', \'db\', '
1719 . GeneralUtility
::quoteJSvalue($mainPageRec['title']) . ', \'\', \'\', \'\',\'\',1);">';
1720 $ATag2 = '<a href="#" onclick="return insertElement(\'pages\', \'' . $mainPageRec['uid'] . '\', \'db\', '
1721 . GeneralUtility
::quoteJSvalue($mainPageRec['title']) . ', \'\', \'\', \'\',\'\',0);">';
1725 $pBicon = $ATag2 ? IconUtility
::getSpriteIcon('actions-edit-add') : '';
1726 $pText = htmlspecialchars(GeneralUtility
::fixed_lgd_cs($mainPageRec['title'], $titleLen));
1727 $out .= $picon . $ATag2 . $pBicon . $ATag_e . $ATag . $pText . $ATag_e . '<br />';
1728 // Initialize the record listing:
1729 $id = $this->expandPage
;
1730 $pointer = MathUtility
::forceIntegerInRange($this->pointer
, 0, 100000);
1731 $perms_clause = $backendUser->getPagePermsClause(1);
1732 $pageInfo = BackendUtility
::readPageAccess($id, $perms_clause);
1733 // Generate the record list:
1734 /** @var $dbList ElementBrowserRecordList */
1735 if (is_object($this->recordList
)) {
1736 $dbList = $this->recordList
;
1738 $dbList = GeneralUtility
::makeInstance(ElementBrowserRecordList
::class);
1740 $dbList->thisScript
= $this->thisScript
;
1741 $dbList->thumbs
= 0;
1742 $dbList->localizationView
= 1;
1743 $dbList->setIsEditable(FALSE);
1744 $dbList->calcPerms
= $backendUser->calcPerms($pageInfo);
1745 $dbList->noControlPanels
= 1;
1746 $dbList->clickMenuEnabled
= 0;
1747 $dbList->tableList
= implode(',', $tablesArr);
1748 $pArr = explode('|', $this->bparams
);
1749 // a string like "data[pages][79][storage_pid]"
1750 $fieldPointerString = $pArr[0];
1751 // parts like: data, pages], 79], storage_pid]
1752 $fieldPointerParts = explode('[', $fieldPointerString);
1753 $relatingTableName = substr($fieldPointerParts[1], 0, -1);
1754 $relatingFieldName = substr($fieldPointerParts[3], 0, -1);
1755 if ($relatingTableName && $relatingFieldName) {
1756 $dbList->setRelatingTableAndField($relatingTableName, $relatingFieldName);
1758 $dbList->start($id, GeneralUtility
::_GP('table'), $pointer, GeneralUtility
::_GP('search_field'),
1759 GeneralUtility
::_GP('search_levels'), GeneralUtility
::_GP('showLimit')
1761 $dbList->setDispFields();
1762 $dbList->generateList();
1763 $out .= $dbList->getSearchBox();
1764 $out .= "<script>document.getElementById('db_list-searchbox-toolbar').style.display = 'block';document.getElementById('db_list-searchbox-toolbar').style.position = 'relative';</script>";
1766 // Add the HTML for the record list to output variable:
1767 $out .= $dbList->HTMLcode
;
1768 // Add support for fieldselectbox in singleTableMode
1769 if ($dbList->table
) {
1770 $out .= $dbList->fieldSelectBox($dbList->table
);
1773 // Return accumulated content:
1778 * Render list of folders inside a folder.
1780 * @param Folder $folder Folder
1781 * @return string HTML output
1783 public function TBE_expandSubFolders(Folder
$folder) {
1785 if ($folder->checkActionPermission('read')) {
1786 $content .= $this->folderList($folder);
1788 // Return accumulated content for folderlisting:
1792 /******************************************************************
1796 ******************************************************************/
1798 * For RTE: This displays all files from folder. No thumbnails shown
1800 * @param Folder $folder The folder path to expand
1801 * @param string $extensionList List of file extensions to show
1802 * @return string HTML output
1804 public function expandFolder(Folder
$folder, $extensionList = '') {
1805 if (!$folder->checkActionPermission('read')) {
1808 $lang = $this->getLanguageService();
1809 $renderFolders = $this->act
=== 'folder';
1810 // Create header for file/folder listing:
1811 if ($renderFolders) {
1812 $out = $this->barheader($lang->getLL('folders') . ':');
1814 $out = $this->barheader($lang->getLL('files') . ':');
1816 // Prepare current path value for comparison (showing red arrow)
1817 $currentIdentifier = '';
1818 if ($this->curUrlInfo
['value']) {
1819 $currentIdentifier = $this->curUrlInfo
['info'];
1821 // Create header element; The folder from which files are listed.
1822 $titleLen = (int)$this->getBackendUser()->uc
['titleLen'];
1823 $folderIcon = IconUtility
::getSpriteIconForResource($folder);
1824 $folderIcon .= htmlspecialchars(GeneralUtility
::fixed_lgd_cs($folder->getIdentifier(), $titleLen));
1826 if ($this->curUrlInfo
['act'] == 'folder' && $currentIdentifier == $folder->getCombinedIdentifier()) {
1827 $selected = ' class="bg-success"';
1830 <a href="#"' . $selected . ' title="' . htmlspecialchars($folder->getIdentifier()) . '" onclick="return link_folder(\'file:' . $folder->getCombinedIdentifier() . '\');">
1834 // Get files from the folder:
1835 if ($renderFolders) {
1836 $items = $folder->getSubfolders();
1838 $items = $this->getFilesInFolder($folder, $extensionList);
1842 if (!empty($items)) {
1843 $out .= '<ul class="list-tree list-tree-root">';
1844 foreach ($items as $fileOrFolderObject) {
1846 if ($renderFolders) {
1847 $fileIdentifier = $fileOrFolderObject->getCombinedIdentifier();
1848 $overlays = array();
1849 if ($fileOrFolderObject instanceof InaccessibleFolder
) {
1850 $overlays = array('status-overlay-locked' => array());
1852 $icon = IconUtility
::getSpriteIcon(
1853 IconUtility
::mapFileExtensionToSpriteIconName('folder'),
1854 array('title' => $fileOrFolderObject->getName()),
1856 $itemUid = 'file:' . $fileIdentifier;
1858 $fileIdentifier = $fileOrFolderObject->getUid();
1859 // Get size and icon:
1860 $size = ' (' . GeneralUtility
::formatSize($fileOrFolderObject->getSize()) . 'bytes)';
1861 $icon = IconUtility
::getSpriteIconForResource($fileOrFolderObject, array('title' => $fileOrFolderObject->getName() . $size));
1862 $itemUid = 'file:' . $fileIdentifier;
1865 if (($this->curUrlInfo
['act'] == 'file' ||
$this->curUrlInfo
['act'] == 'folder')
1866 && $currentIdentifier == $fileIdentifier
1868 $selected = ' class="active"';
1870 // Put it all together for the file element:
1872 '<li' . $selected . '>
1873 <a href="#"title="' . htmlspecialchars($fileOrFolderObject->getName()) . '" onclick="return link_folder(\'' . $itemUid . '\');">
1875 ' . htmlspecialchars(GeneralUtility
::fixed_lgd_cs($fileOrFolderObject->getName(), $titleLen)) . '
1885 * For TYPO3 Element Browser: Expand folder of files.
1887 * @param Folder $folder The folder path to expand
1888 * @param string $extensionList List of fileextensions to show
1889 * @param bool $noThumbs Whether to show thumbnails or not. If set, no thumbnails are shown.
1890 * @return string HTML output
1892 public function TBE_expandFolder(Folder
$folder, $extensionList = '', $noThumbs = FALSE) {
1893 if (!$folder->checkActionPermission('read')) {
1896 $extensionList = $extensionList == '*' ?
'' : $extensionList;
1897 $files = $this->getFilesInFolder($folder, $extensionList);
1898 return $this->fileList($files, $folder, $noThumbs);
1902 * Render list of files.
1904 * @param File[] $files List of files
1905 * @param Folder $folder If set a header with a folder icon and folder name are shown
1906 * @param bool $noThumbs Whether to show thumbnails or not. If set, no thumbnails are shown.
1907 * @return string HTML output
1909 protected function fileList(array $files, Folder
$folder = NULL, $noThumbs = FALSE) {
1912 $lang = $this->getLanguageService();
1914 // Create headline (showing number of files):
1915 $filesCount = count($files);
1916 $out .= $this->barheader(sprintf($lang->getLL('files') . ' (%s):', $filesCount));
1917 $out .= '<div id="filelist">';
1918 $out .= $this->getBulkSelector($filesCount);
1919 $titleLen = (int)$this->getBackendUser()->uc
['titleLen'];
1920 // Create the header of current folder:
1922 $folderIcon = IconUtility
::getSpriteIconForResource($folder);
1923 $lines[] = '<tr class="t3-row-header">
1924 <td colspan="4">' . $folderIcon
1925 . htmlspecialchars(GeneralUtility
::fixed_lgd_cs($folder->getIdentifier(), $titleLen)) . '</td>
1928 if ($filesCount == 0) {
1930 <tr class="file_list_normal">
1931 <td colspan="4">No files found.</td>
1934 // Traverse the filelist:
1935 /** @var $fileObject \TYPO3\CMS\Core\Resource\File */
1936 foreach ($files as $fileObject) {
1937 $fileExtension = $fileObject->getExtension();
1938 // Thumbnail/size generation:
1940 if (GeneralUtility
::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']), strtolower($fileExtension)) && !$noThumbs) {
1941 $processedFile = $fileObject->process(
1942 ProcessedFile
::CONTEXT_IMAGEPREVIEW
,
1943 array('width' => 64, 'height' => 64)
1945 $imageUrl = $processedFile->getPublicUrl(TRUE);
1947 $fileObject->getProperty('width'),
1948 $fileObject->getProperty('height')
1950 $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels';
1951 $clickIcon = '<img src="' . $imageUrl . '" ' .
1952 'width="' . $processedFile->getProperty('width') . '" ' .
1953 'height="' . $processedFile->getProperty('height') . '" ' .
1954 'hspace="5" vspace="5" border="1" />';
1959 // Create file icon:
1960 $size = ' (' . GeneralUtility
::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ?
', ' . $pDim : '') . ')';
1961 $icon = IconUtility
::getSpriteIconForResource($fileObject, array('title' => $fileObject->getName() . $size));
1962 // Create links for adding the file:
1963 $filesIndex = count($this->elements
);
1964 $this->elements
['file_' . $filesIndex] = array(
1966 'table' => 'sys_file',
1967 'uid' => $fileObject->getUid(),
1968 'fileName' => $fileObject->getName(),
1969 'filePath' => $fileObject->getUid(),
1970 'fileExt' => $fileExtension,
1973 if ($this->fileIsSelectableInFileList($fileObject, $imgInfo)) {
1974 $ATag = '<a href="#" title="' . htmlspecialchars($fileObject->getName()) . '" onclick="return BrowseLinks.File.insertElement(\'file_' . $filesIndex . '\');">';
1975 $ATag_alt = substr($ATag, 0, -4) . ',1);">';
1976 $bulkCheckBox = '<input type="checkbox" class="typo3-bulk-item" name="file_' . $filesIndex . '" value="0" /> ';
1984 // Create link to showing details about the file in a window:
1985 $Ahref = BackendUtility
::getModuleUrl('show_item', array(
1988 'uid' => $fileObject->getCombinedIdentifier(),
1989 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')
1991 $ATag2 = '<a href="' . htmlspecialchars($Ahref) . '">';
1993 // Combine the stuff:
1994 $filenameAndIcon = $bulkCheckBox . $ATag_alt . $icon
1995 . htmlspecialchars(GeneralUtility
::fixed_lgd_cs($fileObject->getName(), $titleLen)) . $ATag_e;
2000 <tr class="file_list_normal">
2001 <td nowrap="nowrap">' . $filenameAndIcon . ' </td>
2002 <td>' . $ATag . IconUtility
::getSpriteIcon('actions-edit-add', array('title' => $lang->getLL('addToList', TRUE))) . $ATag_e . '</td>
2003 <td nowrap="nowrap"><a href="' . htmlspecialchars($Ahref) . '" title="' . $lang->getLL('info', TRUE) . '">' . $this->iconFactory
->getIcon('actions-document-info', Icon
::SIZE_SMALL
) . $lang->getLL('info', TRUE) . $ATag2_e . '</td>
2004 <td nowrap="nowrap"> ' . $pDim . '</td>
2008 <td class="filelistThumbnail" colspan="4">' . $ATag_alt . $clickIcon . $ATag_e . '</td>
2012 <tr class="file_list_normal">
2013 <td nowrap="nowrap">' . $filenameAndIcon . ' </td>
2014 <td>' . $ATag . IconUtility
::getSpriteIcon('actions-edit-add', array('title' => $lang->getLL('addToList', TRUE))) . $ATag_e . '</td>
2015 <td nowrap="nowrap"><a href="' . htmlspecialchars($Ahref) . '" title="' . $lang->getLL('info', TRUE) . '">' . $this->iconFactory
->getIcon('actions-document-info', Icon
::SIZE_SMALL
) . $lang->getLL('info', TRUE) . $ATag2_e . '</td>
2020 // Wrap all the rows in table tags:
2026 <table cellpadding="0" cellspacing="0" id="typo3-filelist">
2027 ' . implode('', $lines) . '
2029 // Return accumulated content for filelisting:
2035 * Checks if the given file is selectable in the filelist.
2037 * By default all files are selectable. This method may be overwritten in child classes.
2039 * @param FileInterface $file
2040 * @param mixed[] $imgInfo Image dimensions from \TYPO3\CMS\Core\Imaging\GraphicalFunctions::getImageDimensions()
2041 * @return bool TRUE if file is selectable.
2043 protected function fileIsSelectableInFileList(FileInterface
$file, array $imgInfo) {
2048 * Render list of folders.
2050 * @param Folder $baseFolder
2051 * @return string HTML output
2053 public function folderList(Folder
$baseFolder) {
2055 $lang = $this->getLanguageService();
2056 $folders = $baseFolder->getSubfolders();
2057 $folderIdentifier = $baseFolder->getCombinedIdentifier();
2058 // Create headline (showing number of folders):
2059 $content .= $this->barheader(sprintf($lang->getLL('folders') . ' (%s):', count($folders)));
2060 $titleLength = (int)$this->getBackendUser()->uc
['titleLen'];
2061 // Create the header of current folder:
2062 $aTag = '<a href="#" onclick="return insertElement(\'\',' . GeneralUtility
::quoteJSvalue($folderIdentifier)
2063 . ', \'folder\', ' . GeneralUtility
::quoteJSvalue($folderIdentifier) . ', ' . GeneralUtility
::quoteJSvalue($folderIdentifier)
2064 . ', \'\', \'\',\'\',1);">';
2065 // Add the foder icon
2066 $folderIcon = $aTag;
2067 $folderIcon .= IconUtility
::getSpriteIcon('apps-filetree-folder-default');
2068 $folderIcon .= htmlspecialchars(GeneralUtility
::fixed_lgd_cs($baseFolder->getName(), $titleLength));
2069 $folderIcon .= '</a>';
2070 $content .= $folderIcon . '<br />';
2073 // Traverse the folder list:
2074 foreach ($folders as $subFolder) {
2075 $subFolderIdentifier = $subFolder->getCombinedIdentifier();
2076 // Create folder icon:
2077 $icon = '<span style="width: 16px; height: 16px; display: inline-block;"></span>';
2078 $icon .= IconUtility
::getSpriteIcon('apps-filetree-folder-default', array('title' => htmlspecialchars($subFolder->getName())));
2079 // Create links for adding the folder:
2080 if ($this->P
['itemName'] != '' && $this->P
['formName'] != '') {
2081 $aTag = '<a href="#" onclick="return set_folderpath(' . GeneralUtility
::quoteJSvalue($subFolderIdentifier)
2084 $aTag = '<a href="#" onclick="return insertElement(\'\',' . GeneralUtility
::quoteJSvalue($subFolderIdentifier)
2085 . ', \'folder\', ' . GeneralUtility
::quoteJSvalue($subFolderIdentifier) . ', '
2086 . GeneralUtility
::quoteJSvalue($subFolderIdentifier) . ', \'\', \'\');">';
2088 if (strstr($subFolderIdentifier, ',') ||
strstr($subFolderIdentifier, '|')) {
2089 // In case an invalid character is in the filepath, display error message:
2090 $errorMessage = GeneralUtility
::quoteJSvalue(sprintf($lang->getLL('invalidChar'), ', |'));
2091 $aTag = ($aTag_alt = '<a href="#" onclick="alert(' . $errorMessage . ');return false;">');
2093 // If foldername is OK, just add it:
2094 $aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
2097 // Combine icon and folderpath:
2098 $foldernameAndIcon = $aTag_alt . $icon
2099 . htmlspecialchars(GeneralUtility
::fixed_lgd_cs($subFolder->getName(), $titleLength)) . $aTag_e;
2100 if ($this->P
['itemName'] != '') {
2102 <tr class="bgColor4">
2103 <td nowrap="nowrap">' . $foldernameAndIcon . ' </td>
2108 <tr class="bgColor4">
2109 <td nowrap="nowrap">' . $foldernameAndIcon . ' </td>
2110 <td>' . $aTag . IconUtility
::getSpriteIcon('actions-edit-add', array('title' => $lang->getLL('addToList', TRUE))) . $aTag_e . ' </td>
2116 <td colspan="3"><span style="width: 1px; height: 3px; display: inline-block;"></span></td>
2119 // Wrap all the rows in table tags:
2125 <table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList">
2126 ' . implode('', $lines) . '
2128 // Return accumulated content for folderlisting:
2133 * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
2134 * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
2136 * @param Folder $folder The folder path to expand
2137 * @param string $extensionList List of file extensions to show
2138 * @return string HTML output
2140 public function TBE_dragNDrop(Folder
$folder, $extensionList = '') {
2144 $lang = $this->getLanguageService();
2145 if (!$folder->getStorage()->isPublic()) {
2146 // Print this warning if the folder is NOT a web folder
2147 return GeneralUtility
::makeInstance(FlashMessage
::class, $lang->getLL('noWebFolder'), $lang->getLL('files'), FlashMessage
::WARNING
)
2152 // Read files from directory:
2153 $extensionList = $extensionList == '*' ?
'' : $extensionList;
2154 $files = $this->getFilesInFolder($folder, $extensionList);
2156 $out .= $this->barheader(sprintf($lang->getLL('files') . ' (%s):', count($files)));
2157 $titleLen = (int)$this->getBackendUser()->uc
['titleLen'];
2158 $picon = IconUtility
::getSpriteIcon('apps-filetree-folder-default');
2159 $picon .= htmlspecialchars(GeneralUtility
::fixed_lgd_cs(basename($folder->getName()), $titleLen));
2160 $out .= $picon . '<br />';
2163 // Add "drag-n-drop" message:
2164 $infoText = GeneralUtility
::makeInstance(FlashMessage
::class, $lang->getLL('findDragDrop'), '', FlashMessage
::INFO
)
2168 <td colspan="2">' . $infoText . '</td>
2171 foreach ($files as $fileObject) {
2173 $iUrl = GeneralUtility
::rawurlencodeFP($fileObject->getPublicUrl(TRUE));
2174 // Show only web-images
2175 $fileExtension = strtolower($fileObject->getExtension());
2176 if (GeneralUtility
::inList('gif,jpeg,jpg,png', $fileExtension)) {
2178 $fileObject->getProperty('width'),
2179 $fileObject->getProperty('height')
2181 $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels';
2182 $size = ' (' . GeneralUtility
::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ?
', ' . $pDim : '') . ')';
2183 $filenameAndIcon = IconUtility
::getSpriteIconForResource($fileObject, array('title' => $fileObject->getName() . $size));
2184 if (GeneralUtility
::_GP('noLimit')) {
2194 $IH = ceil($IH / $IW * $maxW);
2198 $IW = ceil($IW / $IH * $maxH);
2203 <tr class="bgColor4">
2204 <td nowrap="nowrap">' . $filenameAndIcon . ' </td>
2205 <td nowrap="nowrap">' . ($imgInfo[0] != $IW
2206 ?
'<a href="' . htmlspecialchars(GeneralUtility
::linkThisScript(array('noLimit' => '1')))
2207 . '">' . IconUtility
::getSpriteIcon('status-dialog-warning', array('title' => $lang->getLL('clickToRedrawFullSize', TRUE)))
2210 . $pDim . ' </td>
2214 <td colspan="2"><img src="' . htmlspecialchars($iUrl) . '" data-htmlarea-file-uid="' . $fileObject->getUid()
2215 . '" width="' . htmlspecialchars($IW) . '" height="' . htmlspecialchars($IH) . '" border="1" alt="" /></td>
2219 <td colspan="2"><span style="width: 1px; height: 3px; display: inline-block;"></span></td>
2223 // Finally, wrap all rows in a table tag:
2228 Filelisting / Drag-n-drop
2230 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
2231 ' . implode('', $lines) . '
2237 /******************************************************************
2239 * Miscellaneous functions
2241 ******************************************************************/
2244 * Prints a 'header' where string is in a tablecell
2246 * @param string $str The string to print in the header. The value is htmlspecialchars()'ed before output.
2247 * @return string The header HTML (wrapped in a table)
2249 public function barheader($str) {
2251 <!-- Bar header: -->
2252 <h3>' . htmlspecialchars($str) . '</h3>
2257 * For RTE/link: This prints the 'currentUrl'
2259 * @param string $str URL value. The value is htmlspecialchars()'ed before output.
2260 * @return string HTML content, wrapped in a table.
2262 public function printCurrentUrl($str) {
2263 // Output the folder or file identifier, when working with files
2264 if (isset($str) && MathUtility
::canBeInterpretedAsInteger($str)) {
2266 $fileObject = ResourceFactory
::getInstance()->retrieveFileOrFolderObject($str);
2267 } catch (Exception\FileDoesNotExistException
$e) {
2270 $str = is_object($fileObject) ?
$fileObject->getIdentifier() : '';
2274 <!-- Print current URL -->
2275 <table border="0" cellpadding="0" cellspacing="0" id="typo3-curUrl">
2277 <td>' . $this->getLanguageService()->getLL('currentLink', TRUE) . ': '
2278 . htmlspecialchars(rawurldecode($str)) . '</td>
2287 * For RTE/link: Parses the incoming URL and determines if it's a page, file, external or mail address.
2289 * @param string $href HREF value tp analyse
2290 * @param string $siteUrl The URL of the current website (frontend)
2291 * @return array[] Array with URL information stored in assoc. keys: value, act (page, file, mail), pageid, cElement, info
2293 public function parseCurUrl($href, $siteUrl) {
2294 $href = trim($href);
2295 $lang = $this->getLanguageService();
2298 // Default is "url":
2299 $info['value'] = $href;
2300 $info['act'] = 'url';
2301 if (!StringUtility
::beginsWith($href, 'file://') && strpos($href, 'file:') !== FALSE) {
2302 $rel = substr($href, strpos($href, 'file:') +
5);
2303 $rel = rawurldecode($rel);
2305 // resolve FAL-api "file:UID-of-sys_file-record" and "file:combined-identifier"
2306 $fileOrFolderObject = ResourceFactory
::getInstance()->retrieveFileOrFolderObject($rel);
2307 if ($fileOrFolderObject instanceof Folder
) {
2308 $info['act'] = 'folder';
2309 $info['value'] = $fileOrFolderObject->getCombinedIdentifier();
2310 } elseif ($fileOrFolderObject instanceof File
) {
2311 $info['act'] = 'file';
2312 $info['value'] = $fileOrFolderObject->getUid();
2314 $info['value'] = $rel;
2316 } catch (Exception\FileDoesNotExistException
$e) {
2317 // file was deleted or any other reason, don't select any item
2318 if (MathUtility
::canBeInterpretedAsInteger($rel)) {
2319 $info['act'] = 'file';
2321 $info['act'] = 'folder';
2323 $info['value'] = '';
2325 } elseif (StringUtility
::beginsWith($href, $siteUrl)) {
2326 // If URL is on the current frontend website:
2327 // URL is a file, which exists:
2328 if (file_exists(PATH_site
. rawurldecode($href))) {
2329 $info['value'] = rawurldecode($href);
2330 if (@is_dir
((PATH_site
. $info['value']))) {
2331 $info['act'] = 'folder';
2333 $info['act'] = 'file';
2336 // URL is a page (id parameter)
2337 $uP = parse_url($href);
2339 $pp = preg_split('/^id=/', $uP['query']);
2340 $pp[1] = preg_replace('/&id=[^&]*/', '', $pp[1]);
2341 $parameters = explode('&', $pp[1]);
2342 $id = array_shift($parameters);
2344 // Checking if the id-parameter is an alias.
2345 if (!MathUtility
::canBeInterpretedAsInteger($id)) {
2346 list($idPartR) = BackendUtility
::getRecordsByField('pages', 'alias', $id);
2347 $id = (int)$idPartR['uid'];
2349 $pageRow = BackendUtility
::getRecordWSOL('pages', $id);
2350 $titleLen = (int)$this->getBackendUser()->uc
['titleLen'];
2351 $info['value'] = ((((($lang->getLL('page', TRUE) . ' \'')
2352 . htmlspecialchars(GeneralUtility
::fixed_lgd_cs($pageRow['title'], $titleLen)))
2353 . '\' (ID:') . $id) . ($uP['fragment'] ?
', #' . $uP['fragment'] : '')) . ')';
2354 $info['pageid'] = $id;
2355 $info['cElement'] = $uP['fragment'];
2356 $info['act'] = 'page';
2357 $info['query'] = $parameters[0] ?
'&' . implode('&', $parameters) : '';
2362 if (strtolower(substr($href, 0, 7)) === 'mailto:') {
2363 $info['value'] = trim(substr($href, 7));
2364 $info['act'] = 'mail';
2367 $info['info'] = $info['value'];
2371 $info['info'] = $lang->getLL('none');
2372 $info['value'] = '';
2373 $info['act'] = 'page';
2375 // let the hook have a look
2376 foreach ($this->hookObjects
as $hookObject) {
2377 $info = $hookObject->parseCurrentUrl($href, $siteUrl, $info);
2383 * Setter for the class that should be used by TBE_expandPage() to generate the record list.
2384 * This method is intended to be used by Extensions that implement their own browsing functionality.
2386 * @param ElementBrowserRecordList $recordList
2387 * @throws \InvalidArgumentException
2391 public function setRecordList($recordList) {
2392 if (!$recordList instanceof ElementBrowserRecordList
) {
2393 throw new \
InvalidArgumentException('$recordList needs to be an instance of ' . ElementBrowserRecordList
::class, 1370878522);
2395 $this->recordList
= $recordList;
2399 * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
2400 * The files are uploaded to the tce_file.php script in the core which will handle the upload.
2402 * @param Folder $folderObject Absolute filepath on server to which to upload.
2403 * @return string HTML for an upload form.
2405 public function uploadForm(Folder
$folderObject) {
2406 if (!$folderObject->checkActionPermission('write')) {
2409 // Read configuration of upload field count
2410 $userSetting = $this->getBackendUser()->getTSConfigVal('options.folderTree.uploadFieldsInLinkBrowser');
2411 $count = isset($userSetting) ?
$userSetting : 1;
2412 if ($count === '0') {
2415 $count = (int)$count === 0 ?
1 : (int)$count;
2416 // Create header, showing upload path:
2417 $header = $folderObject->getIdentifier();
2418 $lang = $this->getLanguageService();
2422 Form, for uploading files:
2424 <form action="' . htmlspecialchars(BackendUtility
::getModuleUrl('tce_file')) . '" method="post" name="editform"'
2425 . ' id="typo3-uplFilesForm" enctype="multipart/form-data">
2426 <table border="0" cellpadding="0" cellspacing="0" id="typo3-uplFiles">
2428 <td>' . $this->barheader($lang->sL(
2429 'LLL:EXT:lang/locallang_core.xlf:file_upload.php.pagetitle', TRUE) . ':') . '</td>
2432 <td class="c-wCell c-hCell"><strong>' . $lang->getLL('path', TRUE) . ':</strong> '
2433 . htmlspecialchars($header) . '</td>
2436 <td class="c-wCell c-hCell">';
2437 // Traverse the number of upload fields (default is 3):
2438 for ($a = 1; $a <= $count; $a++
) {
2439 $code .= '<input type="file" multiple="multiple" name="upload_' . $a . '[]"' . $this->doc
->formWidth(35)
2441 <input type="hidden" name="file[upload][' . $a . '][target]" value="'
2442 . htmlspecialchars($folderObject->getCombinedIdentifier()) . '" />
2443 <input type="hidden" name="file[upload][' . $a . '][data]" value="' . $a . '" /><br />';
2445 // Make footer of upload form, including the submit button:
2446 $redirectValue = $this->getThisScript() . 'act=' . $this->act
. '&mode=' . $this->mode
2447 . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier())
2448 . '&bparams=' . rawurlencode($this->bparams
)
2449 . (is_array($this->P
) ? GeneralUtility
::implodeArrayForUrl('P', $this->P
) : '');
2450 $code .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($redirectValue) . '" />';
2451 $code .= FormEngine
::getHiddenTokenField('tceAction');
2453 <div id="c-override">
2455 <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> '
2456 . $lang->sL('LLL:EXT:lang/locallang_misc.xlf:overwriteExistingFiles', TRUE) . '
2459 <input class="btn btn-default" type="submit" name="submit" value="'
2460 . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_upload.php.submit', TRUE) . '" />
2470 * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
2471 * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
2473 * @param Folder $folderObject Absolute filepath on server in which to create the new folder.
2474 * @return string HTML for the create folder form.
2476 public function createFolder(Folder
$folderObject) {
2477 if (!$folderObject->checkActionPermission('write')) {
2480 $backendUser = $this->getBackendUser();
2481 if (!($backendUser->isAdmin() ||
$backendUser->getTSConfigVal('options.createFoldersInEB'))) {
2484 // Don't show Folder-create form if it's denied
2485 if ($backendUser->getTSConfigVal('options.folderTree.hideCreateFolder')) {
2488 $lang = $this->getLanguageService();
2489 // Create header, showing upload path:
2490 $header = $folderObject->getIdentifier();
2494 Form, for creating new folders:
2496 <form action="' . htmlspecialchars(BackendUtility
::getModuleUrl('tce_file')) . '" method="post" name="editform2" id="typo3-crFolderForm">
2497 <table border="0" cellpadding="0" cellspacing="0" id="typo3-crFolder">
2499 <td>' . $this->barheader($lang->sL(
2500 'LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.pagetitle') . ':') . '</td>
2503 <td class="c-wCell c-hCell"><strong>'
2504 . $lang->getLL('path', TRUE) . ':</strong> ' . htmlspecialchars($header) . '</td>
2507 <td class="c-wCell c-hCell">';
2508 // Create the new-folder name field:
2510 $code .= '<input' . $this->doc
->formWidth(20) . ' type="text" name="file[newfolder][' . $a . '][data]" />'
2511 . '<input type="hidden" name="file[newfolder][' . $a . '][target]" value="'
2512 . htmlspecialchars($folderObject->getCombinedIdentifier()) . '" />';
2513 // Make footer of upload form, including the submit button:
2514 $redirectValue = $this->getThisScript() . 'act=' . $this->act
. '&mode=' . $this->mode
2515 . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier())
2516 . '&bparams=' . rawurlencode($this->bparams
)
2517 . (is_array($this->P
) ? GeneralUtility
::implodeArrayForUrl('P', $this->P
) : '');
2518 $code .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($redirectValue) . '" />'
2519 . FormEngine
::getHiddenTokenField('tceAction')
2520 . '<input class="btn btn-default" type="submit" name="submit" value="'
2521 . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.submit', TRUE) . '" />';
2530 * Get the HTML data required for a bulk selection of files of the TYPO3 Element Browser.
2532 * @param int $filesCount Number of files currently displayed
2533 * @return string HTML data required for a bulk selection of files - if $filesCount is 0, nothing is returned
2535 public function getBulkSelector($filesCount) {
2540 $lang = $this->getLanguageService();
2541 $labelToggleSelection = $lang->sL('LLL:EXT:lang/locallang_browse_links.xlf:toggleSelection', TRUE);
2542 $labelImportSelection = $lang->sL('LLL:EXT:lang/locallang_browse_links.xlf:importSelection', TRUE);
2543 // Getting flag for showing/not showing thumbnails:
2544 $noThumbsInEB = $this->getBackendUser()->getTSConfigVal('options.noThumbsInEB');
2545 $out = $this->doc
->spacer(10) . '<div>' . '<a href="#" onclick="BrowseLinks.Selector.handle()"'
2546 . 'title="' . $labelImportSelection . '">'
2547 . $this->iconFactory
->getIcon('actions-document-import-t3d', Icon
::SIZE_SMALL
)
2548 . $labelImportSelection . '</a> '
2549 . '<a href="#" onclick="BrowseLinks.Selector.toggle()">'
2550 . IconUtility
::getSpriteIcon('actions-document-select', array('title' => $labelToggleSelection))
2551 . $labelToggleSelection . '</a>' . '</div>';
2552 if (!$noThumbsInEB && $this->selectedFolder
) {
2553 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
2554 $_MOD_MENU = array('displayThumbs' => '');
2555 $_MCONF['name'] = 'file_list';
2556 $_MOD_SETTINGS = BackendUtility
::getModuleData($_MOD_MENU, GeneralUtility
::_GP('SET'), $_MCONF['name']);
2557 $addParams = '&act=' . $this->act
. '&mode=' . $this->mode
2558 . '&expandFolder=' . rawurlencode($this->selectedFolder
->getCombinedIdentifier())
2559 . '&bparams=' . rawurlencode($this->bparams
);
2560 $thumbNailCheck = '<div class="checkbox"><label for="checkDisplayThumbs">' . BackendUtility
::getFuncCheck('', 'SET[displayThumbs]', $_MOD_SETTINGS['displayThumbs'],
2561 GeneralUtility
::_GP('M') ?
'' : $this->thisScript
, $addParams, 'id="checkDisplayThumbs"')
2562 . $lang->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:displayThumbs', TRUE) . '</label></div>';
2563 $out .= $this->doc
->spacer(5) . $thumbNailCheck . $this->doc
->spacer(15);
2565 $out .= $this->doc
->spacer(15);
2571 * Determines whether submitted field change functions are valid
2572 * and are coming from the system and not from an external abuse.
2574 * @param bool $handleFlexformSections Whether to handle flexform sections differently
2575 * @return bool Whether the submitted field change functions are valid
2577 protected function areFieldChangeFunctionsValid($handleFlexformSections = FALSE) {
2579 if (isset($this->P
['fieldChangeFunc']) && is_array($this->P
['fieldChangeFunc']) && isset($this->P
['fieldChangeFuncHash'])) {
2581 $pattern = '#\\[el\\]\\[(([^]-]+-[^]-]+-)(idx\\d+-)([^]]+))\\]#i';
2582 $fieldChangeFunctions = $this->P
['fieldChangeFunc'];
2583 // Special handling of flexform sections:
2584 // Field change functions are modified in JavaScript, thus the hash is always invalid
2585 if ($handleFlexformSections && preg_match($pattern, $this->P
['itemName'], $matches)) {
2586 $originalName = $matches[1];
2587 $cleanedName = $matches[2] . $matches[4];
2588 foreach ($fieldChangeFunctions as &$value) {
2589 $value = str_replace($originalName, $cleanedName, $value);
2593 $result = $this->P
['fieldChangeFuncHash'] === GeneralUtility
::hmac(serialize($fieldChangeFunctions));
2599 * Check if a temporary tree mount is set and return a cancel button
2603 protected function getTemporaryTreeMountCancelNotice() {
2604 if ((int)$this->getBackendUser()->getSessionData('pageTree_temporaryMountPoint') === 0) {
2607 $link = '<a href="' . htmlspecialchars(GeneralUtility
::linkThisScript(array('setTempDBmount' => 0))) . '">'
2608 . $this->getLanguageService()->sl('LLL:EXT:lang/locallang_core.xlf:labels.temporaryDBmount', TRUE) . '</a>';
2609 /** @var FlashMessage $flashMessage */
2610 $flashMessage = GeneralUtility
::makeInstance(
2611 FlashMessage
::class,
2616 return $flashMessage->render();
2620 * Get a list of Files in a folder filtered by extension
2622 * @param Folder $folder
2623 * @param string $extensionList
2624 * @return \TYPO3\CMS\Core\Resource\File[]
2626 protected function getFilesInFolder(Folder
$folder, $extensionList) {
2627 if ($extensionList !== '') {
2628 /** @var FileExtensionFilter $filter */
2629 $filter = GeneralUtility
::makeInstance(FileExtensionFilter
::class);
2630 $filter->setAllowedFileExtensions($extensionList);
2631 $folder->setFileAndFolderNameFilters(array(array($filter, 'filterFileList')));
2633 return $folder->getFiles();
2637 * @return LanguageService
2639 protected function getLanguageService() {
2640 return $GLOBALS['LANG'];
2644 * @return BackendUserAuthentication
2646 protected function getBackendUser() {
2647 return $GLOBALS['BE_USER'];
2651 * @return DatabaseConnection
2653 protected function getDatabaseConnection() {
2654 return $GLOBALS['TYPO3_DB'];
2658 * @return PageRenderer
2660 protected function getPageRenderer() {
2661 if ($this->pageRenderer
=== NULL) {
2662 $this->pageRenderer
= GeneralUtility
::makeInstance(PageRenderer
::class);
2665 return $this->pageRenderer
;