[!!!][TASK] Trees do not use global SOBE anymore 53/42853/4
authorMarkus Klein <markus.klein@typo3.org>
Mon, 24 Aug 2015 07:19:42 +0000 (09:19 +0200)
committerBenni Mack <benni@typo3.org>
Tue, 25 Aug 2015 11:40:20 +0000 (13:40 +0200)
The back-reference to the underlying instance of ElementBrowser is now
stored as member of the tree.

Resolves: #69276
Releases: master
Change-Id: Ie48a77cd01269ea7e13905d651663424dbb616a1
Reviewed-on: http://review.typo3.org/42853
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
13 files changed:
typo3/sysext/backend/Classes/Controller/FileSystemNavigationFrameController.php
typo3/sysext/backend/Classes/RecordList/ElementBrowserRecordList.php
typo3/sysext/backend/Classes/Tree/View/ElementBrowserFolderTreeView.php
typo3/sysext/backend/Classes/Tree/View/ElementBrowserPageTreeView.php
typo3/sysext/backend/Classes/Tree/View/FolderTreeView.php
typo3/sysext/core/Documentation/Changelog/master/Breaking-69276-ElementBrowserControllerbrowserRemoved.rst [new file with mode: 0644]
typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php
typo3/sysext/recordlist/Classes/Controller/ElementBrowserController.php
typo3/sysext/recordlist/Classes/Tree/View/ElementBrowserPageTreeView.php
typo3/sysext/rtehtmlarea/Classes/Controller/BrowseLinksController.php
typo3/sysext/rtehtmlarea/Classes/Controller/SelectImageController.php
typo3/sysext/rtehtmlarea/Classes/FolderTree.php
typo3/sysext/rtehtmlarea/Classes/PageTree.php

