[CLEANUP] ElementBrowser controller classes 37/41737/5
authorMarkus Klein <markus.klein@typo3.org>
Mon, 20 Jul 2015 14:51:02 +0000 (16:51 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Wed, 22 Jul 2015 12:18:35 +0000 (14:18 +0200)
Resolves: #68394
Releases: master
Change-Id: Idb1c610465a351cd592242e902d7ebbd03439fcc
Reviewed-on: http://review.typo3.org/41737
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php
typo3/sysext/recordlist/Classes/Controller/ElementBrowserController.php
typo3/sysext/rtehtmlarea/Classes/BrowseLinks.php
typo3/sysext/rtehtmlarea/Classes/Controller/BrowseLinksController.php
typo3/sysext/rtehtmlarea/Classes/Controller/SelectImageController.php
typo3/sysext/rtehtmlarea/Classes/SelectImage.php
typo3/sysext/rtehtmlarea/Modules/BrowseLinks/index.php
typo3/sysext/rtehtmlarea/Modules/SelectImage/index.php

index 11f6848..4258152 100755 (executable)
@@ -17,6 +17,8 @@ namespace TYPO3\CMS\Recordlist\Browser;
 use TYPO3\CMS\Backend\Form\FormEngine;
 use TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList;
 use TYPO3\CMS\Backend\Template\DocumentTemplate;
+use TYPO3\CMS\Backend\Tree\View\ElementBrowserFolderTreeView;
+use TYPO3\CMS\Backend\Tree\View\ElementBrowserPageTreeView;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
@@ -478,7 +480,7 @@ class ElementBrowser {
         */
        protected function getRTEConfig() {
                $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
-               $RTEsetup = $this->getBackendUserAuthentication()->getTSConfig('RTE', BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
+               $RTEsetup = $this->getBackendUser()->getTSConfig('RTE', BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
                return BackendUtility::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
        }
 
@@ -1191,11 +1193,12 @@ class ElementBrowser {
         * @param string $treeClassName
         * @return string
         */
-       protected function getFileSelectorHtml($treeClassName = \TYPO3\CMS\Backend\Tree\View\ElementBrowserFolderTreeView::class) {
+       protected function getFileSelectorHtml($treeClassName = ElementBrowserFolderTreeView::class) {
+               /** @var ElementBrowserFolderTreeView $folderTree */
                $folderTree = GeneralUtility::makeInstance($treeClassName);
                $folderTree->thisScript = $this->thisScript;
                $tree = $folderTree->getBrowsableTree();
-               $backendUser = $this->getBackendUserAuthentication();
+               $backendUser = $this->getBackendUser();
                if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act'] != $this->act) {
                        $cmpPath = '';
                } else {
@@ -1280,8 +1283,10 @@ class ElementBrowser {
         * @param string $treeClassName name of the class used for page tree rendering
         * @return string
         */
-       protected function getPageSelectorHtml($treeClassName = \TYPO3\CMS\Backend\Tree\View\ElementBrowserPageTreeView::class) {
-               $backendUser = $this->getBackendUserAuthentication();
+       protected function getPageSelectorHtml($treeClassName = ElementBrowserPageTreeView::class) {
+               $backendUser = $this->getBackendUser();
+
+               /** @var ElementBrowserPageTreeView $pageTree */
                $pageTree = GeneralUtility::makeInstance($treeClassName);
                $pageTree->thisScript = $this->thisScript;
                $pageTree->ext_showPageId = $backendUser->getTSConfigVal('options.pageTree.showPageIdWithTitle');
@@ -1319,7 +1324,7 @@ class ElementBrowser {
                // Init variable:
                $pArr = explode('|', $this->bparams);
                $tables = $pArr[3];
-               $backendUser = $this->getBackendUserAuthentication();
+               $backendUser = $this->getBackendUser();
 
                // Making the browsable pagetree:
                /** @var \TYPO3\CMS\Recordlist\Tree\View\ElementBrowserPageTreeView $pageTree */
@@ -1398,7 +1403,7 @@ class ElementBrowser {
                if ($allowed !== 'sys_file' && $allowed !== '*' && !empty($allowed)) {
                        $allowedFileExtensions = $allowed;
                }
-               $backendUser = $this->getBackendUserAuthentication();
+               $backendUser = $this->getBackendUser();
 
                if (isset($allowedFileExtensions)) {
                        // Create new filter object
@@ -1462,8 +1467,8 @@ class ElementBrowser {
                }
                $noThumbs = $noThumbs ?: !$_MOD_SETTINGS['displayThumbs'];
                // Create folder tree:
-               /** @var \TYPO3\CMS\Backend\Tree\View\ElementBrowserFolderTreeView $folderTree */
-               $folderTree = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\View\ElementBrowserFolderTreeView::class);
+               /** @var ElementBrowserFolderTreeView $folderTree */
+               $folderTree = GeneralUtility::makeInstance(ElementBrowserFolderTreeView::class);
                $folderTree->thisScript = $this->thisScript;
                $folderTree->ext_noTempRecyclerDirs = $this->mode == 'filedrag';
                $tree = $folderTree->getBrowsableTree();
@@ -1533,11 +1538,11 @@ class ElementBrowser {
                        $createFolder = '';
                }
                // Create folder tree:
-               /** @var \TYPO3\CMS\Backend\Tree\View\ElementBrowserFolderTreeView $folderTree */
-               $folderTree = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\View\ElementBrowserFolderTreeView::class);
+               /** @var ElementBrowserFolderTreeView $folderTree */
+               $folderTree = GeneralUtility::makeInstance(ElementBrowserFolderTreeView::class);
                $folderTree->thisScript = $this->thisScript;
-               $folderTree->ext_noTempRecyclerDirs = $this->mode == 'filedrag';
-               $tree = $folderTree->getBrowsableTree(FALSE);
+               $folderTree->ext_noTempRecyclerDirs = $this->mode === 'filedrag';
+               $tree = $folderTree->getBrowsableTree();
                $folders = '';
                if ($this->selectedFolder) {
                        if ($this->mode == 'filedrag') {
@@ -1592,7 +1597,7 @@ class ElementBrowser {
                // Draw the record list IF there is a page id to expand:
                if ($expPageId
                        && MathUtility::canBeInterpretedAsInteger($expPageId)
-                       && $this->getBackendUserAuthentication()->isInWebMount($expPageId)
+                       && $this->getBackendUser()->isInWebMount($expPageId)
                ) {
                        // Set header:
                        $out .= $this->barheader($this->getLanguageService()->getLL('contentElements') . ':');
@@ -1638,7 +1643,7 @@ class ElementBrowser {
         * @return string HTML output.
         */
        public function TBE_expandPage($tables) {
-               $backendUser = $this->getBackendUserAuthentication();
+               $backendUser = $this->getBackendUser();
                if (!MathUtility::canBeInterpretedAsInteger($this->expandPage)
                        || $this->expandPage < 0
                        || !$backendUser->isInWebMount($this->expandPage)
@@ -1770,7 +1775,7 @@ class ElementBrowser {
                        $currentIdentifier = $this->curUrlInfo['info'];
                }
                // Create header element; The folder from which files are listed.
-               $titleLen = (int)$this->getBackendUserAuthentication()->uc['titleLen'];
+               $titleLen = (int)$this->getBackendUser()->uc['titleLen'];
                $folderIcon = IconUtility::getSpriteIconForResource($folder);
                $folderIcon .= htmlspecialchars(GeneralUtility::fixed_lgd_cs($folder->getIdentifier(), $titleLen));
                $selected = '';
@@ -1862,7 +1867,7 @@ class ElementBrowser {
                $out .= $this->barheader(sprintf($lang->getLL('files') . ' (%s):', $filesCount));
                $out .= '<div id="filelist">';
                $out .= $this->getBulkSelector($filesCount);
-               $titleLen = (int)$this->getBackendUserAuthentication()->uc['titleLen'];
+               $titleLen = (int)$this->getBackendUser()->uc['titleLen'];
                // Create the header of current folder:
                if ($folder) {
                        $folderIcon = IconUtility::getSpriteIconForResource($folder);
@@ -2000,7 +2005,7 @@ class ElementBrowser {
                $folderIdentifier = $baseFolder->getCombinedIdentifier();
                // Create headline (showing number of folders):
                $content .= $this->barheader(sprintf($lang->getLL('folders') . ' (%s):', count($folders)));
-               $titleLength = (int)$this->getBackendUserAuthentication()->uc['titleLen'];
+               $titleLength = (int)$this->getBackendUser()->uc['titleLen'];
                // Create the header of current folder:
                $aTag = '<a href="#" onclick="return insertElement(\'\',' . GeneralUtility::quoteJSvalue($folderIdentifier)
                        . ', \'folder\', ' . GeneralUtility::quoteJSvalue($folderIdentifier) . ', ' . GeneralUtility::quoteJSvalue($folderIdentifier)
@@ -2097,7 +2102,7 @@ class ElementBrowser {
                $files = $this->getFilesInFolder($folder, $extensionList);
 
                $out .= $this->barheader(sprintf($lang->getLL('files') . ' (%s):', count($files)));
-               $titleLen = (int)$this->getBackendUserAuthentication()->uc['titleLen'];
+               $titleLen = (int)$this->getBackendUser()->uc['titleLen'];
                $picon = IconUtility::getSpriteIcon('apps-filetree-folder-default');
                $picon .= htmlspecialchars(GeneralUtility::fixed_lgd_cs(basename($folder->getName()), $titleLen));
                $out .= $picon . '<br />';
@@ -2306,7 +2311,7 @@ class ElementBrowser {
                                                        $id = (int)$idPartR['uid'];
                                                }
                                                $pageRow = BackendUtility::getRecordWSOL('pages', $id);
-                                               $titleLen = (int)$this->getBackendUserAuthentication()->uc['titleLen'];
+                                               $titleLen = (int)$this->getBackendUser()->uc['titleLen'];
                                                $info['value'] = ((((($lang->getLL('page', TRUE) . ' \'')
                                                                                . htmlspecialchars(GeneralUtility::fixed_lgd_cs($pageRow['title'], $titleLen)))
                                                                                . '\' (ID:') . $id) . ($uP['fragment'] ? ', #' . $uP['fragment'] : '')) . ')';
@@ -2366,7 +2371,7 @@ class ElementBrowser {
                        return '';
                }
                // Read configuration of upload field count
-               $userSetting = $this->getBackendUserAuthentication()->getTSConfigVal('options.folderTree.uploadFieldsInLinkBrowser');
+               $userSetting = $this->getBackendUser()->getTSConfigVal('options.folderTree.uploadFieldsInLinkBrowser');
                $count = isset($userSetting) ? $userSetting : 1;
                if ($count === '0') {
                        return '';
@@ -2436,7 +2441,7 @@ class ElementBrowser {
                if (!$folderObject->checkActionPermission('write')) {
                        return '';
                }
-               $backendUser = $this->getBackendUserAuthentication();
+               $backendUser = $this->getBackendUser();
                if (!($backendUser->isAdmin() || $backendUser->getTSConfigVal('options.createFoldersInEB'))) {
                        return '';
                }
@@ -2500,7 +2505,7 @@ class ElementBrowser {
                $labelToggleSelection = $lang->sL('LLL:EXT:lang/locallang_browse_links.xlf:toggleSelection', TRUE);
                $labelImportSelection = $lang->sL('LLL:EXT:lang/locallang_browse_links.xlf:importSelection', TRUE);
                // Getting flag for showing/not showing thumbnails:
-               $noThumbsInEB = $this->getBackendUserAuthentication()->getTSConfigVal('options.noThumbsInEB');
+               $noThumbsInEB = $this->getBackendUser()->getTSConfigVal('options.noThumbsInEB');
                $out = $this->doc->spacer(10) . '<div>' . '<a href="#" onclick="BrowseLinks.Selector.handle()">'
                        . IconUtility::getSpriteIcon('actions-document-import-t3d', array('title' => $labelImportSelection))
                        . $labelImportSelection . '</a>&nbsp;&nbsp;&nbsp;'
@@ -2560,7 +2565,7 @@ class ElementBrowser {
         * @return string
         */
        protected function getTemporaryTreeMountCancelNotice() {
-               if ((int)$this->getBackendUserAuthentication()->getSessionData('pageTree_temporaryMountPoint') === 0) {
+               if ((int)$this->getBackendUser()->getSessionData('pageTree_temporaryMountPoint') === 0) {
                        return '';
                }
                $link = '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('setTempDBmount' => 0))) . '">'
@@ -2602,7 +2607,7 @@ class ElementBrowser {
        /**
         * @return BackendUserAuthentication
         */
-       protected function getBackendUserAuthentication() {
+       protected function getBackendUser() {
                return $GLOBALS['BE_USER'];
        }
 
index 48820c6..985ad8a 100644 (file)
@@ -65,28 +65,26 @@ class ElementBrowserController {
        public function __construct() {
                $GLOBALS['SOBE'] = $this;
                $GLOBALS['BACK_PATH'] = '';
-               $this->getLanguageService()->includeLLFile('EXT:lang/locallang_browse_links.xlf');
+
+               // Creating backend template object:
+               // this might not be needed but some classes refer to $GLOBALS['SOBE']->doc, so ...
+               $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
+               // Apply the same styles as those of the base script
+               $this->doc->bodyTagId = 'typo3-browse-links-php';
 
                $this->init();
        }
 
        /**
-        * Not really needed but for backwards compatibility ...
-        *
-        * @return void
+        * Init controller
         */
        protected function init() {
-               // Find "mode"
+               $this->getLanguageService()->includeLLFile('EXT:lang/locallang_browse_links.xlf');
+
                $this->mode = GeneralUtility::_GP('mode');
                if (!$this->mode) {
                        $this->mode = 'rte';
                }
-               // Creating backend template object:
-               // this might not be needed but some classes refer to $GLOBALS['SOBE']->doc, so ...
-               $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
-               // Apply the same styles as those of the base script
-               $this->doc->bodyTagId = 'typo3-browse-links-php';
-
        }
 
        /**
@@ -95,32 +93,10 @@ class ElementBrowserController {
         * @return void
         */
        public function main() {
-               // Clear temporary DB mounts
-               $tmpMount = GeneralUtility::_GET('setTempDBmount');
-               $backendUser = $this->getBackendUserAuthentication();
-               if (isset($tmpMount)) {
-                       $backendUser->setAndSaveSessionData('pageTree_temporaryMountPoint', (int)$tmpMount);
-               }
-               // Set temporary DB mounts
-               $alternativeWebmountPoint = (int)$backendUser->getSessionData('pageTree_temporaryMountPoint');
-               if ($alternativeWebmountPoint) {
-                       $alternativeWebmountPoint = GeneralUtility::intExplode(',', $alternativeWebmountPoint);
-                       $backendUser->setWebmounts($alternativeWebmountPoint);
-               } else {
-                       switch ((string)$this->mode) {
-                               case 'rte':
-                               case 'db':
-                               case 'wizard':
-                                       // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
-                                       $alternativeWebmountPoints = trim($backendUser->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
-                                       $appendAlternativeWebmountPoints = $backendUser->getTSConfigVal('options.pageTree.altElementBrowserMountPoints.append');
-                                       if ($alternativeWebmountPoints) {
-                                               $alternativeWebmountPoints = GeneralUtility::intExplode(',', $alternativeWebmountPoints);
-                                               $GLOBALS['BE_USER']->setWebmounts($alternativeWebmountPoints, $appendAlternativeWebmountPoints);
-                                       }
-                       }
-               }
+               $this->setTemporaryDbMounts();
+
                $this->content = '';
+
                // Render type by user func
                $browserRendered = FALSE;
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
@@ -137,11 +113,13 @@ class ElementBrowserController {
                }
                // if type was not rendered use default rendering functions
                if (!$browserRendered) {
-                       $this->browser = GeneralUtility::makeInstance(ElementBrowser::class);
+                       $this->browser = $this->getElementBrowserInstance();
                        $this->browser->init();
+                       $backendUser = $this->getBackendUser();
                        $modData = $backendUser->getModuleData('browse_links.php', 'ses');
                        list($modData) = $this->browser->processSessionData($modData);
                        $backendUser->pushModuleData('browse_links.php', $modData);
+
                        // Output the correct content according to $this->mode
                        switch ((string)$this->mode) {
                                case 'rte':
@@ -165,6 +143,49 @@ class ElementBrowserController {
        }
 
        /**
+        * @return void
+        */
+       protected function setTemporaryDbMounts() {
+               $backendUser = $this->getBackendUser();
+
+               // Clear temporary DB mounts
+               $tmpMount = GeneralUtility::_GET('setTempDBmount');
+               if (isset($tmpMount)) {
+                       $backendUser->setAndSaveSessionData('pageTree_temporaryMountPoint', (int)$tmpMount);
+               }
+               // Set temporary DB mounts
+               $alternativeWebmountPoint = (int)$backendUser->getSessionData('pageTree_temporaryMountPoint');
+               if ($alternativeWebmountPoint) {
+                       $alternativeWebmountPoint = GeneralUtility::intExplode(',', $alternativeWebmountPoint);
+                       $backendUser->setWebmounts($alternativeWebmountPoint);
+               } else {
+                       switch ((string)$this->mode) {
+                               case 'rte':
+                               case 'db':
+                               case 'wizard':
+                                       // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
+                                       $alternativeWebmountPoints = trim($backendUser->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
+                                       $appendAlternativeWebmountPoints = $backendUser->getTSConfigVal('options.pageTree.altElementBrowserMountPoints.append');
+                                       if ($alternativeWebmountPoints) {
+                                               $alternativeWebmountPoints = GeneralUtility::intExplode(',', $alternativeWebmountPoints);
+                                               $this->getBackendUser()->setWebmounts($alternativeWebmountPoints, $appendAlternativeWebmountPoints);
+                                       }
+                       }
+               }
+       }
+
+       /**
+        * Get instance of ElementBrowser
+        *
+        * This method shall be overwritten in subclasses
+        *
+        * @return ElementBrowser
+        */
+       protected function getElementBrowserInstance() {
+               return GeneralUtility::makeInstance(ElementBrowser::class);
+       }
+
+       /**
         * Print module content
         *
         * @return void
@@ -183,7 +204,7 @@ class ElementBrowserController {
        /**
         * @return BackendUserAuthentication
         */
-       protected function getBackendUserAuthentication() {
+       protected function getBackendUser() {
                return $GLOBALS['BE_USER'];
        }
 
index 5f150bc..ce6b20d 100644 (file)
@@ -15,12 +15,15 @@ namespace TYPO3\CMS\Rtehtmlarea;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Lang\LanguageService;
+use TYPO3\CMS\Recordlist\Browser\ElementBrowser;
 
 /**
  * Script class for the Element Browser window.
  */
-class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
+class BrowseLinks extends ElementBrowser {
 
        public $editorNo;
        /**
@@ -29,8 +32,11 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
        public $contentTypo3Language;
 
        public $contentTypo3Charset = 'utf-8';
+
        /**
         * Language service object for localization to the content language
+        *
+        * @var LanguageService
         */
        protected $contentLanguageService;
 
@@ -65,7 +71,7 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
        public function init() {
                $this->initVariables();
                // Create content language service
-               $this->contentLanguageService = GeneralUtility::makeInstance(\TYPO3\CMS\Lang\LanguageService::class);
+               $this->contentLanguageService = GeneralUtility::makeInstance(LanguageService::class);
                $this->contentLanguageService->init($this->contentTypo3Language);
                $this->initConfiguration();
 
@@ -168,7 +174,7 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
         */
        protected function getRTEConfig() {
                $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
-               $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
+               $RTEsetup = $this->getBackendUser()->getTSConfig('RTE', BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
                $this->RTEProperties = $RTEsetup['properties'];
                return BackendUtility::RTEsetup($this->RTEProperties, $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
        }
@@ -428,7 +434,7 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
         */
        public function main_rte($wiz = FALSE) {
                // Starting content:
-               $content = $this->doc->startPage($GLOBALS['LANG']->getLL('Insert/Modify Link', TRUE));
+               $content = $this->doc->startPage($this->getLanguageService()->getLL('Insert/Modify Link', TRUE));
                // Making menu in top:
                $content .= $this->doc->getTabMenuRaw($this->buildMenuArray($wiz, $this->allowedItems));
                // Adding the menu and header to the top of page:
@@ -446,11 +452,11 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                        case 'file':
                        case 'folder':
                                $content .= $this->addAttributesForm();
-                               $content .= $this->getFileSelectorHtml(\TYPO3\CMS\Rtehtmlarea\FolderTree::class);
+                               $content .= $this->getFileSelectorHtml(FolderTree::class);
                                break;
                        case 'page':
                                $content .= $this->addAttributesForm();
-                               $content .= $this->getPageSelectorHtml(\TYPO3\CMS\Rtehtmlarea\PageTree::class);
+                               $content .= $this->getPageSelectorHtml(PageTree::class);
                                break;
                        default:
                                // call hook
@@ -473,39 +479,40 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
         */
        protected function buildMenuArray($wiz, $allowedItems) {
                $menuDef = array();
+               $lang = $this->getLanguageService();
                if (!$wiz && $this->curUrlArray['href']) {
                        $menuDef['removeLink']['isActive'] = $this->act == 'removeLink';
-                       $menuDef['removeLink']['label'] = $GLOBALS['LANG']->getLL('removeLink', TRUE);
+                       $menuDef['removeLink']['label'] = $lang->getLL('removeLink', TRUE);
                        $menuDef['removeLink']['url'] = '#';
                        $menuDef['removeLink']['addParams'] = 'onclick="plugin.unLink();return false;"';
                }
                if (in_array('page', $this->allowedItems)) {
                        $menuDef['page']['isActive'] = $this->act == 'page';
-                       $menuDef['page']['label'] = $GLOBALS['LANG']->getLL('page', TRUE);
+                       $menuDef['page']['label'] = $lang->getLL('page', TRUE);
                        $menuDef['page']['url'] = '#';
                        $menuDef['page']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=page&mode=' . $this->mode . '&bparams=' . $this->bparams) . ');return false;"';
                }
                if (in_array('file', $this->allowedItems)) {
                        $menuDef['file']['isActive'] = $this->act == 'file';
-                       $menuDef['file']['label'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.xlf:file', TRUE);
+                       $menuDef['file']['label'] = $lang->sL('LLL:EXT:lang/locallang_browse_links.xlf:file', TRUE);
                        $menuDef['file']['url'] = '#';
                        $menuDef['file']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=file&mode=' . $this->mode . '&bparams=' . $this->bparams) . ');return false;"';
                }
                if (in_array('folder', $this->allowedItems)) {
                        $menuDef['folder']['isActive'] = $this->act == 'folder';
-                       $menuDef['folder']['label'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.xlf:folder', TRUE);
+                       $menuDef['folder']['label'] = $lang->sL('LLL:EXT:lang/locallang_browse_links.xlf:folder', TRUE);
                        $menuDef['folder']['url'] = '#';
                        $menuDef['folder']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=folder&mode=' . $this->mode . '&bparams=' . $this->bparams) . ');return false;"';
                }
                if (in_array('url', $this->allowedItems)) {
                        $menuDef['url']['isActive'] = $this->act == 'url';
-                       $menuDef['url']['label'] = $GLOBALS['LANG']->getLL('extUrl', TRUE);
+                       $menuDef['url']['label'] = $lang->getLL('extUrl', TRUE);
                        $menuDef['url']['url'] = '#';
                        $menuDef['url']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=url&mode=' . $this->mode . '&bparams=' . $this->bparams) . ');return false;"';
                }
                if (in_array('mail', $this->allowedItems)) {
                        $menuDef['mail']['isActive'] = $this->act == 'mail';
-                       $menuDef['mail']['label'] = $GLOBALS['LANG']->getLL('email', TRUE);
+                       $menuDef['mail']['label'] = $lang->getLL('email', TRUE);
                        $menuDef['mail']['url'] = '#';
                        $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=mail&mode=' . $this->mode . '&bparams=' . $this->bparams) . ');return false;"';
                }
@@ -529,13 +536,13 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                        <tr>
                                <td>
                                        <label>
-                                               ' . $GLOBALS['LANG']->getLL('emailAddress', TRUE) . ':
+                                               ' . $this->getLanguageService()->getLL('emailAddress', TRUE) . ':
                                        </label>
                                </td>
                                <td>
                                        <input type="text" name="lemail"' . $this->doc->formWidth(20)
                                                . ' value="' . htmlspecialchars(($this->curUrlInfo['act'] == 'mail' ? $this->curUrlInfo['info'] : '')) . '" />
-                                       <input class="btn btn-default" type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', TRUE)
+                                       <input class="btn btn-default" type="submit" value="' . $this->getLanguageService()->getLL('setLink', TRUE)
                                                . '" onclick="browse_links_setTarget(\'\');browse_links_setHref(\'mailto:\'+document.ltargetform.lemail.value);'
                                                . 'browse_links_setAdditionalValue(\'data-htmlarea-external\', \'\');return link_current();" />
                                </td>
@@ -563,10 +570,10 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                                        <input type="text" name="lurl"' . $this->doc->formWidth(20)
                                                . ' value="' . htmlspecialchars(($this->curUrlInfo['act'] == 'url' ? $this->curUrlInfo['info'] : 'http://'))
                                                . '" />
-                                       <input class="btn btn-default" type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', TRUE)
+                                       <input class="btn btn-default" type="submit" value="' . $this->getLanguageService()->getLL('setLink', TRUE)
                                                . '" onclick="if (/^[A-Za-z0-9_+]{1,8}:/.test(document.ltargetform.lurl.value)) { '
                                                . ' browse_links_setHref(document.ltargetform.lurl.value); } else { browse_links_setHref(\'http://\''
-                                               . '+document.ltargetform.lurl.value); }; browse_links_setAdditionalValue(\'data-htmlarea-external\', \'1\');'
+                                               . '+document.ltargetform.lurl.value); } browse_links_setAdditionalValue(\'data-htmlarea-external\', \'1\');'
                                                . 'return link_current();" />
                                </td>
                        </tr>';
@@ -650,7 +657,7 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                                                <td>
                                                </td>
                                                <td colspan="3">
-                                                       <input class="btn btn-default" type="submit" value="' . $GLOBALS['LANG']->getLL('update', TRUE) . '" onclick="'
+                                                       <input class="btn btn-default" type="submit" value="' . $this->getLanguageService()->getLL('update', TRUE) . '" onclick="'
                                                                . ($this->act == 'url' ? 'browse_links_setAdditionalValue(\'data-htmlarea-external\', \'1\'); ' : '')
                                                                . 'return link_current();" />
                                                </td>
@@ -675,12 +682,12 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                                <tr>
                                        <td>
                                                <label>
-                                                       ' . $GLOBALS['LANG']->getLL('page_id', TRUE) . ':
+                                                       ' . $this->getLanguageService()->getLL('page_id', TRUE) . ':
                                                </label>
                                        </td>
                                        <td colspan="3">
                                                <input type="text" size="6" name="luid" /> <input class="btn btn-default" type="submit" value="'
-                                                       . $GLOBALS['LANG']->getLL('setLink', TRUE) . '" onclick="return link_typo3Page(document.ltargetform.luid.value);" />
+                                                       . $this->getLanguageService()->getLL('setLink', TRUE) . '" onclick="return link_typo3Page(document.ltargetform.luid.value);" />
                                        </td>
                                </tr>';
                }
@@ -700,7 +707,7 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                ) {
                        return '
                                                <tr>
-                                                       <td><label>' . $GLOBALS['LANG']->getLL('linkRelationship', TRUE) . ':</label></td>
+                                                       <td><label>' . $this->getLanguageService()->getLL('linkRelationship', TRUE) . ':</label></td>
                                                        <td colspan="3">
                                                                <input type="text" name="lrel" value="' . $currentRel . '"  '
                                . $this->doc->formWidth(30) . ' />
@@ -721,7 +728,7 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                ) {
                        return '
                                                <tr>
-                                                       <td><label>' . $GLOBALS['LANG']->getLL('query_parameters', TRUE) . ':</label></td>
+                                                       <td><label>' . $this->getLanguageService()->getLL('query_parameters', TRUE) . ':</label></td>
                                                        <td colspan="3">
                                                                <input type="text" name="query_parameters" value="' . ($this->curUrlInfo['query'] ?: '')
                                . '" ' . $this->doc->formWidth(30) . ' />
@@ -751,9 +758,10 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                // Reset the target to default if we changed tab
                $currentTarget = $this->curUrlInfo['act'] === $this->act && isset($this->curUrlArray['target']) ? $this->curUrlArray['target'] : '';
                $target = $currentTarget ?: $this->defaultLinkTarget;
+               $lang = $this->getLanguageService();
                $ltarget = '
                                <tr id="ltargetrow"' . ($targetSelectorConfig['disabled'] && $popupSelectorConfig['disabled'] ? ' style="display: none;"' : '') . '>
-                                       <td><label>' . $GLOBALS['LANG']->getLL('target', TRUE) . ':</label></td>
+                                       <td><label>' . $lang->getLL('target', TRUE) . ':</label></td>
                                        <td><input type="text" name="ltarget" onchange="browse_links_setTarget(this.value);" value="'
                                        . htmlspecialchars($target) . '"' . $this->doc->formWidth(10) . ' /></td>';
                $ltarget .= '
@@ -762,8 +770,8 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                        $ltarget .= '
                                                <select name="ltarget_type" onchange="browse_links_setTarget(this.options[this.selectedIndex].value);document.ltargetform.ltarget.value=this.options[this.selectedIndex].value;this.selectedIndex=0;">
                                                        <option></option>
-                                                       <option value="_top">' . $GLOBALS['LANG']->getLL('top', TRUE) . '</option>
-                                                       <option value="_blank">' . $GLOBALS['LANG']->getLL('newWindow', TRUE) . '</option>
+                                                       <option value="_top">' . $lang->getLL('top', TRUE) . '</option>
+                                                       <option value="_blank">' . $lang->getLL('newWindow', TRUE) . '</option>
                                                </select>';
                }
                $ltarget .= '
@@ -778,10 +786,10 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                        }';
                        $ltarget .= '
                                        <tr>
-                                               <td><label>' . $GLOBALS['LANG']->getLL('target_popUpWindow', TRUE) . ':</label></td>
+                                               <td><label>' . $lang->getLL('target_popUpWindow', TRUE) . ':</label></td>
                                                <td colspan="3">
                                                        <select name="popup_width" onchange="' . $selectJS . '">
-                                                               <option value="0">' . $GLOBALS['LANG']->getLL('target_popUpWindow_width', TRUE) . '</option>
+                                                               <option value="0">' . $lang->getLL('target_popUpWindow_width', TRUE) . '</option>
                                                                <option value="300">300</option>
                                                                <option value="400">400</option>
                                                                <option value="500">500</option>
@@ -791,7 +799,7 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                                                        </select>
                                                        x
                                                        <select name="popup_height" onchange="' . $selectJS . '">
-                                                               <option value="0">' . $GLOBALS['LANG']->getLL('target_popUpWindow_height', TRUE) . '</option>
+                                                               <option value="0">' . $lang->getLL('target_popUpWindow_height', TRUE) . '</option>
                                                                <option value="200">200</option>
                                                                <option value="300">300</option>
                                                                <option value="400">400</option>
@@ -814,7 +822,7 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                if ($this->classesAnchorJSOptions[$this->act]) {
                        $selectClass = '
                                                <tr>
-                                                       <td><label>' . $GLOBALS['LANG']->getLL('anchor_class', TRUE) . ':</label></td>
+                                                       <td><label>' . $this->getLanguageService()->getLL('anchor_class', TRUE) . ':</label></td>
                                                        <td colspan="3">
                                                                <select name="anchor_class" onchange="' . $this->getClassOnChangeJS() . '">
                                                                        ' . $this->classesAnchorJSOptions[$this->act] . '
@@ -887,7 +895,7 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                }
                return '
                                                <tr>
-                                                       <td><label for="rtehtmlarea-browse-links-anchor_title" id="rtehtmlarea-browse-links-title-label">' . $GLOBALS['LANG']->getLL('anchor_title', TRUE) . ':</label></td>
+                                                       <td><label for="rtehtmlarea-browse-links-anchor_title" id="rtehtmlarea-browse-links-title-label">' . $this->getLanguageService()->getLL('anchor_title', TRUE) . ':</label></td>
                                                        <td colspan="3">
                                                                <span id="rtehtmlarea-browse-links-title-input" style="display: ' . ($readOnly ? 'none' : 'inline') . ';">
                                                                        <input type="text" id="rtehtmlarea-browse-links-anchor_title" name="anchor_title" value="' . htmlspecialchars($title) . '" ' . $this->doc->formWidth(30) . ' />
@@ -918,10 +926,24 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                if (substr($string, 0, 4) !== 'LLL:') {
                        $label = $string;
                } else {
-                       $label = $GLOBALS['LANG']->sL(trim($string));
+                       $label = $this->getLanguageService()->sL(trim($string));
                }
                $label = str_replace('"', '\\"', str_replace('\\\'', '\'', $label));
                return $JScharCode ? GeneralUtility::quoteJSvalue($label) : $label;
        }
 
+       /**
+        * @return LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
+
+       /**
+        * @return BackendUserAuthentication
+        */
+       protected function getBackendUser() {
+               return $GLOBALS['BE_USER'];
+       }
+
 }
index 8f63f02..d617d40 100644 (file)
@@ -14,88 +14,48 @@ namespace TYPO3\CMS\Rtehtmlarea\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Recordlist\Browser\ElementBrowser;
+use TYPO3\CMS\Recordlist\Controller\ElementBrowserController;
+use TYPO3\CMS\Rtehtmlarea\BrowseLinks;
+
 /**
  * Script class for the Element Browser window.
  */
-class BrowseLinksController {
-
-       public $mode = 'rte';
+class BrowseLinksController extends ElementBrowserController {
 
+       /**
+        * @var string
+        */
        public $button = 'link';
 
-       protected $content = '';
-
        /**
-        * Initialize language files
+        * @var BrowseLinks
         */
-       public function __construct() {
-               $GLOBALS['LANG']->includeLLFile('EXT:rtehtmlarea/Resources/Private/Language/locallang_browselinkscontroller.xlf');
-               $GLOBALS['LANG']->includeLLFile('EXT:rtehtmlarea/Resources/Private/Language/locallang_dialogs.xlf');
-       }
+       public $browser;
+
        /**
-        * Main function, rendering the element browser in RTE mode.
-        *
-        * @return void
+        * Initialize controller
         */
-       public function main() {
-               // Setting alternative web browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
-               $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
-               $appendAltMountPoints = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints.append');
-               // Clear temporary DB mounts
-               $tmpMount = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('setTempDBmount');
-               if (isset($tmpMount)) {
-                       $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint', (int)$tmpMount);
-               }
-               // Set temporary DB mounts
-               $tempDBmount = (int)$GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint');
-               if ($tempDBmount) {
-                       $altMountPoints = $tempDBmount;
-                       $appendAltMountPoints = FALSE;
-               }
-               if ($altMountPoints) {
-                       $alternativeMountPoints = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $altMountPoints);
-                       $GLOBALS['BE_USER']->setWebmounts($alternativeMountPoints, $appendAltMountPoints);
-               }
-               // Setting alternative file browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
-               $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints'));
-               if ($altMountPoints) {
-                       $altMountPoints = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $altMountPoints);
-                       foreach ($altMountPoints as $filePathRelativeToFileadmindir) {
-                               // @todo: add this feature for FAL and TYPO3 6.2
-                       }
-               }
-               // Render type by user function
-               $browserRendered = FALSE;
-               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
-                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'] as $classRef) {
-                               $browserRenderObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
-                               if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) {
-                                       if ($browserRenderObj->isValid($this->mode, $this)) {
-                                               $this->content .= $browserRenderObj->render($this->mode, $this);
-                                               $browserRendered = TRUE;
-                                               break;
-                                       }
-                               }
-                       }
-               }
-               // If type was not rendered, use default rendering functions
-               if (!$browserRendered) {
-                       $GLOBALS['SOBE']->browser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Rtehtmlarea\BrowseLinks::class);
-                       $GLOBALS['SOBE']->browser->init();
-                       $modData = $GLOBALS['BE_USER']->getModuleData('browse_links.php', 'ses');
-                       list($modData, $store) = $GLOBALS['SOBE']->browser->processSessionData($modData);
-                       $GLOBALS['BE_USER']->pushModuleData('browse_links.php', $modData);
-                       $this->content = $GLOBALS['SOBE']->browser->main_rte();
-               }
+       protected function init() {
+               parent::init();
+
+               $lang = $this->getLanguageService();
+               $lang->includeLLFile('EXT:rtehtmlarea/Resources/Private/Language/locallang_browselinkscontroller.xlf');
+               $lang->includeLLFile('EXT:rtehtmlarea/Resources/Private/Language/locallang_dialogs.xlf');
+
+               $this->mode = 'rte';
        }
 
        /**
-        * Print module content
+        * Get instance of ElementBrowser
+        *
+        * This method shall be overwritten in subclasses
         *
-        * @return void
+        * @return ElementBrowser
         */
-       public function printContent() {
-               echo $this->content;
+       protected function getElementBrowserInstance() {
+               return GeneralUtility::makeInstance(BrowseLinks::class);
        }
 
 }
index 04c1500..e909ad9 100644 (file)
@@ -14,72 +14,48 @@ namespace TYPO3\CMS\Rtehtmlarea\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Recordlist\Browser\ElementBrowser;
+use TYPO3\CMS\Recordlist\Controller\ElementBrowserController;
+use TYPO3\CMS\Rtehtmlarea\SelectImage;
+
 /**
- * Script class for the Element Browser window.
+ * Script class for the Element Browser window to select images in RTE
  */
-class SelectImageController {
-
-       public $mode = 'rte';
+class SelectImageController extends ElementBrowserController {
 
+       /**
+        * @var string
+        */
        public $button = 'image';
 
-       protected $content = '';
-
        /**
-        * Initialize language files
+        * @var SelectImage
         */
-       public function __construct() {
-               $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_browse_links.xlf');
-               $GLOBALS['LANG']->includeLLFile('EXT:rtehtmlarea/Resources/Private/Language/locallang_selectimagecontroller.xlf');
-               $GLOBALS['LANG']->includeLLFile('EXT:rtehtmlarea/Resources/Private/Language/locallang_dialogs.xlf');
-       }
+       public $browser;
 
        /**
-        * Main function, rendering the element browser in RTE mode.
-        *
-        * @return void
+        * Initialize controller
         */
-       public function main() {
-               // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
-               $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints'));
-               if ($altMountPoints) {
-                       $altMountPoints = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $altMountPoints);
-                       foreach ($altMountPoints as $filePathRelativeToFileadmindir) {
-                               // @todo: add this feature for FAL and TYPO3 6.2
-                       }
-               }
-               // Rendering type by user function
-               $browserRendered = FALSE;
-               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/TYPO3\\CMS\\Recordlist\\Browser\\ElementBrowser.php']['browserRendering'])) {
-                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/TYPO3\\CMS\\Recordlist\\Browser\\ElementBrowser.php']['browserRendering'] as $classRef) {
-                               $browserRenderObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
-                               if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) {
-                                       if ($browserRenderObj->isValid($this->mode, $this)) {
-                                               $this->content .= $browserRenderObj->render($this->mode, $this);
-                                               $browserRendered = TRUE;
-                                               break;
-                                       }
-                               }
-                       }
-               }
-               // If type was not rendered, use default rendering functions
-               if (!$browserRendered) {
-                       $GLOBALS['SOBE']->browser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Rtehtmlarea\SelectImage::class);
-                       $GLOBALS['SOBE']->browser->init();
-                       $modData = $GLOBALS['BE_USER']->getModuleData('select_image.php', 'ses');
-                       list($modData, $store) = $GLOBALS['SOBE']->browser->processSessionData($modData);
-                       $GLOBALS['BE_USER']->pushModuleData('select_image.php', $modData);
-                       $this->content = $GLOBALS['SOBE']->browser->main_rte();
-               }
+       protected function init() {
+               parent::init();
+
+               $lang = $this->getLanguageService();
+               $lang->includeLLFile('EXT:rtehtmlarea/Resources/Private/Language/locallang_selectimagecontroller.xlf');
+               $lang->includeLLFile('EXT:rtehtmlarea/Resources/Private/Language/locallang_dialogs.xlf');
+
+               $this->mode = 'rte';
        }
 
        /**
-        * Print module content
+        * Get instance of ElementBrowser
+        *
+        * This method shall be overwritten in subclasses
         *
-        * @return void
+        * @return ElementBrowser
         */
-       public function printContent() {
-               echo $this->content;
+       protected function getElementBrowserInstance() {
+               return GeneralUtility::makeInstance(SelectImage::class);
        }
 
 }
index 42097e6..e408c83 100644 (file)
@@ -14,13 +14,19 @@ namespace TYPO3\CMS\Rtehtmlarea;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Tree\View\ElementBrowserFolderTreeView;
+use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\Resource\Service\MagicImageService;
+use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Resource;
+use TYPO3\CMS\Lang\LanguageService;
+use TYPO3\CMS\Recordlist\Browser\ElementBrowser;
 
 /**
  * Script Class
  */
-class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
+class SelectImage extends ElementBrowser {
 
        /**
         * These file extensions are allowed in the "plain" image selection mode.
@@ -72,6 +78,11 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
        protected $imgObj;
 
        /**
+        * @var string
+        */
+       public $addModifyTab;
+
+       /**
         * Initialisation
         *
         * @return void
@@ -135,12 +146,12 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                }');
                $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Rtehtmlarea/Modules/SelectImage', 'function(SelectImage) {
                        SelectImage.editorNo = ' . GeneralUtility::quoteJSvalue($this->editorNo) . ';
-                       SelectImage.act = ' . GeneralUtility::quoteJSvalue(($this->act ?: reset($this->allowedItems))) . ';
+                       SelectImage.act = ' . GeneralUtility::quoteJSvalue($this->act ?: reset($this->allowedItems)) . ';
                        SelectImage.sys_language_content = ' . GeneralUtility::quoteJSvalue($this->sys_language_content) . ';
                        SelectImage.RTEtsConfigParams = ' . GeneralUtility::quoteJSvalue(rawurlencode($this->RTEtsConfigParams)) . ';
                        SelectImage.bparams = ' . GeneralUtility::quoteJSvalue($this->bparams) . ';
                }');
-               $this->getPageRenderer()->addCssFile($this->doc->backPath . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('t3skin') . 'rtehtmlarea/htmlarea.css');
+               $this->getPageRenderer()->addCssFile($this->doc->backPath . ExtensionManagementUtility::extRelPath('t3skin') . 'rtehtmlarea/htmlarea.css');
                $this->doc->getContextMenuCode();
        }
 
@@ -201,8 +212,8 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
         */
        public function insertMagicImage(Resource\File $fileObject, $altText = '', $titleText = '', $additionalParams = '') {
                // Create the magic image service
-               /** @var $magicImageService Resource\Service\MagicImageService */
-               $magicImageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Service\MagicImageService::class);
+               /** @var $magicImageService MagicImageService */
+               $magicImageService = GeneralUtility::makeInstance(MagicImageService::class);
                $magicImageService->setMagicImageMaximumDimensions($this->thisConfig);
                // Create the magic image
                $imageConfiguration = array(
@@ -257,7 +268,8 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
         * @return string the image insertion JS statement
         */
        protected function imageInsertJsStatement($url, $width, $height, $altText = '', $titleText = '', $additionalParams = '') {
-               return 'insertImage(' . GeneralUtility::quoteJSvalue($url, 1) . ',' . $width . ',' . $height . ',' . GeneralUtility::quoteJSvalue($altText, 1) . ',' . GeneralUtility::quoteJSvalue($titleText, 1) . ',' . GeneralUtility::quoteJSvalue($additionalParams, 1) . ');';
+               return 'insertImage(' . GeneralUtility::quoteJSvalue($url) . ',' . $width . ',' . $height . ',' . GeneralUtility::quoteJSvalue($altText)
+                       . ',' . GeneralUtility::quoteJSvalue($titleText) . ',' . GeneralUtility::quoteJSvalue($additionalParams) . ');';
        }
 
        /**
@@ -348,7 +360,8 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
         */
        public function main_rte($wiz = FALSE) {
                // Starting content:
-               $this->content = $this->doc->startPage($GLOBALS['LANG']->getLL('Insert Image', TRUE));
+               $lang = $this->getLanguageService();
+               $this->content = $this->doc->startPage($lang->getLL('Insert Image', TRUE));
 
                $this->content .= $this->doc->getTabMenuRaw($this->buildMenuArray($wiz, $this->allowedItems));
                switch ($this->act) {
@@ -377,9 +390,9 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                                }
                                $labels = array('notSet','nonFloating','right','left','class','width','height','border','float','padding_top','padding_left','padding_bottom','padding_right','title','alt','update');
                                foreach ($labels as $label) {
-                                       $localizedLabels[$label] = $GLOBALS['LANG']->getLL($label);
+                                       $localizedLabels[$label] = $lang->getLL($label);
                                }
-                               $localizedLabels['image_zoom'] = $GLOBALS['LANG']->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:image_zoom', TRUE);
+                               $localizedLabels['image_zoom'] = $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:image_zoom', TRUE);
                                $JScode = '
                                        require(["TYPO3/CMS/Rtehtmlarea/Modules/SelectImage"], function(SelectImage) {
                                                SelectImage.editorNo = "' . $this->editorNo . '";
@@ -397,13 +410,11 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                        case 'plain':
                        case 'magic':
                                // Create folder tree:
-                               $foldertree = GeneralUtility::makeInstance(\TYPO3\CMS\Rtehtmlarea\FolderTree::class);
+                               $foldertree = GeneralUtility::makeInstance(FolderTree::class);
                                $foldertree->thisScript = $this->thisScript;
                                $tree = $foldertree->getBrowsableTree();
                                // Get currently selected folder
-                               if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act'] != $this->act) {
-                                       $cmpPath = '';
-                               } else {
+                               if ($this->curUrlInfo['value'] && $this->curUrlInfo['act'] === $this->act) {
                                        $cmpPath = $this->curUrlInfo['value'];
                                        if (!isset($this->expandFolder)) {
                                                $this->expandFolder = $cmpPath;
@@ -414,14 +425,14 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                                if ($this->expandFolder) {
                                        $fileOrFolderObject = NULL;
                                        try {
-                                               $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
+                                               $fileOrFolderObject = Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
                                        } catch (\Exception $e) {
                                                // No path is selected
                                        }
-                                       if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
+                                       if ($fileOrFolderObject instanceof Resource\Folder) {
                                                // it's a folder
                                                $selectedFolder = $fileOrFolderObject;
-                                       } elseif ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
+                                       } elseif ($fileOrFolderObject instanceof Resource\FileInterface) {
                                                // it's a file
                                                try {
                                                        $selectedFolder = $fileOrFolderObject->getParentFolder();
@@ -431,9 +442,10 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                                        }
                                }
                                // If no folder is selected, get the user's default upload folder
+                               $backendUser = $this->getBackendUser();
                                if (!$selectedFolder) {
                                        try {
-                                               $selectedFolder = $GLOBALS['BE_USER']->getDefaultUploadFolder();
+                                               $selectedFolder = $backendUser->getDefaultUploadFolder();
                                        } catch (\Exception $e) {
                                                // The configured default user folder does not exist
                                        }
@@ -446,13 +458,13 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                                        $createFolder = $this->createFolder($selectedFolder);
                                }
                                // Insert the upload form on top, if so configured
-                               if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
+                               if ($backendUser->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
                                        $this->content .= $uploadForm;
                                }
                                // Render the filelist if there is a folder selected
                                $files = '';
                                if ($selectedFolder) {
-                                       $files = $this->TBE_expandFolder($selectedFolder, $this->act === 'plain' ? self::PLAIN_MODE_IMAGE_FILE_EXTENSIONS : $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInRTEimageSelect'));
+                                       $files = $this->TBE_expandFolder($selectedFolder, $this->act === 'plain' ? self::PLAIN_MODE_IMAGE_FILE_EXTENSIONS : $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $backendUser->getTSConfigVal('options.noThumbsInRTEimageSelect'));
                                }
                                // Setup filelist indexed elements:
                                $this->doc->JScode .= $this->doc->wrapScriptTags('
@@ -467,7 +479,7 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                                -->
                                                <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
                                                        <tr>
-                                                               <td class="c-wCell" valign="top">' . $this->barheader(($GLOBALS['LANG']->getLL('folderTree') . ':')) . $tree . '</td>
+                                                               <td class="c-wCell" valign="top">' . $this->barheader(($lang->getLL('folderTree') . ':')) . $tree . '</td>
                                                                <td class="c-wCell" valign="top">' . $files . '</td>
                                                        </tr>
                                                </table>
@@ -478,21 +490,19 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                                        $this->content .= $this->getMsgBox($helpMessage);
                                }
                                // Adding create folder + upload form if applicable
-                               if (!$GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
+                               if (!$backendUser->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
                                        $this->content .= $uploadForm;
                                }
                                $this->content .= $createFolder;
                                $this->content .= '<br />';
                                break;
                        case 'dragdrop':
-                               $foldertree = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\View\ElementBrowserFolderTreeView::class);
+                               $foldertree = GeneralUtility::makeInstance(ElementBrowserFolderTreeView::class);
                                $foldertree->thisScript = $this->thisScript;
                                $foldertree->ext_noTempRecyclerDirs = TRUE;
                                $tree = $foldertree->getBrowsableTree();
                                // Get currently selected folder
-                               if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act'] != $this->act) {
-                                       $cmpPath = '';
-                               } else {
+                               if ($this->curUrlInfo['value'] && $this->curUrlInfo['act'] === $this->act) {
                                        $cmpPath = $this->curUrlInfo['value'];
                                        if (!isset($this->expandFolder)) {
                                                $this->expandFolder = $cmpPath;
@@ -501,7 +511,7 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                                $selectedFolder = FALSE;
                                if ($this->expandFolder) {
                                        try {
-                                               $selectedFolder = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder);
+                                               $selectedFolder = Resource\ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder);
                                        } catch (\Exception $e) {
                                        }
                                }
@@ -513,7 +523,7 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                                // Wrap tree
                                $this->content .= '<table border="0" cellpadding="0" cellspacing="0">
                                        <tr>
-                                               <td style="vertical-align: top;">' . $this->barheader(($GLOBALS['LANG']->getLL('folderTree') . ':')) . $tree . '</td>
+                                               <td style="vertical-align: top;">' . $this->barheader(($lang->getLL('folderTree') . ':')) . $tree . '</td>
                                                <td>&nbsp;</td>
                                                <td style="vertical-align: top;">' . $files . '</td>
                                        </tr>
@@ -540,27 +550,28 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
         */
        protected function buildMenuArray($wiz, $allowedItems) {
                $menuDef = array();
+               $lang = $this->getLanguageService();
                if (in_array('image', $this->allowedItems) && ($this->act === 'image' || $this->addModifyTab)) {
                        $menuDef['image']['isActive'] = FALSE;
-                       $menuDef['image']['label'] = $GLOBALS['LANG']->getLL('currentImage', TRUE);
+                       $menuDef['image']['label'] = $lang->getLL('currentImage', TRUE);
                        $menuDef['image']['url'] = '#';
                        $menuDef['image']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript()) . ' + \'act=image\');return false;"';
                }
                if (in_array('magic', $this->allowedItems)) {
                        $menuDef['magic']['isActive'] = FALSE;
-                       $menuDef['magic']['label'] = $GLOBALS['LANG']->getLL('magicImage', TRUE);
+                       $menuDef['magic']['label'] = $lang->getLL('magicImage', TRUE);
                        $menuDef['magic']['url'] = '#';
                        $menuDef['magic']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript()) . ' + \'act=magic\');return false;"';
                }
                if (in_array('plain', $this->allowedItems)) {
                        $menuDef['plain']['isActive'] = FALSE;
-                       $menuDef['plain']['label'] = $GLOBALS['LANG']->getLL('plainImage', TRUE);
+                       $menuDef['plain']['label'] = $lang->getLL('plainImage', TRUE);
                        $menuDef['plain']['url'] = '#';
                        $menuDef['plain']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript()) . ' + \'act=plain\');return false;"';
                }
                if (in_array('dragdrop', $this->allowedItems)) {
                        $menuDef['dragdrop']['isActive'] = FALSE;
-                       $menuDef['dragdrop']['label'] = $GLOBALS['LANG']->getLL('dragDropImage', TRUE);
+                       $menuDef['dragdrop']['label'] = $lang->getLL('dragDropImage', TRUE);
                        $menuDef['dragdrop']['url'] = '#';
                        $menuDef['dragdrop']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript()) . ' + \'act=dragdrop\');return false;"';
                }
@@ -704,10 +715,10 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
        public function getHelpMessage($act) {
                switch ($act) {
                        case 'plain':
-                               return sprintf($GLOBALS['LANG']->getLL('plainImage_msg'), $this->plainMaxWidth, $this->plainMaxHeight);
+                               return sprintf($this->getLanguageService()->getLL('plainImage_msg'), $this->plainMaxWidth, $this->plainMaxHeight);
                                break;
                        case 'magic':
-                               return sprintf($GLOBALS['LANG']->getLL('magicImage_msg'));
+                               return sprintf($this->getLanguageService()->getLL('magicImage_msg'));
                                break;
                        default:
                                return '';
@@ -719,11 +730,11 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
         *
         * In "plain" RTE mode only image files with a maximum width and height are selectable.
         *
-        * @param \TYPO3\CMS\Core\Resource\FileInterface $file
+        * @param Resource\FileInterface $file
         * @param array $imgInfo Image dimensions from \TYPO3\CMS\Core\Imaging\GraphicalFunctions::getImageDimensions()
         * @return bool TRUE if file is selectable.
         */
-       protected function fileIsSelectableInFileList(\TYPO3\CMS\Core\Resource\FileInterface $file, array $imgInfo) {
+       protected function fileIsSelectableInFileList(Resource\FileInterface $file, array $imgInfo) {
                return (
                        $this->act !== 'plain'
                        || (
@@ -734,4 +745,18 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                );
        }
 
+       /**
+        * @return LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
+
+       /**
+        * @return BackendUserAuthentication
+        */
+       protected function getBackendUser() {
+               return $GLOBALS['BE_USER'];
+       }
+
 }
index 7b4ae35..e15de04 100644 (file)
@@ -21,6 +21,6 @@
  */
 
 // Make instance:
-$GLOBALS['SOBE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Rtehtmlarea\Controller\BrowseLinksController::class);
-$GLOBALS['SOBE']->main();
-$GLOBALS['SOBE']->printContent();
+$elementBrowserController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Rtehtmlarea\Controller\BrowseLinksController::class);
+$elementBrowserController->main();
+$elementBrowserController->printContent();
index d2e038e..5bc3da8 100644 (file)
@@ -17,6 +17,6 @@
  */
 
 // Make instance:
-$GLOBALS['SOBE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Rtehtmlarea\Controller\SelectImageController::class);
-$GLOBALS['SOBE']->main();
-$GLOBALS['SOBE']->printContent();
+$elementBrowserController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Rtehtmlarea\Controller\SelectImageController::class);
+$elementBrowserController->main();
+$elementBrowserController->printContent();