index 7227b88..d7fbf5b 100644 (file)
@@ -23,21 +23,22 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Filelist\FileListFolderTree;
 use TYPO3\CMS\Backend\Template\DocumentTemplate;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Recordlist\Browser\ElementBrowser;
 
 /**
  * Main script class for rendering of the folder tree
  */
 class FileSystemNavigationFrameController implements ControllerInterface {
 
-       // Internal, dynamic:
-       // Content accumulates in this variable.
        /**
+        * Content accumulates in this variable.
+        *
         * @var string
         */
        public $content;
 
        /**
-        * @var \TYPO3\CMS\Filelist\FileListFolderTree
+        * @var \TYPO3\CMS\Backend\Tree\View\FolderTreeView
         */
        public $foldertree;
 
@@ -48,7 +49,6 @@ class FileSystemNavigationFrameController implements ControllerInterface {
         */
        public $doc;
 
-       // Internal, static: GPvar:
        /**
         * @var string
         */
@@ -109,21 +109,22 @@ class FileSystemNavigationFrameController implements ControllerInterface {
 
                // Create folder tree object:
                if (!empty($this->scopeData)) {
-                       $className = $this->scopeData['class'];
-                       $this->foldertree = GeneralUtility::makeInstance($className);
+                       $this->foldertree = GeneralUtility::makeInstance($this->scopeData['class']);
                        $this->foldertree->thisScript = $this->scopeData['script'];
                        $this->foldertree->ext_noTempRecyclerDirs = $this->scopeData['ext_noTempRecyclerDirs'];
-                       $GLOBALS['SOBE']->browser = new \stdClass();
-                       $GLOBALS['SOBE']->browser->mode = $this->scopeData['browser']['mode'];
-                       $GLOBALS['SOBE']->browser->act = $this->scopeData['browser']['act'];
+                       if ($this->foldertree instanceof ElementBrowserFolderTreeView) {
+                               $browser = GeneralUtility::makeInstance(ElementBrowser::class);
+                               $browser->mode = $this->scopeData['browser']['mode'];
+                               $browser->act = $this->scopeData['browser']['act'];
+                               $this->foldertree->setElementBrowser($browser);
+                       }
                } else {
-                       $className = FileListFolderTree::class;
-                       $this->foldertree = GeneralUtility::makeInstance($className);
+                       $this->foldertree = GeneralUtility::makeInstance(FileListFolderTree::class);
                        $this->foldertree->thisScript = BackendUtility::getModuleUrl('file_navframe');
                }
                // Only set ext_IconMode if we are not running an ajax request from the ElementBrowser,
                // which has this property hardcoded to 1.
-               if ($className !== ElementBrowserFolderTreeView::class) {
+               if (!$this->foldertree instanceof ElementBrowserFolderTreeView::class) {
                        $this->foldertree->ext_IconMode = $this->getBackendUser()->getTSConfigVal('options.folderTree.disableIconLinkToContextmenu');
                }
        }
@@ -242,7 +243,6 @@ class FileSystemNavigationFrameController implements ControllerInterface {
         * @return void
         */
        public function ajaxExpandCollapse($params, $ajaxObj) {
-               $this->init();
                $tree = $this->foldertree->getBrowsableTree();
                if ($this->foldertree->getAjaxStatus() === FALSE) {
                        $ajaxObj->setError($tree);
index 5349a3e..1078ce0 100644 (file)
@@ -18,13 +18,14 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Recordlist\Browser\ElementBrowser;
+use TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList;
 
 /**
  * Displays the page/file tree for browsing database records or files.
  * Used from TCEFORMS an other elements
  * In other words: This is the ELEMENT BROWSER!
  */
-class ElementBrowserRecordList extends \TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList {
+class ElementBrowserRecordList extends DatabaseRecordList {
 
        /**
         * Table name of the field pointing to this element browser
@@ -41,9 +42,14 @@ class ElementBrowserRecordList extends \TYPO3\CMS\Recordlist\RecordList\Database
        protected $relatingField;
 
        /**
-        * Initializes the script path
+        * Back-reference to ElementBrowser class
         *
-        * @return void
+        * @var ElementBrowser
+        */
+       protected $elementBrowser;
+
+       /**
+        * Initializes the script path
         */
        public function __construct() {
                parent::__construct();
@@ -51,6 +57,14 @@ class ElementBrowserRecordList extends \TYPO3\CMS\Recordlist\RecordList\Database
        }
 
        /**
+        * @param ElementBrowser $elementBrowser
+        * @return void
+        */
+       public function setElementBrowser(ElementBrowser $elementBrowser) {
+               $this->elementBrowser = $elementBrowser;
+       }
+
+       /**
         * Creates the URL for links
         *
         * @param mixed $altId If not blank string, this is used instead of $this->id as the id value.
@@ -58,8 +72,15 @@ class ElementBrowserRecordList extends \TYPO3\CMS\Recordlist\RecordList\Database
         * @param string $exclList Commalist of fields NOT to pass as parameters (currently "sortField" and "sortRev")
         * @return string Query-string for URL
         */
-       public function listURL($altId = '', $table = -1, $exclList = '') {
-               return $this->getThisScript() . 'id=' . ($altId !== '' ? $altId : $this->id) . '&table=' . rawurlencode(($table == -1 ? $this->table : $table)) . ($this->thumbs ? '&imagemode=' . $this->thumbs : '') . ($this->searchString ? '&search_field=' . rawurlencode($this->searchString) : '') . ($this->searchLevels ? '&search_levels=' . rawurlencode($this->searchLevels) : '') . ((!$exclList || !GeneralUtility::inList($exclList, 'sortField')) && $this->sortField ? '&sortField=' . rawurlencode($this->sortField) : '') . ((!$exclList || !GeneralUtility::inList($exclList, 'sortRev')) && $this->sortRev ? '&sortRev=' . rawurlencode($this->sortRev) : '') . $this->ext_addP();
+       public function listURL($altId = '', $table = '-1', $exclList = '') {
+               return $this->getThisScript() . 'id=' . ($altId !== '' ? $altId : $this->id)
+                       . '&table=' . rawurlencode((int)$table === -1 ? $this->table : $table)
+                       . ($this->thumbs ? '&imagemode=' . $this->thumbs : '')
+                       . ($this->searchString ? '&search_field=' . rawurlencode($this->searchString) : '')
+                       . ($this->searchLevels ? '&search_levels=' . rawurlencode($this->searchLevels) : '')
+                       . ((!$exclList || !GeneralUtility::inList($exclList, 'sortField')) && $this->sortField ? '&sortField=' . rawurlencode($this->sortField) : '')
+                       . ((!$exclList || !GeneralUtility::inList($exclList, 'sortRev')) && $this->sortRev ? '&sortRev=' . rawurlencode($this->sortRev) : '')
+                       . $this->ext_addP();
        }
 
        /**
@@ -68,10 +89,7 @@ class ElementBrowserRecordList extends \TYPO3\CMS\Recordlist\RecordList\Database
         * @return string
         */
        public function ext_addP() {
-               /** @var ElementBrowser $elementBrowser */
-               $elementBrowser = $GLOBALS['SOBE']->browser;
-               $str = '&act=' . $elementBrowser->act . '&mode=' . $elementBrowser->mode . '&expandPage=' . $elementBrowser->expandPage . '&bparams=' . rawurlencode($elementBrowser->bparams);
-               return $str;
+               return '&act=' . $this->elementBrowser->act . '&mode=' . $this->elementBrowser->mode . '&expandPage=' . $this->elementBrowser->expandPage . '&bparams=' . rawurlencode($this->elementBrowser->bparams);
        }
 
        /**
@@ -85,7 +103,7 @@ class ElementBrowserRecordList extends \TYPO3\CMS\Recordlist\RecordList\Database
         */
        public function linkWrapItems($table, $uid, $code, $row) {
                if (!$code) {
-                       $code = '<i>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', TRUE) . ']</i>';
+                       $code = '<i>[' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', TRUE) . ']</i>';
                } else {
                        $code = BackendUtility::getRecordTitlePrep($code, $this->fixedL);
                }
@@ -95,7 +113,7 @@ class ElementBrowserRecordList extends \TYPO3\CMS\Recordlist\RecordList\Database
                $ATag = '<a href="#" onclick="' . $aOnClick . '">';
                $ATag_alt = substr($ATag, 0, -4) . ',\'\',1);">';
                $ATag_e = '</a>';
-               return $ATag . IconUtility::getSpriteIcon('actions-edit-add', array('title' => $GLOBALS['LANG']->getLL('addToList', TRUE))) . $ATag_e . $ATag_alt . $code . $ATag_e;
+               return $ATag . IconUtility::getSpriteIcon('actions-edit-add', array('title' => $this->getLanguageService()->getLL('addToList', TRUE))) . $ATag_e . $ATag_alt . $code . $ATag_e;
        }
 
        /**
index ca87beb..c7cadd4 100644 (file)
@@ -33,6 +33,13 @@ class ElementBrowserFolderTreeView extends FolderTreeView {
        public $ext_IconMode = 1;
 
        /**
+        * Back-reference to ElementBrowser class
+        *
+        * @var ElementBrowser
+        */
+       protected $elementBrowser;
+
+       /**
         * Initializes the script path
         */
        public function __construct() {
@@ -41,6 +48,14 @@ class ElementBrowserFolderTreeView extends FolderTreeView {
        }
 
        /**
+        * @param ElementBrowser $elementBrowser
+        * @return void
+        */
+       public function setElementBrowser(ElementBrowser $elementBrowser) {
+               $this->elementBrowser = $elementBrowser;
+       }
+
+       /**
         * Wrapping the title in a link, if applicable.
         *
         * @param string $title Title, ready for output.
@@ -49,9 +64,7 @@ class ElementBrowserFolderTreeView extends FolderTreeView {
         */
        public function wrapTitle($title, Folder $folderObject) {
                if ($this->ext_isLinkable($folderObject)) {
-                       /** @var ElementBrowser $elementBrowser */
-                       $elementBrowser = $GLOBALS['SOBE']->browser;
-                       $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $elementBrowser->act . '&mode=' . $elementBrowser->mode . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier())) . ');';
+                       $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $this->elementBrowser->act . '&mode=' . $this->elementBrowser->mode . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier())) . ');';
                        return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
                } else {
                        return '<span class="text-muted">' . $title . '</span>';
@@ -92,4 +105,29 @@ class ElementBrowserFolderTreeView extends FolderTreeView {
                return '<a href="#"' . htmlspecialchars($name) . ' onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
        }
 
+       /**
+        * Wrap the plus/minus icon in a link
+        *
+        * @param string $icon HTML string to wrap, probably an image tag.
+        * @param string $cmd Command for 'PM' get var
+        * @param bool $isExpand Whether to be expanded
+        * @return string Link-wrapped input string
+        * @internal
+        */
+       public function PMiconATagWrap($icon, $cmd, $isExpand = TRUE) {
+               if (empty($this->scope)) {
+                       $this->scope = array(
+                               'class' => get_class($this),
+                               'script' => $this->thisScript,
+                               'ext_noTempRecyclerDirs' => $this->ext_noTempRecyclerDirs,
+                               'browser' => array(
+                                       'mode' => $this->elementBrowser->mode,
+                                       'act' => $this->elementBrowser->act,
+                               ),
+                       );
+               }
+
+               return parent::PMiconATagWrap($icon, $cmd, $isExpand);
+       }
+
 }
index ae48b28..accd0ba 100644 (file)
@@ -44,6 +44,13 @@ class ElementBrowserPageTreeView extends BrowseTreeView {
        public $ext_pArrPages = TRUE;
 
        /**
+        * Back-reference to ElementBrowser class
+        *
+        * @var ElementBrowser
+        */
+       protected $elementBrowser;
+
+       /**
         * Constructor. Just calling init()
         */
        public function __construct() {
@@ -53,6 +60,14 @@ class ElementBrowserPageTreeView extends BrowseTreeView {
        }
 
        /**
+        * @param ElementBrowser $elementBrowser
+        * @return void
+        */
+       public function setElementBrowser(ElementBrowser $elementBrowser) {
+               $this->elementBrowser = $elementBrowser;
+       }
+
+       /**
         * Wrapping the title in a link, if applicable.
         *
         * @param string $title Title, (must be ready for output, that means it must be htmlspecialchars()'ed).
@@ -95,14 +110,12 @@ class ElementBrowserPageTreeView extends BrowseTreeView {
                                $classAttr .= ' list-tree-control-open';
                        }
 
-                       /** @var ElementBrowser $elementBrowser */
-                       $elementBrowser = $GLOBALS['SOBE']->browser;
                        $selected = '';
-                       if ($elementBrowser->curUrlInfo['act'] == 'page' && $elementBrowser->curUrlInfo['pageid'] == $treeItem['row']['uid'] && $elementBrowser->curUrlInfo['pageid']) {
+                       if ($this->elementBrowser->curUrlInfo['act'] == 'page' && $this->elementBrowser->curUrlInfo['pageid'] == $treeItem['row']['uid'] && $this->elementBrowser->curUrlInfo['pageid']) {
                                $selected = ' bg-success';
                                $classAttr .= ' active';
                        }
-                       $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $elementBrowser->act . '&mode=' . $elementBrowser->mode . '&expandPage=' . $treeItem['row']['uid']) . ');';
+                       $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $this->elementBrowser->act . '&mode=' . $this->elementBrowser->mode . '&expandPage=' . $treeItem['row']['uid']) . ');';
                        $cEbullet = $this->ext_isLinkable($treeItem['row']['doktype'], $treeItem['row']['uid']) ? '<a href="#" class="list-tree-show" onclick="' . htmlspecialchars($aOnClick) . '"><i class="fa fa-caret-square-o-right"></i></a>' : '';
                        $out .= '
                                <li' . ($classAttr ? ' class="' . trim($classAttr) . '"' : '') . '>
index 2fa4a93..f6ba343 100644 (file)
@@ -16,10 +16,11 @@ namespace TYPO3\CMS\Backend\Tree\View;
 
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Core\Resource\Folder;
 use TYPO3\CMS\Core\Resource\FolderInterface;
+use TYPO3\CMS\Core\Resource\InaccessibleFolder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Lang\LanguageService;
-use TYPO3\CMS\Recordlist\Browser\ElementBrowser;
 
 /**
  * Generate a folder tree,
@@ -118,16 +119,10 @@ class FolderTreeView extends AbstractTreeView {
        public function PMiconATagWrap($icon, $cmd, $isExpand = TRUE) {
 
                if (empty($this->scope)) {
-                       /** @var ElementBrowser $elementBrowser */
-                       $elementBrowser = $GLOBALS['SOBE']->browser;
                        $this->scope = array(
                                'class' => get_class($this),
                                'script' => $this->thisScript,
-                               'ext_noTempRecyclerDirs' => $this->ext_noTempRecyclerDirs,
-                               'browser' => array(
-                                       'mode' => $elementBrowser->mode,
-                                       'act' => $elementBrowser->act,
-                               ),
+                               'ext_noTempRecyclerDirs' => $this->ext_noTempRecyclerDirs
                        );
                }
 
@@ -156,7 +151,7 @@ class FolderTreeView extends AbstractTreeView {
                // Wrap icon in click-menu link.
                if (!$this->ext_IconMode) {
                        // Check storage access to wrap with click menu
-                       if (!$folderObject instanceof \TYPO3\CMS\Core\Resource\InaccessibleFolder) {
+                       if (!$folderObject instanceof InaccessibleFolder) {
                                $theFolderIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($icon, $folderObject->getCombinedIdentifier(), '', 0);
                        }
                } elseif ($this->ext_IconMode === 'titlelink') {
@@ -177,7 +172,7 @@ class FolderTreeView extends AbstractTreeView {
         */
        public function wrapTitle($title, $folderObject, $bank = 0) {
                // Check storage access to wrap with click menu
-               if ($folderObject instanceof \TYPO3\CMS\Core\Resource\InaccessibleFolder) {
+               if ($folderObject instanceof InaccessibleFolder) {
                        return $title;
                }
                $aOnClick = 'return jumpTo(' . GeneralUtility::quoteJSvalue($this->getJumpToParam($folderObject)) . ', this, ' . GeneralUtility::quoteJSvalue($this->domIdPrefix . $this->getId($folderObject)) . ', ' . $bank . ');';
@@ -345,7 +340,7 @@ class FolderTreeView extends AbstractTreeView {
 
                // This generates the directory tree
                /* array of \TYPO3\CMS\Core\Resource\Folder */
-               if ($folderObject instanceof \TYPO3\CMS\Core\Resource\InaccessibleFolder) {
+               if ($folderObject instanceof InaccessibleFolder) {
                        $subFolders = array();
                } else {
                        $subFolders = $folderObject->getSubfolders();
@@ -356,13 +351,15 @@ class FolderTreeView extends AbstractTreeView {
                $totalSubFolders = count($subFolders);
                $HTML = '';
                $subFolderCounter = 0;
+               $treeKey = '';
+               /** @var Folder $subFolder */
                foreach ($subFolders as $subFolderName => $subFolder) {
                        $subFolderCounter++;
                        // Reserve space.
                        $this->tree[] = array();
                        // Get the key for this space
                        end($this->tree);
-                       $isLocked = $subFolder instanceof \TYPO3\CMS\Core\Resource\InaccessibleFolder;
+                       $isLocked = $subFolder instanceof InaccessibleFolder;
                        $treeKey = key($this->tree);
                        $specUID = GeneralUtility::md5int($subFolder->getCombinedIdentifier());
                        $this->specUIDmap[$specUID] = $subFolder->getCombinedIdentifier();
@@ -436,13 +433,13 @@ class FolderTreeView extends AbstractTreeView {
                        return $message->render();
                }
 
+               $expandedFolderHash = '';
+               $invertedDepthOfAjaxRequestedItem = 0;
                $out = '<ul class="list-tree list-tree-root">';
                // Evaluate AJAX request
                if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX) {
                        list(, $expandCollapseCommand, $expandedFolderHash, ) = $this->evaluateExpandCollapseParameter();
                        if ($expandCollapseCommand == 1) {
-                               // We don't know yet. Will be set later.
-                               $invertedDepthOfAjaxRequestedItem = 0;
                                $doExpand = TRUE;
                        } else {
                                $doCollapse = TRUE;
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-69276-ElementBrowserControllerbrowserRemoved.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-69276-ElementBrowserControllerbrowserRemoved.rst
new file mode 100644 (file)
index 0000000..89bee9d
--- /dev/null
@@ -0,0 +1,28 @@
+=============================================================
+Breaking: #69276 - ElementBrowserController::$browser removed
+=============================================================
+
+Description
+===========
+
+The ``$browser`` member of ``\TYPO3\CMS\Recordlist\Controller\ElementBrowserController`` has been removed.
+
+
+Impact
+======
+
+Any third party code accessing ``$GLOBAL['SOBE']->browser`` will break.
+
+
+Affected Installations
+======================
+
+Installations using third party code, which accesses ``$GLOBAL['SOBE']->browser``.
+
+
+Migration
+=========
+
+If the code is extending one of the ElementBrowser tree classes, the protected member ``$elementBrowser`` can be used to access the underlying ElementBrowser instance.
+
+If your code is using the ElementBrowser tree classes, an instance of ``ElementBrowser`` has to be injected using the setter.
\ No newline at end of file
index 6865766..b19e9a6 100755 (executable)
@@ -1264,6 +1264,7 @@ class ElementBrowser {
 
                /** @var ElementBrowserPageTreeView $pageTree */
                $pageTree = GeneralUtility::makeInstance($treeClassName);
+               $pageTree->setElementBrowser($this);
                $pageTree->thisScript = $this->thisScript;
                $pageTree->ext_showPageId = (bool)$backendUser->getTSConfigVal('options.pageTree.showPageIdWithTitle');
                $pageTree->ext_showNavTitle = (bool)$backendUser->getTSConfigVal('options.pageTree.showNavTitle');
@@ -1305,6 +1306,7 @@ class ElementBrowser {
                // Making the browsable pagetree:
                /** @var \TYPO3\CMS\Recordlist\Tree\View\ElementBrowserPageTreeView $pageTree */
                $pageTree = GeneralUtility::makeInstance(\TYPO3\CMS\Recordlist\Tree\View\ElementBrowserPageTreeView::class);
+               $pageTree->setElementBrowser($this);
                $pageTree->thisScript = $this->thisScript;
                $pageTree->ext_pArrPages = $tables === 'pages';
                $pageTree->ext_showNavTitle = (bool)$backendUser->getTSConfigVal('options.pageTree.showNavTitle');
@@ -1690,6 +1692,7 @@ class ElementBrowser {
                } else {
                        $dbList = GeneralUtility::makeInstance(ElementBrowserRecordList::class);
                }
+               $dbList->setElementBrowser($this);
                $dbList->thisScript = $this->thisScript;
                $dbList->thumbs = 0;
                $dbList->localizationView = 1;
@@ -2336,14 +2339,10 @@ class ElementBrowser {
         * This method is intended to be used by Extensions that implement their own browsing functionality.
         *
         * @param ElementBrowserRecordList $recordList
-        * @throws \InvalidArgumentException
         * @return void
         * @api
         */
-       public function setRecordList($recordList) {
-               if (!$recordList instanceof ElementBrowserRecordList) {
-                       throw new \InvalidArgumentException('$recordList needs to be an instance of ' . ElementBrowserRecordList::class, 1370878522);
-               }
+       public function setRecordList(ElementBrowserRecordList $recordList) {
                $this->recordList = $recordList;
        }
 
index 2e498be..def91e9 100644 (file)
@@ -42,18 +42,6 @@ class ElementBrowserController implements \TYPO3\CMS\Core\Http\ControllerInterfa
        public $mode;
 
        /**
-        * Holds an instance of ElementBrowser class or a subclass
-        *
-        * This is needed fo intercommunication between tree classes that
-        * need access to variables via $GLOBALS['SOBE'].
-        * Not the most nice solution but introduced since we don't have
-        * another general way to return class-instances or registry for now
-        *
-        * @var ElementBrowser
-        */
-       public $browser;
-
-       /**
         * Document template object
         *
         * @var DocumentTemplate
@@ -131,30 +119,30 @@ class ElementBrowserController implements \TYPO3\CMS\Core\Http\ControllerInterfa
                }
                // if type was not rendered use default rendering functions
                if (!$browserRendered) {
-                       $this->browser = $this->getElementBrowserInstance();
-                       $this->browser->init();
+                       $browser = $this->getElementBrowserInstance();
+                       $browser->init();
                        $backendUser = $this->getBackendUser();
                        $modData = $backendUser->getModuleData('browse_links.php', 'ses');
-                       list($modData) = $this->browser->processSessionData($modData);
+                       list($modData) = $browser->processSessionData($modData);
                        $backendUser->pushModuleData('browse_links.php', $modData);
 
                        // Output the correct content according to $this->mode
                        switch ((string)$this->mode) {
                                case 'rte':
-                                       $this->content = $this->browser->main_rte();
+                                       $this->content = $browser->main_rte();
                                        break;
                                case 'db':
-                                       $this->content = $this->browser->main_db();
+                                       $this->content = $browser->main_db();
                                        break;
                                case 'file':
                                case 'filedrag':
-                                       $this->content = $this->browser->main_file();
+                                       $this->content = $browser->main_file();
                                        break;
                                case 'folder':
-                                       $this->content = $this->browser->main_folder();
+                                       $this->content = $browser->main_folder();
                                        break;
                                case 'wizard':
-                                       $this->content = $this->browser->main_rte(TRUE);
+                                       $this->content = $browser->main_rte(TRUE);
                                        break;
                        }
                }
index 5c2601f..58e2771 100644 (file)
@@ -16,7 +16,6 @@ namespace TYPO3\CMS\Recordlist\Tree\View;
 
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Recordlist\Controller\ElementBrowserController;
 
 /**
  * Extension class for the TBE record browser
@@ -47,9 +46,7 @@ class ElementBrowserPageTreeView extends \TYPO3\CMS\Backend\Tree\View\ElementBro
                        $ficon = IconUtility::getSpriteIconForRecord('pages', $v);
                        $onClick = 'return insertElement(\'pages\', \'' . $v['uid'] . '\', \'db\', ' . GeneralUtility::quoteJSvalue($v['title']) . ', \'\', \'\', ' . GeneralUtility::quoteJSvalue($ficon) . ',\'\',1);';
                } else {
-                       /** @var ElementBrowserController $controller */
-                       $controller = $GLOBALS['SOBE'];
-                       $onClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $controller->browser->act . '&mode=' . $controller->browser->mode . '&expandPage=' . $v['uid']) . ');';
+                       $onClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $this->elementBrowser->act . '&mode=' . $this->elementBrowser->mode . '&expandPage=' . $v['uid']) . ');';
                }
                return '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' . $title . '</a>';
        }
index 25fc697..98c0dad 100644 (file)
@@ -25,12 +25,6 @@ use TYPO3\CMS\Rtehtmlarea\BrowseLinks;
 class BrowseLinksController extends ElementBrowserController {
 
        /**
-        * Typehint needed for code completion
-        * @var BrowseLinks
-        */
-       public $browser;
-
-       /**
         * Initialize controller
         */
        protected function init() {
index 70ab68a..4c33f34 100644 (file)
@@ -25,12 +25,6 @@ use TYPO3\CMS\Rtehtmlarea\SelectImage;
 class SelectImageController extends ElementBrowserController {
 
        /**
-        * Typehint needed for code completion
-        * @var SelectImage
-        */
-       public $browser;
-
-       /**
         * Initialize controller
         */
        protected function init() {
index 664f05f..d0a4d1e 100644 (file)
@@ -24,6 +24,11 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 class FolderTree extends ElementBrowserFolderTreeView {
 
        /**
+        * @var BrowseLinks|SelectImage
+        */
+       protected $elementBrowser;
+
+       /**
         * Will create and return the HTML code for a browsable tree of folders.
         * Is based on the mounts found in the internal array ->MOUNTS (set in the constructor)
         *
@@ -31,21 +36,19 @@ class FolderTree extends ElementBrowserFolderTreeView {
         */
        public function getBrowsableTree() {
                // TYPO3\CMS\Backend\Controller\FileSystemNavigationFrameController does not set custom parameters on an Ajax expand/collapse request
-               /** @var BrowseLinks|SelectImage $elementBrowser */
-               $elementBrowser = $GLOBALS['SOBE']->browser;
-               if (!$elementBrowser->editorNo) {
+               if (!$this->elementBrowser->editorNo) {
                        $scopeData = (string)GeneralUtility::_GP('scopeData');
                        $scopeHash = (string)GeneralUtility::_GP('scopeHash');
                        if (!empty($scopeData) && GeneralUtility::hmac($scopeData) === $scopeHash) {
                                $scopeData = unserialize($scopeData);
                                if ($scopeData['browser']['editorNo']) {
-                                       $elementBrowser->editorNo = $scopeData['browser']['editorNo'];
+                                       $this->elementBrowser->editorNo = $scopeData['browser']['editorNo'];
                                }
-                               if ($scopeData['browser']['sys_language_content']) {
-                                       $elementBrowser->sys_language_content = $scopeData['browser']['sys_language_content'];
+                               if ($this->elementBrowser instanceof SelectImage && $scopeData['browser']['sys_language_content']) {
+                                       $this->elementBrowser->sys_language_content = $scopeData['browser']['sys_language_content'];
                                }
-                               if ($scopeData['browser']['contentTypo3Language']) {
-                                       $elementBrowser->contentTypo3Language = $scopeData['browser']['contentTypo3Language'];
+                               if ($this->elementBrowser instanceof BrowseLinks && $scopeData['browser']['contentTypo3Language']) {
+                                       $this->elementBrowser->contentTypo3Language = $scopeData['browser']['contentTypo3Language'];
                                }
                        }
                }
@@ -61,21 +64,20 @@ class FolderTree extends ElementBrowserFolderTreeView {
         */
        public function wrapTitle($title, Folder $folderObject) {
                if ($this->ext_isLinkable($folderObject)) {
-                       /** @var BrowseLinks|SelectImage $elementBrowser */
-                       $elementBrowser = $GLOBALS['SOBE']->browser;
-                       $aOnClick = 'return jumpToUrl(\''
-                               . $this->getThisScript()
-                               . 'act=' . $elementBrowser->act
-                               . '&mode=' . $elementBrowser->mode
-                               . '&editorNo=' . $elementBrowser->editorNo
-                               . ($elementBrowser->sys_language_content ? '&sys_language_content=' . $elementBrowser->sys_language_content : '')
-                               . ($elementBrowser->contentTypo3Language ? '&contentTypo3Language=' . $elementBrowser->contentTypo3Language : '')
-                               . '&expandFolder=' . $this->getJumpToParam($folderObject)
-                               . '\');';
+                       $parameters = 'act=' . $this->elementBrowser->act
+                               . '&mode=' . $this->elementBrowser->mode
+                               . '&editorNo=' . $this->elementBrowser->editorNo
+                               . '&expandFolder=' . $this->getJumpToParam($folderObject);
+                       if ($this->elementBrowser instanceof SelectImage && $this->elementBrowser->sys_language_content) {
+                               $parameters .= '&sys_language_content=' . $this->elementBrowser->sys_language_content;
+                       }
+                       if ($this->elementBrowser instanceof BrowseLinks && $this->elementBrowser->contentTypo3Language) {
+                               $parameters .= '&contentTypo3Language=' . $this->elementBrowser->contentTypo3Language;
+                       }
+                       $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . $parameters) . ');';
                        return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
-               } else {
-                       return '<span class="text-muted">' . $title . '</span>';
                }
+               return '<span class="text-muted">' . $title . '</span>';
        }
 
        /**
@@ -89,25 +91,27 @@ class FolderTree extends ElementBrowserFolderTreeView {
         */
        public function PMiconATagWrap($icon, $cmd, $isExpand = TRUE) {
                if (empty($this->scope)) {
-                       /** @var BrowseLinks|SelectImage $elementBrowser */
-                       $elementBrowser = $GLOBALS['SOBE']->browser;
                        $this->scope = array(
                                'class' => get_class($this),
                                'script' => $this->thisScript,
                                'ext_noTempRecyclerDirs' => $this->ext_noTempRecyclerDirs,
                                'browser' => array(
-                                       'mode' => $elementBrowser->mode,
-                                       'act' => $elementBrowser->act
+                                       'mode' => $this->elementBrowser->mode,
+                                       'act' => $this->elementBrowser->act
                                )
                        );
-                       if ($elementBrowser->editorNo) {
-                               $this->scope['browser']['editorNo'] = $elementBrowser->editorNo;
-                       }
-                       if ($elementBrowser->sys_language_content) {
-                               $this->scope['browser']['sys_language_content'] = $elementBrowser->sys_language_content;
+                       if ($this->elementBrowser instanceof BrowseLinks) {
+                               if ($this->elementBrowser->editorNo) {
+                                       $this->scope['browser']['editorNo'] = $this->elementBrowser->editorNo;
+                               }
+                               if ($this->elementBrowser->contentTypo3Language) {
+                                       $this->scope['browser']['contentTypo3Language'] = $this->elementBrowser->contentTypo3Language;
+                               }
                        }
-                       if ($elementBrowser->contentTypo3Language) {
-                               $this->scope['browser']['contentTypo3Language'] = $elementBrowser->contentTypo3Language;
+                       if ($this->elementBrowser instanceof SelectImage) {
+                               if ($this->elementBrowser->sys_language_content) {
+                                       $this->scope['browser']['sys_language_content'] = $this->elementBrowser->sys_language_content;
+                               }
                        }
                }
                return parent::PMiconATagWrap($icon, $cmd, $isExpand);
index f21501e..ea1aec0 100644 (file)
@@ -24,7 +24,6 @@ namespace TYPO3\CMS\Rtehtmlarea;
 
 use TYPO3\CMS\Backend\Tree\View\ElementBrowserPageTreeView;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Rtehtmlarea\Controller\BrowseLinksController;
 
 /**
  * Class which generates the page tree
@@ -32,6 +31,13 @@ use TYPO3\CMS\Rtehtmlarea\Controller\BrowseLinksController;
 class PageTree extends ElementBrowserPageTreeView {
 
        /**
+        * Back-reference to ElementBrowser class for RTE
+        *
+        * @var BrowseLinks
+        */
+       protected $elementBrowser;
+
+       /**
         * Create the page navigation tree in HTML
         *
         * @param array|string $treeArr Tree array
@@ -57,15 +63,13 @@ class PageTree extends ElementBrowserPageTreeView {
                        }
 
                        $selected = '';
-                       /** @var BrowseLinksController $controller */
-                       $controller = $GLOBALS['SOBE'];
-                       if ($controller->browser->curUrlInfo['act'] === 'page' && $controller->browser->curUrlInfo['pageid'] == $treeItem['row']['uid'] && $controller->browser->curUrlInfo['pageid']) {
+                       if ($this->elementBrowser->curUrlInfo['act'] === 'page' && $this->elementBrowser->curUrlInfo['pageid'] == $treeItem['row']['uid'] && $this->elementBrowser->curUrlInfo['pageid']) {
                                $selected = ' bg-success';
                        }
                        $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript()
-                                       . 'act=' . $controller->browser->act . '&editorNo=' . $controller->browser->editorNo
-                                       . '&contentTypo3Language=' . $controller->browser->contentTypo3Language
-                                       . '&mode=' . $controller->browser->mode . '&expandPage=' . $treeItem['row']['uid']) . ');';
+                                       . 'act=' . $this->elementBrowser->act . '&editorNo=' . $this->elementBrowser->editorNo
+                                       . '&contentTypo3Language=' . $this->elementBrowser->contentTypo3Language
+                                       . '&mode=' . $this->elementBrowser->mode . '&expandPage=' . $treeItem['row']['uid']) . ');';
                        $cEbullet = $this->ext_isLinkable($treeItem['row']['doktype'], $treeItem['row']['uid'])
                                ? '<a href="#" class="pull-right" onclick="' . htmlspecialchars($aOnClick) . '"><i class="fa fa-caret-square-o-right"></i></a>'
                                : '';