[CLEANUP] sysext:recordlist 87/36087/10
authorMarkus Klein <klein.t3@reelworx.at>
Sat, 17 Jan 2015 20:11:59 +0000 (21:11 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Fri, 30 Jan 2015 18:06:58 +0000 (19:06 +0100)
Resolves: #64337
Releases: master
Change-Id: Ie813bf610bbaaf75e87fe22e40478bb09ab109db
Reviewed-on: http://review.typo3.org/36087
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Classes/View/PageLayoutView.php
typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php
typo3/sysext/recordlist/Classes/Controller/ElementBrowserController.php
typo3/sysext/recordlist/Classes/Controller/ElementBrowserFramesetController.php
typo3/sysext/recordlist/Classes/RecordList.php
typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php
typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php

index 1ba3d3c..8da8b3b 100644 (file)
@@ -15,7 +15,6 @@ namespace TYPO3\CMS\Backend\View;
  */
 
 use TYPO3\CMS\Backend\Controller\PageLayoutController;
-use TYPO3\CMS\Backend\Template\DocumentTemplate;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
@@ -23,7 +22,6 @@ use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Versioning\VersionState;
-use TYPO3\CMS\Lang\LanguageService;
 
 /**
  * Child class for the Web > Page module
@@ -2246,24 +2244,10 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
        }
 
        /**
-        * @return LanguageService
-        */
-       protected function getLanguageService() {
-               return $GLOBALS['LANG'];
-       }
-
-       /**
         * @return PageLayoutController
         */
        protected function getPageLayoutController() {
                return $GLOBALS['SOBE'];
        }
 
-       /**
-        * @return DocumentTemplate
-        */
-       protected function getDocumentTemplate() {
-               return $GLOBALS['TBE_TEMPLATE'];
-       }
-
 }
index fe45e39..39745c6 100644 (file)
@@ -14,11 +14,28 @@ namespace TYPO3\CMS\Recordlist\Browser;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Form\FormEngine;
+use TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList;
+use TYPO3\CMS\Backend\Template\DocumentTemplate;
+use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\Database\DatabaseConnection;
+use TYPO3\CMS\Core\ElementBrowser\ElementBrowserHookInterface;
+use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Core\Resource\Exception;
 use TYPO3\CMS\Core\Resource\File;
+use TYPO3\CMS\Core\Resource\FileInterface;
+use TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter;
 use TYPO3\CMS\Core\Resource\Folder;
+use TYPO3\CMS\Core\Resource\InaccessibleFolder;
+use TYPO3\CMS\Core\Resource\ProcessedFile;
+use TYPO3\CMS\Core\Resource\ResourceFactory;
+use TYPO3\CMS\Core\Utility\File\BasicFileUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\Utility\MathUtility;
+use TYPO3\CMS\Core\Utility\PathUtility;
+use TYPO3\CMS\Lang\LanguageService;
 
 /**
  * class for the Element Browser window.
@@ -31,7 +48,7 @@ class ElementBrowser {
         * Optional instance of a record list that TBE_expandPage() should
         * use to render the records in a page
         *
-        * @var \TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList
+        * @var ElementBrowserRecordList
         */
        protected $recordList = NULL;
 
@@ -53,7 +70,7 @@ class ElementBrowser {
        /**
         * RTE specific TSconfig
         *
-        * @var array
+        * @var array[]
         */
        public $thisConfig;
 
@@ -86,14 +103,14 @@ class ElementBrowser {
        /**
         * Backend template object
         *
-        * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
+        * @var DocumentTemplate
         */
        public $doc;
 
        /**
         * Holds information about files
         *
-        * @var array
+        * @var mixed[][]
         */
        public $elements = array();
 
@@ -150,7 +167,7 @@ class ElementBrowser {
         * TYPO3 Element Browser, wizard mode parameters. There is a heap of parameters there,
         * better debug() them out if you need something... :-)
         *
-        * @var array
+        * @var array[]
         */
        public $P;
 
@@ -205,7 +222,7 @@ class ElementBrowser {
         * in the RTE/TCEform field. This consists of "href", "target" and "title" keys.
         * This information is passed around in links.
         *
-        * @var array
+        * @var array[]
         */
        public $curUrlArray;
 
@@ -214,19 +231,19 @@ class ElementBrowser {
         * This is splitted into pageid, content element id, label value etc.
         * This is used for the internal processing of that information.
         *
-        * @var array
+        * @var array[]
         */
        public $curUrlInfo;
 
        /**
         * array which holds hook objects (initialised in init())
         *
-        * @var \TYPO3\CMS\Core\ElementBrowser\ElementBrowserHookInterface[]
+        * @var ElementBrowserHookInterface[]
         */
        protected $hookObjects = array();
 
        /**
-        * @var \TYPO3\CMS\Core\Utility\File\BasicFileUtility
+        * @var BasicFileUtility
         */
        public $fileProcessor;
 
@@ -319,7 +336,7 @@ class ElementBrowser {
                }
 
                // Init fileProcessor
-               $this->fileProcessor = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Utility\File\BasicFileUtility::class);
+               $this->fileProcessor = GeneralUtility::makeInstance(BasicFileUtility::class);
                $this->fileProcessor->init(array(), $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
        }
 
@@ -342,7 +359,7 @@ class ElementBrowser {
         */
        protected function initDocumentTemplate() {
                // Creating backend template object:
-               $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
+               $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
                $this->doc->bodyTagId = 'typo3-browse-links-php';
                $this->doc->backPath = $GLOBALS['BACK_PATH'];
                $this->doc->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/BrowseLinks');
@@ -360,8 +377,8 @@ class ElementBrowser {
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][$hookKey]['browseLinksHook'])) {
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][$hookKey]['browseLinksHook'] as $classData) {
                                $processObject = GeneralUtility::getUserObj($classData);
-                               if (!$processObject instanceof \TYPO3\CMS\Core\ElementBrowser\ElementBrowserHookInterface) {
-                                       throw new \UnexpectedValueException('$processObject must implement interface ' . \TYPO3\CMS\Core\ElementBrowser\ElementBrowserHookInterface::class, 1195039394);
+                               if (!$processObject instanceof ElementBrowserHookInterface) {
+                                       throw new \UnexpectedValueException('$processObject must implement interface ' . ElementBrowserHookInterface::class, 1195039394);
                                }
                                $parameters = array();
                                $processObject->init($this, $parameters);
@@ -419,7 +436,7 @@ class ElementBrowser {
                                        $currentLinkParts[0] = rawurldecode(substr($this->curUrlArray['href'], 5));
                                } elseif (file_exists(PATH_site . rawurldecode($this->curUrlArray['href']))) {
                                        if (GeneralUtility::isFirstPartOfStr($this->curUrlArray['href'], PATH_site)) {
-                                               $currentLinkParts[0] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->curUrlArray['href']);
+                                               $currentLinkParts[0] = PathUtility::stripPathSitePrefix($this->curUrlArray['href']);
                                        }
                                        $this->curUrlInfo = $this->parseCurUrl($this->siteURL . $this->curUrlArray['href'], $this->siteURL);
                                } elseif (strstr($this->curUrlArray['href'], '@')) {
@@ -453,11 +470,11 @@ class ElementBrowser {
        /**
         * Get the RTE configuration from Page TSConfig
         *
-        * @return array RTE configuration array
+        * @return array[] RTE configuration array
         */
        protected function getRTEConfig() {
                $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
-               $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
+               $RTEsetup = $this->getBackendUserAuthentication()->getTSConfig('RTE', BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
                return BackendUtility::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
        }
 
@@ -791,8 +808,8 @@ class ElementBrowser {
         * Session data for this class can be set from outside with this method.
         * Call after init()
         *
-        * @param array $data Session data array
-        * @return array Session data and boolean which indicates that data needs to be stored in session because it's changed
+        * @param mixed[] $data Session data array
+        * @return array[] Session data and boolean which indicates that data needs to be stored in session because it's changed
         */
        public function processSessionData($data) {
                $store = FALSE;
@@ -876,6 +893,7 @@ class ElementBrowser {
                                        $content .= $hookObject->getTab($this->act);
                                }
                }
+               $lang = $this->getLanguageService();
                if (in_array('params', $allowedFields, TRUE)) {
                        $content .= '
                                <!--
@@ -884,7 +902,7 @@ class ElementBrowser {
                                <form action="" name="lparamsform" id="lparamsform">
                                        <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkParams">
                                                <tr>
-                                                       <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('params', TRUE) . '</td>
+                                                       <td style="width: 96px;">' . $lang->getLL('params', TRUE) . '</td>
                                                        <td><input type="text" name="lparams" class="typo3-link-input" onchange="'
                                                                . 'browse_links_setParams(this.value);" value="' . htmlspecialchars($this->setParams)
                                                                . '" /></td>
@@ -901,7 +919,7 @@ class ElementBrowser {
                                <form action="" name="lclassform" id="lclassform">
                                        <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkClass">
                                                <tr>
-                                                       <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('class', TRUE) . '</td>
+                                                       <td style="width: 96px;">' . $lang->getLL('class', TRUE) . '</td>
                                                        <td><input type="text" name="lclass" class="typo3-link-input" onchange="'
                                                                . 'browse_links_setClass(this.value);" value="' . htmlspecialchars($this->setClass)
                                                                . '" /></td>
@@ -918,7 +936,7 @@ class ElementBrowser {
                                <form action="" name="ltitleform" id="ltitleform">
                                        <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTitle">
                                                <tr>
-                                                       <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('title', TRUE) . '</td>
+                                                       <td style="width: 96px;">' . $lang->getLL('title', TRUE) . '</td>
                                                        <td><input type="text" name="ltitle" class="typo3-link-input" onchange="'
                                                                . 'browse_links_setTitle(this.value);" value="' . htmlspecialchars($this->setTitle)
                                                                . '" /></td>
@@ -950,7 +968,7 @@ class ElementBrowser {
                                <form action="" name="ltargetform" id="ltargetform">
                                        <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
                                                <tr>
-                                                       <td>' . $GLOBALS['LANG']->getLL('target', TRUE) . ':</td>
+                                                       <td>' . $lang->getLL('target', TRUE) . ':</td>
                                                        <td><input type="text" name="ltarget" onchange="browse_links_setTarget(this.value);" value="'
                                                                . htmlspecialchars($this->setTarget) . '"' . $this->doc->formWidth(10) . ' /></td>
                                                        <td>
@@ -958,8 +976,8 @@ class ElementBrowser {
                                                                        . '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>
                                                        </td>
                                                        <td>';
@@ -967,7 +985,7 @@ class ElementBrowser {
                                && $this->curUrlArray['href'] && $this->curUrlInfo['act'] == $this->act
                        ) {
                                $ltarget .= '
-                                                       <input class="btn btn-default" type="submit" value="' . $GLOBALS['LANG']->getLL('update', TRUE)
+                                                       <input class="btn btn-default" type="submit" value="' . $lang->getLL('update', TRUE)
                                                                . '" onclick="return link_current();" />';
                        }
                        $selectJS = '
@@ -988,10 +1006,10 @@ class ElementBrowser {
                        $ltarget .= '           </td>
                                                </tr>
                                                <tr>
-                                                       <td>' . $GLOBALS['LANG']->getLL('target_popUpWindow', TRUE) . ':</td>
+                                                       <td>' . $lang->getLL('target_popUpWindow', TRUE) . ':</td>
                                                        <td colspan="3">
                                                                <select name="popup_width" onchange="' . htmlspecialchars($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>
@@ -1001,7 +1019,7 @@ class ElementBrowser {
                                                                </select>
                                                                x
                                                                <select name="popup_height" onchange="' . htmlspecialchars($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>
@@ -1026,7 +1044,7 @@ class ElementBrowser {
        /**
         * Get the allowed items or tabs
         *
-        * @param string $items: initial list of possible items
+        * @param string $items initial list of possible items
         * @return array the allowed items
         */
        public function getAllowedItems($items) {
@@ -1051,50 +1069,51 @@ class ElementBrowser {
         *
         * @param $wiz
         * @param $allowedItems
-        * @return array
+        * @return mixed[][]
         */
        protected function buildMenuArray($wiz, $allowedItems) {
                // Making menu in top:
                $menuDef = array();
+               $lang = $this->getLanguageService();
                if (!$wiz) {
                        $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="self.parent.parent.renderPopup_unLink();return false;"';
                }
                if (in_array('page', $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') . ');return false;"';
                }
                if (in_array('file', $allowedItems)) {
                        $menuDef['file']['isActive'] = $this->act === 'file';
-                       $menuDef['file']['label'] = $GLOBALS['LANG']->getLL('file', TRUE);
+                       $menuDef['file']['label'] = $lang->getLL('file', TRUE);
                        $menuDef['file']['url'] = '#';
                        $menuDef['file']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=file') . ');return false;"';
                }
                if (in_array('folder', $allowedItems)) {
                        $menuDef['folder']['isActive'] = $this->act === 'folder';
-                       $menuDef['folder']['label'] = $GLOBALS['LANG']->getLL('folder', TRUE);
+                       $menuDef['folder']['label'] = $lang->getLL('folder', TRUE);
                        $menuDef['folder']['url'] = '#';
                        $menuDef['folder']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=folder') . ');return false;"';
                }
                if (in_array('url', $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') . ');return false;"';
                }
                if (in_array('mail', $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') . ');return false;"';
                }
                if (is_array($this->thisConfig['userLinks.']) && in_array('spec', $allowedItems)) {
                        $menuDef['spec']['isActive'] = $this->act === 'spec';
-                       $menuDef['spec']['label'] = $GLOBALS['LANG']->getLL('special', TRUE);
+                       $menuDef['spec']['label'] = $lang->getLL('special', TRUE);
                        $menuDef['spec']['url'] = '#';
                        $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=spec') . ');return false;"';
                }
@@ -1111,6 +1130,7 @@ class ElementBrowser {
         * @return string
         */
        protected function getEmailSelectorHtml() {
+               $lang = $this->getLanguageService();
                $extUrl = '
                        <!--
                                Enter mail address:
@@ -1119,13 +1139,13 @@ class ElementBrowser {
                                <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
                                        <tr>
                                                <td style="width: 96px;">
-                                                       ' . $GLOBALS['LANG']->getLL('emailAddress', TRUE) . ':
+                                                       ' . $lang->getLL('emailAddress', TRUE) . ':
                                                </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="' . $lang->getLL('setLink', TRUE)
                                                                . '" onclick="browse_links_setTarget(\'\');browse_links_setValue(\'mailto:\'+'
                                                                . 'document.lurlform.lemail.value); return link_current();" />
                                                </td>
@@ -1152,7 +1172,7 @@ class ElementBrowser {
                                                                        <td style="width: 96px;">URL:</td>
                                                                        <td><input type="text" name="lurl"' . $this->doc->formWidth(30) . ' 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="browse_links_setValue(document.lurlform.lurl.value); return link_current();" /></td>
                                                                </tr>
                                                        </table>
@@ -1170,6 +1190,7 @@ class ElementBrowser {
                $folderTree = GeneralUtility::makeInstance($treeClassName);
                $folderTree->thisScript = $this->thisScript;
                $tree = $folderTree->getBrowsableTree();
+               $backendUser = $this->getBackendUserAuthentication();
                if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act'] != $this->act) {
                        $cmpPath = '';
                } else {
@@ -1183,7 +1204,7 @@ class ElementBrowser {
                if ($this->expandFolder) {
                        $fileOrFolderObject = NULL;
                        try {
-                               $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
+                               $fileOrFolderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
                        } catch (\Exception $e) {
                                // No path is selected
                        }
@@ -1191,7 +1212,7 @@ class ElementBrowser {
                        if ($fileOrFolderObject instanceof Folder) {
                                // It's a folder
                                $selectedFolder = $fileOrFolderObject;
-                       } elseif ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
+                       } elseif ($fileOrFolderObject instanceof FileInterface) {
                                // It's a file
                                try {
                                        $selectedFolder = $fileOrFolderObject->getParentFolder();
@@ -1203,7 +1224,7 @@ class ElementBrowser {
                // If no folder is selected, get the user's default upload folder
                if (!$selectedFolder) {
                        try {
-                               $selectedFolder = $GLOBALS['BE_USER']->getDefaultUploadFolder();
+                               $selectedFolder = $backendUser->getDefaultUploadFolder();
                        } catch (\Exception $e) {
                                // The configured default user folder does not exist
                        }
@@ -1217,7 +1238,7 @@ class 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')) {
                        $content .= $uploadForm;
                }
 
@@ -1238,13 +1259,13 @@ class 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>
+                       . $this->barheader(($this->getLanguageService()->getLL('folderTree') . ':')) . $tree . '</td>
                                                                <td class="c-wCell" valign="top">' . $files . '</td>
                                                        </tr>
                                                </table>
                                                ';
                // Adding create folder + upload form if applicable
-               if (!$GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
+               if (!$backendUser->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
                        $content .= $uploadForm;
                }
                $content .=  '<br />' . $createFolder . '<br />';
@@ -1260,6 +1281,7 @@ class ElementBrowser {
                if (!is_array($this->thisConfig['userLinks.'])) {
                        return '';
                }
+               $lang = $this->getLanguageService();
                $subcats = array();
                $v = $this->thisConfig['userLinks.'];
                foreach ($v as $k2 => $value) {
@@ -1270,11 +1292,11 @@ class ElementBrowser {
                                if (!$title) {
                                        $title = $v[$k2i . '.']['url'];
                                } else {
-                                       $title = $GLOBALS['LANG']->sL($title);
+                                       $title = $lang->sL($title);
                                }
                                // Description:
                                $description = $v[$k2i . '.']['description']
-                                       ? $GLOBALS['LANG']->sL($v[($k2i . '.')]['description'], TRUE) . '<br />'
+                                       ? $lang->sL($v[($k2i . '.')]['description'], TRUE) . '<br />'
                                        : '';
                                // URL + onclick event:
                                $onClickEvent = '';
@@ -1315,7 +1337,7 @@ class ElementBrowser {
                                                <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
                                                        <tr>
                                                                <td class="bgColor5" class="c-wCell" valign="top"><strong>'
-                       . $GLOBALS['LANG']->getLL('special', TRUE) . '</strong></td>
+                       . $lang->getLL('special', TRUE) . '</strong></td>
                                                        </tr>
                                                        ' . implode('', $subcats) . '
                                                </table>
@@ -1330,10 +1352,11 @@ class ElementBrowser {
         * @return string
         */
        protected function getPageSelectorHtml($treeClassName = \TYPO3\CMS\Backend\Tree\View\ElementBrowserPageTreeView::class) {
+               $backendUser = $this->getBackendUserAuthentication();
                $pageTree = GeneralUtility::makeInstance($treeClassName);
                $pageTree->thisScript = $this->thisScript;
-               $pageTree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
-               $pageTree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
+               $pageTree->ext_showPageId = $backendUser->getTSConfigVal('options.pageTree.showPageIdWithTitle');
+               $pageTree->ext_showNavTitle = $backendUser->getTSConfigVal('options.pageTree.showNavTitle');
                $pageTree->addField('nav_title');
                $tree = $pageTree->getBrowsableTree();
                $cElements = $this->expandPage();
@@ -1346,7 +1369,7 @@ class ElementBrowser {
                                                <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
                                                        <tr>
                                                                <td class="c-wCell" valign="top">'
-                       . $this->barheader(($GLOBALS['LANG']->getLL('pageTree') . ':'))
+                       . $this->barheader(($this->getLanguageService()->getLL('pageTree') . ':'))
                        . $dbmount
                        . $tree . '</td>
                                                                <td class="c-wCell" valign="top">' . $cElements . '</td>
@@ -1367,14 +1390,15 @@ class ElementBrowser {
                // Init variable:
                $pArr = explode('|', $this->bparams);
                $tables = $pArr[3];
+               $backendUser = $this->getBackendUserAuthentication();
 
                // Making the browsable pagetree:
                /** @var \TYPO3\CMS\Recordlist\Tree\View\ElementBrowserPageTreeView $pageTree */
                $pageTree = GeneralUtility::makeInstance(\TYPO3\CMS\Recordlist\Tree\View\ElementBrowserPageTreeView::class);
                $pageTree->thisScript = $this->thisScript;
                $pageTree->ext_pArrPages = $tables === 'pages' ? 1 : 0;
-               $pageTree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
-               $pageTree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
+               $pageTree->ext_showNavTitle = $backendUser->getTSConfigVal('options.pageTree.showNavTitle');
+               $pageTree->ext_showPageId = $backendUser->getTSConfigVal('options.pageTree.showPageIdWithTitle');
                $pageTree->addField('nav_title');
 
                $withTree = TRUE;
@@ -1409,7 +1433,7 @@ class ElementBrowser {
                                <tr>';
                if ($withTree) {
                        $content .= '<td class="c-wCell" valign="top">'
-                               . $this->barheader(($GLOBALS['LANG']->getLL('pageTree') . ':'))
+                               . $this->barheader(($this->getLanguageService()->getLL('pageTree') . ':'))
                                . $this->getTemporaryTreeMountCancelNotice()
                                . $tree . '</td>';
                }
@@ -1443,13 +1467,14 @@ class ElementBrowser {
                if ($allowed !== 'sys_file' && $allowed !== '*' && !empty($allowed)) {
                        $allowedFileExtensions = $allowed;
                }
+               $backendUser = $this->getBackendUserAuthentication();
 
                if (isset($allowedFileExtensions)) {
                        // Create new filter object
-                       $filterObject = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter::class);
+                       $filterObject = GeneralUtility::makeInstance(FileExtensionFilter::class);
                        $filterObject->setAllowedFileExtensions($allowedFileExtensions);
                        // Set file extension filters on all storages
-                       $storages = $GLOBALS['BE_USER']->getFileStorages();
+                       $storages = $backendUser->getFileStorages();
                        /** @var $storage \TYPO3\CMS\Core\Resource\ResourceStorage */
                        foreach ($storages as $storage) {
                                $storage->addFileAndFolderNameFilter(array($filterObject, 'filterFileList'));
@@ -1463,15 +1488,15 @@ class ElementBrowser {
                        // Try to fetch the folder the user had open the last time he browsed files
                        // Fallback to the default folder in case the last used folder is not existing
                        try {
-                               $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
-                       } catch (\TYPO3\CMS\Core\Resource\Exception $accessException) {
+                               $fileOrFolderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
+                       } catch (Exception $accessException) {
                                // We're just catching the exception here, nothing to be done if folder does not exist or is not accessible.
                        }
 
-                       if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
+                       if ($fileOrFolderObject instanceof Folder) {
                                // It's a folder
                                $this->selectedFolder = $fileOrFolderObject;
-                       } elseif ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
+                       } elseif ($fileOrFolderObject instanceof FileInterface) {
                                // It's a file
                                $this->selectedFolder = $fileOrFolderObject->getParentFolder();
                        }
@@ -1479,7 +1504,7 @@ class ElementBrowser {
                // Or get the user's default upload folder
                if (!$this->selectedFolder) {
                        try {
-                               $this->selectedFolder = $GLOBALS['BE_USER']->getDefaultUploadFolder();
+                               $this->selectedFolder = $backendUser->getDefaultUploadFolder();
                        } catch (\Exception $e) {
                                // The configured default user folder does not exist
                        }
@@ -1492,11 +1517,11 @@ class ElementBrowser {
                        $createFolder = $this->createFolder($this->selectedFolder);
                }
                // Insert the upload form on top, if so configured
-               if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
+               if ($backendUser->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
                        $content .= $uploadForm;
                }
                // Getting flag for showing/not showing thumbnails:
-               $noThumbs = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
+               $noThumbs = $backendUser->getTSConfigVal('options.noThumbsInEB');
                $_MOD_SETTINGS = array();
                if (!$noThumbs) {
                        // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
@@ -1511,7 +1536,6 @@ class ElementBrowser {
                $folderTree->thisScript = $this->thisScript;
                $folderTree->ext_noTempRecyclerDirs = $this->mode == 'filedrag';
                $tree = $folderTree->getBrowsableTree();
-               list(, , $specUid) = explode('_', $this->PM);
                if ($this->selectedFolder) {
                        if ($this->mode == 'filedrag') {
                                $files = $this->TBE_dragNDrop($this->selectedFolder, $pArr[3]);
@@ -1532,14 +1556,14 @@ class ElementBrowser {
                        -->
                        <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
                                <tr>
-                                       <td class="c-wCell" valign="top">' . $this->barheader(($GLOBALS['LANG']->getLL('folderTree') . ':'))
+                                       <td class="c-wCell" valign="top">' . $this->barheader(($this->getLanguageService()->getLL('folderTree') . ':'))
                                                . $tree . '</td>
                                        <td class="c-wCell" valign="top">' . $files . '</td>
                                </tr>
                        </table>
                        ';
                // Adding create folder + upload forms if applicable:
-               if (!$GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
+               if (!$backendUser->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
                        $content .= $uploadForm;
                }
                $content .= $createFolder;
@@ -1570,7 +1594,7 @@ class ElementBrowser {
                // Init variable:
                $parameters = explode('|', $this->bparams);
                if ($this->expandFolder) {
-                       $this->selectedFolder = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder);
+                       $this->selectedFolder = ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder);
                }
                if ($this->selectedFolder) {
                        $createFolder = $this->createFolder($this->selectedFolder);
@@ -1583,7 +1607,7 @@ class ElementBrowser {
                $folderTree->thisScript = $this->thisScript;
                $folderTree->ext_noTempRecyclerDirs = $this->mode == 'filedrag';
                $tree = $folderTree->getBrowsableTree(FALSE);
-               list(, , $specUid) = explode('_', $this->PM);
+               $folders = '';
                if ($this->selectedFolder) {
                        if ($this->mode == 'filedrag') {
                                $folders = $this->TBE_dragNDrop($this->selectedFolder, $parameters[3]);
@@ -1599,7 +1623,7 @@ class ElementBrowser {
                        -->
                        <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
                                <tr>
-                                       <td class="c-wCell" valign="top">' . $this->barheader(($GLOBALS['LANG']->getLL('folderTree') . ':'))
+                                       <td class="c-wCell" valign="top">' . $this->barheader(($this->getLanguageService()->getLL('folderTree') . ':'))
                                                . $tree . '</td>
                                        <td class="c-wCell" valign="top">' . $folders . '</td>
                                </tr>
@@ -1636,18 +1660,19 @@ class ElementBrowser {
                }
                // Draw the record list IF there is a page id to expand:
                if ($expPageId
-                       && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($expPageId)
-                       && $GLOBALS['BE_USER']->isInWebMount($expPageId)
+                       && MathUtility::canBeInterpretedAsInteger($expPageId)
+                       && $this->getBackendUserAuthentication()->isInWebMount($expPageId)
                ) {
                        // Set header:
-                       $out .= $this->barheader($GLOBALS['LANG']->getLL('contentElements') . ':');
+                       $out .= $this->barheader($this->getLanguageService()->getLL('contentElements') . ':');
                        // Create header for listing, showing the page title/icon:
                        $mainPageRec = BackendUtility::getRecordWSOL('pages', $expPageId);
+                       $db = $this->getDatabaseConnection();
                        $picon = IconUtility::getSpriteIconForRecord('pages', $mainPageRec);
                        $picon .= BackendUtility::getRecordTitle('pages', $mainPageRec, TRUE);
                        $out .= $picon . '<br />';
                        // Look up tt_content elements from the expanded page:
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
+                       $res = $db->exec_SELECTquery(
                                'uid,header,hidden,starttime,endtime,fe_group,CType,colPos,bodytext',
                                'tt_content',
                                'pid=' . (int)$expPageId . BackendUtility::deleteClause('tt_content')
@@ -1655,10 +1680,10 @@ class ElementBrowser {
                                '',
                                'colPos,sorting'
                        );
-                       $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
+                       $cc = $db->sql_num_rows($res);
                        // Traverse list of records:
                        $c = 0;
-                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+                       while ($row = $db->sql_fetch_assoc($res)) {
                                $c++;
                                $icon = IconUtility::getSpriteIconForRecord('tt_content', $row);
                                if ($this->curUrlInfo['act'] == 'page' && $this->curUrlInfo['cElement'] == $row['uid']) {
@@ -1701,9 +1726,10 @@ class ElementBrowser {
         * @return string HTML output.
         */
        public function TBE_expandPage($tables) {
-               if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->expandPage)
+               $backendUser = $this->getBackendUserAuthentication();
+               if (!MathUtility::canBeInterpretedAsInteger($this->expandPage)
                        || $this->expandPage < 0
-                       || !$GLOBALS['BE_USER']->isInWebMount($this->expandPage)
+                       || !$backendUser->isInWebMount($this->expandPage)
                ) {
                        return '';
                }
@@ -1715,10 +1741,10 @@ class ElementBrowser {
                }
                reset($tablesArr);
                // Headline for selecting records:
-               $out = $this->barheader($GLOBALS['LANG']->getLL('selectRecords') . ':');
+               $out = $this->barheader($this->getLanguageService()->getLL('selectRecords') . ':');
                // Create the header, showing the current page for which the listing is.
                // Includes link to the page itself, if pages are amount allowed tables.
-               $titleLen = (int)$GLOBALS['BE_USER']->uc['titleLen'];
+               $titleLen = (int)$backendUser->uc['titleLen'];
                $mainPageRec = BackendUtility::getRecordWSOL('pages', $this->expandPage);
                $ATag = '';
                $ATag_e = '';
@@ -1741,20 +1767,20 @@ class ElementBrowser {
                $out .= $picon . $ATag2 . $pBicon . $ATag_e . $ATag . $pText . $ATag_e . '<br />';
                // Initialize the record listing:
                $id = $this->expandPage;
-               $pointer = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->pointer, 0, 100000);
-               $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
+               $pointer = MathUtility::forceIntegerInRange($this->pointer, 0, 100000);
+               $perms_clause = $backendUser->getPagePermsClause(1);
                $pageInfo = BackendUtility::readPageAccess($id, $perms_clause);
                // Generate the record list:
-               /** @var $dbList \TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList */
+               /** @var $dbList ElementBrowserRecordList */
                if (is_object($this->recordList)) {
                        $dbList = $this->recordList;
                } else {
-                       $dbList = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList::class);
+                       $dbList = GeneralUtility::makeInstance(ElementBrowserRecordList::class);
                }
                $dbList->thisScript = $this->thisScript;
                $dbList->backPath = $GLOBALS['BACK_PATH'];
                $dbList->thumbs = 0;
-               $dbList->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageInfo);
+               $dbList->calcPerms = $backendUser->calcPerms($pageInfo);
                $dbList->noControlPanels = 1;
                $dbList->clickMenuEnabled = 0;
                $dbList->tableList = implode(',', $tablesArr);
@@ -1818,12 +1844,13 @@ class ElementBrowser {
                if (!$folder->checkActionPermission('read')) {
                        return '';
                }
+               $lang = $this->getLanguageService();
                $renderFolders = $this->act === 'folder';
                // Create header for file/folder listing:
                if ($renderFolders) {
-                       $out = $this->barheader($GLOBALS['LANG']->getLL('folders') . ':');
+                       $out = $this->barheader($lang->getLL('folders') . ':');
                } else {
-                       $out = $this->barheader($GLOBALS['LANG']->getLL('files') . ':');
+                       $out = $this->barheader($lang->getLL('files') . ':');
                }
                // Prepare current path value for comparison (showing red arrow)
                $currentIdentifier = '';
@@ -1831,7 +1858,7 @@ class ElementBrowser {
                        $currentIdentifier = $this->curUrlInfo['info'];
                }
                // Create header element; The folder from which files are listed.
-               $titleLen = (int)$GLOBALS['BE_USER']->uc['titleLen'];
+               $titleLen = (int)$this->getBackendUserAuthentication()->uc['titleLen'];
                $folderIcon = IconUtility::getSpriteIconForResource($folder);
                $folderIcon .= htmlspecialchars(GeneralUtility::fixed_lgd_cs($folder->getIdentifier(), $titleLen));
                $picon = '<a href="#" title="' . htmlspecialchars($folder->getIdentifier()) . '" onclick="return link_folder(\'file:' . $folder->getCombinedIdentifier() . '\');">'
@@ -1855,7 +1882,7 @@ class ElementBrowser {
                        if ($renderFolders) {
                                $fileIdentifier = $fileOrFolderObject->getCombinedIdentifier();
                                $overlays = array();
-                               if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\InaccessibleFolder) {
+                               if ($fileOrFolderObject instanceof InaccessibleFolder) {
                                        $overlays = array('status-overlay-locked' => array());
                                }
                                $icon = IconUtility::getSpriteIcon(
@@ -1865,8 +1892,6 @@ class ElementBrowser {
                                $itemUid = 'file:' . $fileIdentifier;
                        } else {
                                $fileIdentifier = $fileOrFolderObject->getUid();
-                               // File icon:
-                               $fileExtension = $fileOrFolderObject->getExtension();
                                // Get size and icon:
                                $size = ' (' . GeneralUtility::formatSize($fileOrFolderObject->getSize()) . 'bytes)';
                                $icon = IconUtility::getSpriteIconForResource($fileOrFolderObject, array('title' => $fileOrFolderObject->getName() . $size));
@@ -1925,13 +1950,14 @@ class ElementBrowser {
        protected function fileList(array $files, Folder $folder = NULL, $noThumbs = FALSE) {
                $out = '';
 
+               $lang = $this->getLanguageService();
                $lines = array();
                // Create headline (showing number of files):
                $filesCount = count($files);
-               $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files') . ' (%s):', $filesCount));
+               $out .= $this->barheader(sprintf($lang->getLL('files') . ' (%s):', $filesCount));
                $out .= '<div id="filelist">';
                $out .= $this->getBulkSelector($filesCount);
-               $titleLen = (int)$GLOBALS['BE_USER']->uc['titleLen'];
+               $titleLen = (int)$this->getBackendUserAuthentication()->uc['titleLen'];
                // Create the header of current folder:
                if ($folder) {
                        $folderIcon = IconUtility::getSpriteIconForResource($folder);
@@ -1954,7 +1980,7 @@ class ElementBrowser {
                        $imgInfo = array();
                        if (GeneralUtility::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']), strtolower($fileExtension)) && !$noThumbs) {
                                $imageUrl = $fileObject->process(
-                                       \TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW,
+                                       ProcessedFile::CONTEXT_IMAGEPREVIEW,
                                        array('width' => 64, 'height' => 64)
                                )->getPublicUrl(TRUE);
                                $imgInfo = array(
@@ -2008,12 +2034,12 @@ class ElementBrowser {
                                        <tr class="file_list_normal">
                                                <td nowrap="nowrap">' . $filenameAndIcon . '&nbsp;</td>
                                                <td>' . ($ATag . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif',
-                                                       'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList', TRUE)
+                                                       'width="18" height="16"') . ' title="' . $lang->getLL('addToList', TRUE)
                                                        . '" alt="" />' . $ATag_e) . '</td>
                                                <td nowrap="nowrap">' . ($ATag2 . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'],
                                                        'gfx/zoom2.gif', 'width="12" height="12"') . ' title="'
-                                                       . $GLOBALS['LANG']->getLL('info', TRUE) . '" alt="" /> '
-                                                       . $GLOBALS['LANG']->getLL('info', TRUE) . $ATag2_e) . '</td>
+                                                       . $lang->getLL('info', TRUE) . '" alt="" /> '
+                                                       . $lang->getLL('info', TRUE) . $ATag2_e) . '</td>
                                                <td nowrap="nowrap">&nbsp;' . $pDim . '</td>
                                        </tr>';
                                $lines[] = '
@@ -2025,12 +2051,12 @@ class ElementBrowser {
                                        <tr class="file_list_normal">
                                                <td nowrap="nowrap">' . $filenameAndIcon . '&nbsp;</td>
                                                <td>' . ($ATag . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif',
-                                                       'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList', TRUE)
+                                                       'width="18" height="16"') . ' title="' . $lang->getLL('addToList', TRUE)
                                                        . '" alt="" />' . $ATag_e) . '</td>
                                                <td nowrap="nowrap">' . ($ATag2 . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'],
                                                        'gfx/zoom2.gif', 'width="12" height="12"') . ' title="'
-                                                       . $GLOBALS['LANG']->getLL('info', TRUE) . '" alt="" /> '
-                                               . $GLOBALS['LANG']->getLL('info', TRUE) . $ATag2_e) . '</td>
+                                                       . $lang->getLL('info', TRUE) . '" alt="" /> '
+                                               . $lang->getLL('info', TRUE) . $ATag2_e) . '</td>
                                                <td>&nbsp;</td>
                                        </tr>';
                        }
@@ -2054,11 +2080,11 @@ class ElementBrowser {
         *
         * By default all files are selectable. This method may be overwritten in child classes.
         *
-        * @param \TYPO3\CMS\Core\Resource\FileInterface $file
-        * @param array $imgInfo Image dimensions from \TYPO3\CMS\Core\Imaging\GraphicalFunctions::getImageDimensions()
+        * @param FileInterface $file
+        * @param mixed[] $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(FileInterface $file, array $imgInfo) {
                return TRUE;
        }
 
@@ -2070,11 +2096,12 @@ class ElementBrowser {
         */
        public function folderList(Folder $baseFolder) {
                $content = '';
+               $lang = $this->getLanguageService();
                $folders = $baseFolder->getSubfolders();
                $folderIdentifier = $baseFolder->getCombinedIdentifier();
                // Create headline (showing number of folders):
-               $content .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('folders') . ' (%s):', count($folders)));
-               $titleLength = (int)$GLOBALS['BE_USER']->uc['titleLen'];
+               $content .= $this->barheader(sprintf($lang->getLL('folders') . ' (%s):', count($folders)));
+               $titleLength = (int)$this->getBackendUserAuthentication()->uc['titleLen'];
                // Create the header of current folder:
                $aTag = '<a href="#" onclick="return insertElement(\'\',' . GeneralUtility::quoteJSvalue($folderIdentifier)
                        . ', \'folder\', ' . GeneralUtility::quoteJSvalue($folderIdentifier) . ', ' . GeneralUtility::quoteJSvalue($folderIdentifier)
@@ -2107,7 +2134,7 @@ class ElementBrowser {
                        }
                        if (strstr($subFolderIdentifier, ',') || strstr($subFolderIdentifier, '|')) {
                                // In case an invalid character is in the filepath, display error message:
-                               $errorMessage = GeneralUtility::quoteJSvalue(sprintf($GLOBALS['LANG']->getLL('invalidChar'), ', |'));
+                               $errorMessage = GeneralUtility::quoteJSvalue(sprintf($lang->getLL('invalidChar'), ', |'));
                                $aTag = ($aTag_alt = '<a href="#" onclick="alert(' . $errorMessage . ');return false;">');
                        } else {
                                // If foldername is OK, just add it:
@@ -2128,7 +2155,7 @@ class ElementBrowser {
                                        <tr class="bgColor4">
                                                <td nowrap="nowrap">' . $foldernameAndIcon . '&nbsp;</td>
                                                <td>' . $aTag . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif',
-                                               'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList', TRUE)
+                                               'width="18" height="16"') . ' title="' . $lang->getLL('addToList', TRUE)
                                        . '" alt="" />' . $aTag_e . ' </td>
                                                <td>&nbsp;</td>
                                        </tr>';
@@ -2163,10 +2190,11 @@ class ElementBrowser {
                if (!$folder) {
                        return '';
                }
+               $lang = $this->getLanguageService();
                if (!$folder->getStorage()->isPublic()) {
                        // Print this warning if the folder is NOT a web folder
-                       return $this->barheader($GLOBALS['LANG']->getLL('files'))
-                               . $this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'), 'icon_warning2');
+                       return $this->barheader($lang->getLL('files'))
+                               . $this->getMsgBox($lang->getLL('noWebFolder'), 'icon_warning2');
                }
                $out = '';
 
@@ -2174,8 +2202,8 @@ class ElementBrowser {
                $extensionList = $extensionList == '*' ? '' : $extensionList;
                $files = $this->getFilesInFolder($folder, $extensionList);
 
-               $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files') . ' (%s):', count($files)));
-               $titleLen = (int)$GLOBALS['BE_USER']->uc['titleLen'];
+               $out .= $this->barheader(sprintf($lang->getLL('files') . ' (%s):', count($files)));
+               $titleLen = (int)$this->getBackendUserAuthentication()->uc['titleLen'];
                $picon = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />';
                $picon .= htmlspecialchars(GeneralUtility::fixed_lgd_cs(basename($folder->getName()), $titleLen));
                $out .= $picon . '<br />';
@@ -2184,11 +2212,10 @@ class ElementBrowser {
                // Add "drag-n-drop" message:
                $lines[] = '
                        <tr>
-                               <td colspan="2">' . $this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')) . '</td>
+                               <td colspan="2">' . $this->getMsgBox($lang->getLL('findDragDrop')) . '</td>
                        </tr>';
                // Traverse files:
                foreach ($files as $fileObject) {
-                       $fileInfo = $fileObject->getStorage()->getFileInfo($fileObject);
                        // URL of image:
                        $iUrl = GeneralUtility::rawurlencodeFP($fileObject->getPublicUrl(TRUE));
                        // Show only web-images
@@ -2226,7 +2253,7 @@ class ElementBrowser {
                                                ? '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('noLimit' => '1')))
                                                . '">' . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/icon_warning2.gif',
                                                        'width="18" height="16"') . ' title="'
-                                               . $GLOBALS['LANG']->getLL('clickToRedrawFullSize', TRUE) . '" alt="" />' . '</a>'
+                                               . $lang->getLL('clickToRedrawFullSize', TRUE) . '" alt="" />' . '</a>'
                                                : '')
                                        . $pDim . '&nbsp;</td>
                                        </tr>';
@@ -2306,12 +2333,12 @@ class ElementBrowser {
         */
        public function printCurrentUrl($str) {
                // Output the folder or file identifier, when working with files
-               if (isset($str) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($str)
+               if (isset($str) && MathUtility::canBeInterpretedAsInteger($str)
                        && ($this->act === 'file' || $this->act === 'folder')
                ) {
                        try {
-                               $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($str);
-                       } catch (\TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException $e) {
+                               $fileObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($str);
+                       } catch (Exception\FileDoesNotExistException $e) {
                                $fileObject = NULL;
                        }
                        $str = is_object($fileObject) ? $fileObject->getIdentifier() : '';
@@ -2321,7 +2348,7 @@ class ElementBrowser {
                                <!-- Print current URL -->
                                <table border="0" cellpadding="0" cellspacing="0" id="typo3-curUrl">
                                        <tr>
-                                               <td>' . $GLOBALS['LANG']->getLL('currentLink', TRUE) . ': '
+                                               <td>' . $this->getLanguageService()->getLL('currentLink', TRUE) . ': '
                                                        . htmlspecialchars(rawurldecode($str)) . '</td>
                                        </tr>
                                </table>';
@@ -2335,10 +2362,11 @@ class ElementBrowser {
         *
         * @param string $href HREF value tp analyse
         * @param string $siteUrl The URL of the current website (frontend)
-        * @return array Array with URL information stored in assoc. keys: value, act (page, file, spec, mail), pageid, cElement, info
+        * @return array[] Array with URL information stored in assoc. keys: value, act (page, file, spec, mail), pageid, cElement, info
         */
        public function parseCurUrl($href, $siteUrl) {
                $href = trim($href);
+               $lang = $this->getLanguageService();
                if ($href) {
                        $info = array();
                        // Default is "url":
@@ -2353,7 +2381,7 @@ class ElementBrowser {
                                $rel = substr($href, strpos($href, 'file:') + 5);
                                $rel = rawurldecode($rel);
                                // resolve FAL-api "file:UID-of-sys_file-record" and "file:combined-identifier"
-                               $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($rel);
+                               $fileOrFolderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($rel);
                                if ($fileOrFolderObject instanceof Folder) {
                                        $info['act'] = 'folder';
                                        $info['value'] = $fileOrFolderObject->getCombinedIdentifier();
@@ -2383,13 +2411,13 @@ class ElementBrowser {
                                        $id = array_shift($parameters);
                                        if ($id) {
                                                // Checking if the id-parameter is an alias.
-                                               if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) {
+                                               if (!MathUtility::canBeInterpretedAsInteger($id)) {
                                                        list($idPartR) = BackendUtility::getRecordsByField('pages', 'alias', $id);
                                                        $id = (int)$idPartR['uid'];
                                                }
                                                $pageRow = BackendUtility::getRecordWSOL('pages', $id);
-                                               $titleLen = (int)$GLOBALS['BE_USER']->uc['titleLen'];
-                                               $info['value'] = ((((($GLOBALS['LANG']->getLL('page', TRUE) . ' \'')
+                                               $titleLen = (int)$this->getBackendUserAuthentication()->uc['titleLen'];
+                                               $info['value'] = ((((($lang->getLL('page', TRUE) . ' \'')
                                                                                . htmlspecialchars(GeneralUtility::fixed_lgd_cs($pageRow['title'], $titleLen)))
                                                                                . '\' (ID:') . $id) . ($uP['fragment'] ? ', #' . $uP['fragment'] : '')) . ')';
                                                $info['pageid'] = $id;
@@ -2400,7 +2428,7 @@ class ElementBrowser {
                                }
                        } else {
                                // Email link:
-                               if (strtolower(substr($href, 0, 7)) == 'mailto:') {
+                               if (strtolower(substr($href, 0, 7)) === 'mailto:') {
                                        $info['value'] = trim(substr($href, 7));
                                        $info['act'] = 'mail';
                                }
@@ -2409,7 +2437,7 @@ class ElementBrowser {
                } else {
                        // NO value input:
                        $info = array();
-                       $info['info'] = $GLOBALS['LANG']->getLL('none');
+                       $info['info'] = $lang->getLL('none');
                        $info['value'] = '';
                        $info['act'] = 'page';
                }
@@ -2424,14 +2452,14 @@ class ElementBrowser {
         * Setter for the class that should be used by TBE_expandPage() to generate the record list.
         * This method is intended to be used by Extensions that implement their own browsing functionality.
         *
-        * @param \TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList $recordList
+        * @param ElementBrowserRecordList $recordList
         * @throws \InvalidArgumentException
         * @return void
         * @api
         */
        public function setRecordList($recordList) {
-               if (!$recordList instanceof \TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList) {
-                       throw new \InvalidArgumentException('$recordList needs to be an instance of \\TYPO3\\CMS\\Backend\\RecordList\\ElementBrowserRecordList', 1370878522);
+               if (!$recordList instanceof ElementBrowserRecordList) {
+                       throw new \InvalidArgumentException('$recordList needs to be an instance of ' . ElementBrowserRecordList::class, 1370878522);
                }
                $this->recordList = $recordList;
        }
@@ -2448,7 +2476,7 @@ class ElementBrowser {
                        return '';
                }
                // Read configuration of upload field count
-               $userSetting = $GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.uploadFieldsInLinkBrowser');
+               $userSetting = $this->getBackendUserAuthentication()->getTSConfigVal('options.folderTree.uploadFieldsInLinkBrowser');
                $count = isset($userSetting) ? $userSetting : 1;
                if ($count === '0') {
                        return '';
@@ -2456,6 +2484,7 @@ class ElementBrowser {
                $count = (int)$count === 0 ? 1 : (int)$count;
                // Create header, showing upload path:
                $header = $folderObject->getIdentifier();
+               $lang = $this->getLanguageService();
                $code = '
                        <br />
                        <!--
@@ -2465,11 +2494,11 @@ class ElementBrowser {
                        . ' id="typo3-uplFilesForm" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '">
                                <table border="0" cellpadding="0" cellspacing="0" id="typo3-uplFiles">
                                        <tr>
-                                               <td>' . $this->barheader($GLOBALS['LANG']->sL(
+                                               <td>' . $this->barheader($lang->sL(
                                                                'LLL:EXT:lang/locallang_core.xlf:file_upload.php.pagetitle', TRUE) . ':') . '</td>
                                        </tr>
                                        <tr>
-                                               <td class="c-wCell c-hCell"><strong>' . $GLOBALS['LANG']->getLL('path', TRUE) . ':</strong> '
+                                               <td class="c-wCell c-hCell"><strong>' . $lang->getLL('path', TRUE) . ':</strong> '
                                                        . htmlspecialchars($header) . '</td>
                                        </tr>
                                        <tr>
@@ -2487,16 +2516,16 @@ class ElementBrowser {
                        . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier())
                        . '&bparams=' . rawurlencode($this->bparams);
                $code .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($redirectValue) . '" />';
-               $code .= \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction');
+               $code .= FormEngine::getHiddenTokenField('tceAction');
                $code .= '
                        <div id="c-override">
                                <label>
                                        <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> '
-                                       . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xlf:overwriteExistingFiles', TRUE) . '
+                                       . $lang->sL('LLL:EXT:lang/locallang_misc.xlf:overwriteExistingFiles', TRUE) . '
                                </label>
                        </div>
                        <input class="btn btn-default" type="submit" name="submit" value="'
-                               . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_upload.php.submit', TRUE) . '" />
+                               . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_upload.php.submit', TRUE) . '" />
                ';
                $code .= '</td>
                                        </tr>
@@ -2516,13 +2545,15 @@ class ElementBrowser {
                if (!$folderObject->checkActionPermission('write')) {
                        return '';
                }
-               if (!($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB'))) {
+               $backendUser = $this->getBackendUserAuthentication();
+               if (!($backendUser->isAdmin() || $backendUser->getTSConfigVal('options.createFoldersInEB'))) {
                        return '';
                }
                // Don't show Folder-create form if it's denied
-               if ($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.hideCreateFolder')) {
+               if ($backendUser->getTSConfigVal('options.folderTree.hideCreateFolder')) {
                        return '';
                }
+               $lang = $this->getLanguageService();
                // Create header, showing upload path:
                $header = $folderObject->getIdentifier();
                $code = '
@@ -2533,12 +2564,12 @@ class ElementBrowser {
                        <form action="' . $GLOBALS['BACK_PATH'] . 'tce_file.php" method="post" name="editform2" id="typo3-crFolderForm">
                                <table border="0" cellpadding="0" cellspacing="0" id="typo3-crFolder">
                                        <tr>
-                                               <td>' . $this->barheader($GLOBALS['LANG']->sL(
+                                               <td>' . $this->barheader($lang->sL(
                                                                'LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.pagetitle') . ':') . '</td>
                                        </tr>
                                        <tr>
                                                <td class="c-wCell c-hCell"><strong>'
-                                                       . $GLOBALS['LANG']->getLL('path', TRUE) . ':</strong> ' . htmlspecialchars($header) . '</td>
+                                                       . $lang->getLL('path', TRUE) . ':</strong> ' . htmlspecialchars($header) . '</td>
                                        </tr>
                                        <tr>
                                                <td class="c-wCell c-hCell">';
@@ -2552,9 +2583,9 @@ class ElementBrowser {
                        . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier())
                        . '&bparams=' . rawurlencode($this->bparams);
                $code .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($redirectValue) . '" />'
-                       . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction')
+                       . FormEngine::getHiddenTokenField('tceAction')
                        . '<input class="btn btn-default" type="submit" name="submit" value="'
-                       . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.submit', TRUE) . '" />';
+                       . $lang->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.submit', TRUE) . '" />';
                $code .= '</td>
                                        </tr>
                                </table>
@@ -2573,17 +2604,17 @@ class ElementBrowser {
                        return '';
                }
 
-               $labelToggleSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.xlf:toggleSelection', TRUE);
-               $labelImportSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.xlf:importSelection', TRUE);
+               $lang = $this->getLanguageService();
+               $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 = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
+               $noThumbsInEB = $this->getBackendUserAuthentication()->getTSConfigVal('options.noThumbsInEB');
                $out = $this->doc->spacer(10) . '<div>' . '<a href="#" onclick="BrowseLinks.Selector.handle()">'
                        . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/import.gif', 'width="12" height="12"')
                        . ' title="' . $labelImportSelection . '" alt="" /> ' . $labelImportSelection . '</a>&nbsp;&nbsp;&nbsp;'
                        . '<a href="#" onclick="BrowseLinks.Selector.toggle()">' . '<img'
                        . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/clip_select.gif', 'width="12" height="12"')
                        . ' title="' . $labelToggleSelection . '" alt="" /> ' . $labelToggleSelection . '</a>' . '</div>';
-               $thumbNailCheck = '';
                if (!$noThumbsInEB && $this->selectedFolder) {
                        // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
                        $_MOD_MENU = array('displayThumbs' => '');
@@ -2595,7 +2626,7 @@ class ElementBrowser {
                        $thumbNailCheck = BackendUtility::getFuncCheck('', 'SET[displayThumbs]', $_MOD_SETTINGS['displayThumbs'],
                                        GeneralUtility::_GP('M') ? '' : $this->thisScript, $addParams, 'id="checkDisplayThumbs"')
                                . ' <label for="checkDisplayThumbs">'
-                               . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:displayThumbs', TRUE) . '</label>';
+                               . $lang->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:displayThumbs', TRUE) . '</label>';
                        $out .= $this->doc->spacer(5) . $thumbNailCheck . $this->doc->spacer(15);
                } else {
                        $out .= $this->doc->spacer(15);
@@ -2637,17 +2668,17 @@ class ElementBrowser {
         * @return string
         */
        protected function getTemporaryTreeMountCancelNotice() {
-               if ((int)$GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint') === 0) {
+               if ((int)$this->getBackendUserAuthentication()->getSessionData('pageTree_temporaryMountPoint') === 0) {
                        return '';
                }
                $link = '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('setTempDBmount' => 0))) . '">'
-                       . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xlf:labels.temporaryDBmount', TRUE) . '</a>';
-               /** @var \TYPO3\CMS\Core\Messaging\FlashMessage $flashMessage */
+                       . $this->getLanguageService()->sl('LLL:EXT:lang/locallang_core.xlf:labels.temporaryDBmount', TRUE) . '</a>';
+               /** @var FlashMessage $flashMessage */
                $flashMessage = GeneralUtility::makeInstance(
-                       \TYPO3\CMS\Core\Messaging\FlashMessage::class,
+                       FlashMessage::class,
                        $link,
                        '',
-                       \TYPO3\CMS\Core\Messaging\FlashMessage::INFO
+                       FlashMessage::INFO
                );
                return $flashMessage->render();
        }
@@ -2655,18 +2686,39 @@ class ElementBrowser {
        /**
         * Get a list of Files in a folder filtered by extension
         *
-        * @param \TYPO3\CMS\Core\Resource\Folder $folder
+        * @param Folder $folder
         * @param string $extensionList
         * @return \TYPO3\CMS\Core\Resource\File[]
         */
-       protected function getFilesInFolder(\TYPO3\CMS\Core\Resource\Folder $folder, $extensionList) {
+       protected function getFilesInFolder(Folder $folder, $extensionList) {
                if ($extensionList !== '') {
-                       /** @var \TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter $filter */
-                       $filter = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter::class);
+                       /** @var FileExtensionFilter $filter */
+                       $filter = GeneralUtility::makeInstance(FileExtensionFilter::class);
                        $filter->setAllowedFileExtensions($extensionList);
                        $folder->setFileAndFolderNameFilters(array(array($filter, 'filterFileList')));
                }
                return $folder->getFiles();
        }
 
-}
+       /**
+        * @return LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
+
+       /**
+        * @return BackendUserAuthentication
+        */
+       protected function getBackendUserAuthentication() {
+               return $GLOBALS['BE_USER'];
+       }
+
+       /**
+        * @return DatabaseConnection
+        */
+       protected function getDatabaseConnection() {
+               return $GLOBALS['TYPO3_DB'];
+       }
+
+}
\ No newline at end of file
index 2a973e2..79e6d9c 100644 (file)
@@ -14,6 +14,12 @@ namespace TYPO3\CMS\Recordlist\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Template\DocumentTemplate;
+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.
  *
@@ -39,24 +45,29 @@ class ElementBrowserController {
         * needed fo intercommunication between various 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 \TYPO3\CMS\Recordlist\Browser\ElementBrowser
+        * @var ElementBrowser
         */
        public $browser;
 
        /**
         * Document template object
         *
-        * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
+        * @var DocumentTemplate
         */
        public $doc;
 
        /**
+        * @var string
+        */
+       public $content = '';
+
+       /**
         * Constructor
         */
        public function __construct() {
                $GLOBALS['SOBE'] = $this;
-               $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_browse_links.xlf');
                $GLOBALS['BACK_PATH'] = '';
+               $this->getLanguageService()->includeLLFile('EXT:lang/locallang_browse_links.xlf');
 
                $this->init();
        }
@@ -68,14 +79,13 @@ class ElementBrowserController {
         */
        protected function init() {
                // Find "mode"
-               $this->mode = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('mode');
+               $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 = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
-               $this->doc->backPath = $GLOBALS['BACK_PATH'];
+               $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
                // Apply the same styles as those of the base script
                $this->doc->bodyTagId = 'typo3-browse-links-php';
 
@@ -88,25 +98,26 @@ class ElementBrowserController {
         */
        public function main() {
                // Clear temporary DB mounts
-               $tmpMount = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('setTempDBmount');
+               $tmpMount = GeneralUtility::_GET('setTempDBmount');
+               $backendUser = $this->getBackendUserAuthentication();
                if (isset($tmpMount)) {
-                       $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint', (int)$tmpMount);
+                       $backendUser->setAndSaveSessionData('pageTree_temporaryMountPoint', (int)$tmpMount);
                }
                // Set temporary DB mounts
-               $alternativeWebmountPoint = (int)$GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint');
+               $alternativeWebmountPoint = (int)$backendUser->getSessionData('pageTree_temporaryMountPoint');
                if ($alternativeWebmountPoint) {
-                       $alternativeWebmountPoint = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $alternativeWebmountPoint);
-                       $GLOBALS['BE_USER']->setWebmounts($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($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
-                                       $appendAlternativeWebmountPoints = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints.append');
+                                       $alternativeWebmountPoints = trim($backendUser->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
+                                       $appendAlternativeWebmountPoints = $backendUser->getTSConfigVal('options.pageTree.altElementBrowserMountPoints.append');
                                        if ($alternativeWebmountPoints) {
-                                               $alternativeWebmountPoints = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $alternativeWebmountPoints);
+                                               $alternativeWebmountPoints = GeneralUtility::intExplode(',', $alternativeWebmountPoints);
                                                $GLOBALS['BE_USER']->setWebmounts($alternativeWebmountPoints, $appendAlternativeWebmountPoints);
                                        }
                        }
@@ -116,7 +127,7 @@ class ElementBrowserController {
                $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);
+                               $browserRenderObj = 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);
@@ -128,11 +139,11 @@ class ElementBrowserController {
                }
                // if type was not rendered use default rendering functions
                if (!$browserRendered) {
-                       $this->browser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Recordlist\Browser\ElementBrowser::class);
+                       $this->browser = GeneralUtility::makeInstance(ElementBrowser::class);
                        $this->browser->init();
-                       $modData = $GLOBALS['BE_USER']->getModuleData('browse_links.php', 'ses');
-                       list($modData, $store) = $this->browser->processSessionData($modData);
-                       $GLOBALS['BE_USER']->pushModuleData('browse_links.php', $modData);
+                       $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':
@@ -164,4 +175,18 @@ class ElementBrowserController {
                echo $this->content;
        }
 
+       /**
+        * @return LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
+
+       /**
+        * @return BackendUserAuthentication
+        */
+       protected function getBackendUserAuthentication() {
+               return $GLOBALS['BE_USER'];
+       }
+
 }
index 0cf3078..a9480ba 100644 (file)
@@ -14,8 +14,11 @@ namespace TYPO3\CMS\Recordlist\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Template\DocumentTemplate;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Lang\LanguageService;
 
 /**
  * Script Class, putting the frameset together.
@@ -39,10 +42,11 @@ class ElementBrowserFramesetController {
         */
        public function main() {
                // Setting GPvars:
-               $mode = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('mode');
-               $bparams = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('bparams');
+               $mode = GeneralUtility::_GP('mode');
+               $bparams = GeneralUtility::_GP('bparams');
                $moduleUrl = BackendUtility::getModuleUrl('wizard_element_browser') . '&mode=';
-               $GLOBALS['TBE_TEMPLATE']->JScode = $GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
+               $documentTemplate = $this->getDocumentTemplate();
+               $documentTemplate->JScode = $documentTemplate->wrapScriptTags('
                                function closing() {    //
                                        close();
                                }
@@ -56,14 +60,14 @@ class ElementBrowserFramesetController {
                ');
 
                // build the header part
-               $GLOBALS['TBE_TEMPLATE']->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:TYPO3_Element_Browser'));
+               $documentTemplate->startPage($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:TYPO3_Element_Browser'));
 
                // URL for the inner main frame:
                $url = $GLOBALS['BACK_PATH'] . $moduleUrl . rawurlencode($mode) . '&bparams=' . rawurlencode($bparams);
 
                // Create the frameset for the window
                // Formerly there were a ' onunload="closing();"' in the <frameset> tag - but it failed on Safari browser on Mac unless the handler was "onUnload"
-               $this->content = $GLOBALS['TBE_TEMPLATE']->getPageRenderer()->render(\TYPO3\CMS\Core\Page\PageRenderer::PART_HEADER) .
+               $this->content = $documentTemplate->getPageRenderer()->render(PageRenderer::PART_HEADER) .
                        '<frameset rows="*,1" framespacing="0" frameborder="0" border="0">
                                <frame name="content" src="' . htmlspecialchars($url) . '" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" noresize="noresize" />
                                <frame name="menu" src="' . $GLOBALS['BACK_PATH'] . 'dummy.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />
@@ -81,4 +85,18 @@ class ElementBrowserFramesetController {
                echo $this->content;
        }
 
+       /**
+        * @return DocumentTemplate
+        */
+       protected function getDocumentTemplate() {
+               return $GLOBALS['TBE_TEMPLATE'];
+       }
+
+       /**
+        * @return LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
+
 }
index 8abf139..ee22feb 100644 (file)
@@ -14,9 +14,17 @@ namespace TYPO3\CMS\Recordlist;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Clipboard\Clipboard;
+use TYPO3\CMS\Backend\Template\DocumentTemplate;
+use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\DataHandling\DataHandler;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Utility\MathUtility;
+use TYPO3\CMS\Lang\LanguageService;
 
 /**
  * Script Class for the Web > List module; rendering the listing of records on a page
@@ -119,14 +127,14 @@ class RecordList {
        /**
         * Current ids page record
         *
-        * @var array
+        * @var mixed[]|bool
         */
        public $pageinfo;
 
        /**
         * Document template object
         *
-        * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
+        * @var DocumentTemplate
         */
        public $doc;
 
@@ -141,14 +149,14 @@ class RecordList {
        /**
         * Menu configuration
         *
-        * @var array
+        * @var string[]
         */
        public $MOD_MENU = array();
 
        /**
         * Module settings (session variable)
         *
-        * @var array
+        * @var string[]
         */
        public $MOD_SETTINGS = array();
 
@@ -167,10 +175,15 @@ class RecordList {
        protected $moduleName = 'web_list';
 
        /**
+        * @var string
+        */
+       public $body = '';
+
+       /**
         * Constructor
         */
        public function __construct() {
-               $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_mod_web_list.xlf');
+               $this->getLanguageService()->includeLLFile('EXT:lang/locallang_mod_web_list.xlf');
        }
 
        /**
@@ -179,9 +192,10 @@ class RecordList {
         * @return void
         */
        public function init() {
-               $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
+               $backendUser = $this->getBackendUserAuthentication();
+               $this->perms_clause = $backendUser->getPagePermsClause(1);
                // Get session data
-               $sessionData = $GLOBALS['BE_USER']->getSessionData(\TYPO3\CMS\Recordlist\RecordList::class);
+               $sessionData = $backendUser->getSessionData(__CLASS__);
                $this->search_field = !empty($sessionData['search_field']) ? $sessionData['search_field'] : '';
                // GPvars:
                $this->id = (int)GeneralUtility::_GP('id');
@@ -205,8 +219,8 @@ class RecordList {
                // Initialize menu
                $this->menuConfig();
                // Store session data
-               $GLOBALS['BE_USER']->setAndSaveSessionData(\TYPO3\CMS\Recordlist\RecordList::class, $sessionData);
-               $GLOBALS['TBE_TEMPLATE']->getPageRenderer()->addInlineLanguageLabelFile('EXT:lang/locallang_mod_web_list.xlf');
+               $backendUser->setAndSaveSessionData(RecordList::class, $sessionData);
+               $this->getDocumentTemplate()->getPageRenderer()->addInlineLanguageLabelFile('EXT:lang/locallang_mod_web_list.xlf');
        }
 
        /**
@@ -234,7 +248,7 @@ class RecordList {
         */
        public function clearCache() {
                if ($this->clear_cache) {
-                       $tce = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
+                       $tce = GeneralUtility::makeInstance(DataHandler::class);
                        $tce->stripslashes_values = 0;
                        $tce->start(array(), array());
                        $tce->clear_cacheCmd($this->id);
@@ -247,8 +261,10 @@ class RecordList {
         * @return void
         */
        public function main() {
+               $backendUser = $this->getBackendUserAuthentication();
+               $lang = $this->getLanguageService();
                // Start document template object:
-               $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
+               $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
                $this->doc->backPath = $GLOBALS['BACK_PATH'];
                $this->doc->setModuleTemplate('EXT:recordlist/Resources/Private/Templates/db_list.html');
                $this->doc->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/AjaxDataHandler');
@@ -277,12 +293,12 @@ class RecordList {
                }
 
                // Initialize the dblist object:
-               /** @var $dblist \TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList */
-               $dblist = GeneralUtility::makeInstance(\TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList::class);
+               /** @var $dblist RecordList\DatabaseRecordList */
+               $dblist = GeneralUtility::makeInstance(RecordList\DatabaseRecordList::class);
                $dblist->backPath = $GLOBALS['BACK_PATH'];
                $dblist->script = BackendUtility::getModuleUrl('web_list', array(), '');
-               $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($this->pageinfo);
-               $dblist->thumbs = $GLOBALS['BE_USER']->uc['thumbnailsByDefault'];
+               $dblist->calcPerms = $backendUser->calcPerms($this->pageinfo);
+               $dblist->thumbs = $backendUser->uc['thumbnailsByDefault'];
                $dblist->returnUrl = $this->returnUrl;
                $dblist->allFields = $this->MOD_SETTINGS['bigControlPanel'] || $this->table ? 1 : 0;
                $dblist->localizationView = $this->MOD_SETTINGS['localization'];
@@ -303,7 +319,7 @@ class RecordList {
                $dblist->clickTitleMode = $clickTitleMode === '' ? 'edit' : $clickTitleMode;
                // Clipboard is initialized:
                // Start clipboard
-               $dblist->clipObj = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Clipboard\Clipboard::class);
+               $dblist->clipObj = GeneralUtility::makeInstance(Clipboard::class);
                // Initialize - reads the clipboard content from the user session
                $dblist->clipObj->initializeClipboard();
                // Clipboard actions are handled:
@@ -340,7 +356,7 @@ class RecordList {
                                                $iKParts = explode('|', $iK);
                                                $cmd[$iKParts[0]][$iKParts[1]]['delete'] = 1;
                                        }
-                                       $tce = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
+                                       $tce = GeneralUtility::makeInstance(DataHandler::class);
                                        $tce->stripslashes_values = 0;
                                        $tce->start(array(), $cmd);
                                        $tce->process_cmdmap();
@@ -351,11 +367,11 @@ class RecordList {
                                }
                        }
                        // Initialize the listing object, dblist, for rendering the list:
-                       $this->pointer = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->pointer, 0, 100000);
+                       $this->pointer = MathUtility::forceIntegerInRange($this->pointer, 0, 100000);
                        $dblist->start($this->id, $this->table, $this->pointer, $this->search_field, $this->search_levels, $this->showLimit);
                        $dblist->setDispFields();
                        // Render versioning selector:
-                       if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('version')) {
+                       if (ExtensionManagementUtility::isLoaded('version')) {
                                $dblist->HTMLcode .= $this->doc->getVersionSelector($this->id);
                        }
                        // Render the list of tables:
@@ -424,7 +440,7 @@ class RecordList {
                } else {
                        $output = $flashMessage = GeneralUtility::makeInstance(
                                FlashMessage::class,
-                               $GLOBALS['LANG']->getLL('noRecordsOnThisPage'),
+                               $lang->getLL('noRecordsOnThisPage'),
                                '',
                                FlashMessage::INFO
                        )->render();
@@ -453,7 +469,7 @@ class RecordList {
                                $this->body .= '<div class="checkbox">' .
                                        '<label for="checkLargeControl">' .
                                        BackendUtility::getFuncCheck($this->id, 'SET[bigControlPanel]', $this->MOD_SETTINGS['bigControlPanel'], '', $this->table ? '&table=' . $this->table : '', 'id="checkLargeControl"') .
-                                       BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $GLOBALS['LANG']->getLL('largeControl', TRUE)) .
+                                       BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $lang->getLL('largeControl', TRUE)) .
                                        '</label>' .
                                        '</div>';
                        }
@@ -464,7 +480,7 @@ class RecordList {
                                        $this->body .= '<div class="checkbox">' .
                                                '<label for="checkShowClipBoard">' .
                                                BackendUtility::getFuncCheck($this->id, 'SET[clipBoard]', $this->MOD_SETTINGS['clipBoard'], '', $this->table ? '&table=' . $this->table : '', 'id="checkShowClipBoard"') .
-                                               BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $GLOBALS['LANG']->getLL('showClipBoard', TRUE)) .
+                                               BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $lang->getLL('showClipBoard', TRUE)) .
                                                '</label>' .
                                                '</div>';
                                }
@@ -475,7 +491,7 @@ class RecordList {
                                $this->body .= '<div class="checkbox">' .
                                        '<label for="checkLocalization">' .
                                        BackendUtility::getFuncCheck($this->id, 'SET[localization]', $this->MOD_SETTINGS['localization'], '', $this->table ? '&table=' . $this->table : '', 'id="checkLocalization"') .
-                                       BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $GLOBALS['LANG']->getLL('localization', TRUE)) .
+                                       BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $lang->getLL('localization', TRUE)) .
                                        '</label>' .
                                        '</div>';
                        }
@@ -504,12 +520,13 @@ class RecordList {
                        'EXTRACONTAINERCLASS' => $this->table ? 'singletable' : '',
                        'BUTTONLIST_ADDITIONAL' => '',
                        'SEARCHBOX' => '',
-                       'BUTTONLIST_ADDITIONAL' => ''
                );
                // searchbox toolbar
                if (!$this->modTSconfig['properties']['disableSearchBox'] && ($dblist->HTMLcode || !empty($dblist->searchString))) {
                        $markers['SEARCHBOX'] = $dblist->getSearchBox();
-                       $markers['BUTTONLIST_ADDITIONAL'] = '<a href="#" onclick="toggleSearchToolbox(); return false;" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.searchIcon', TRUE) . '">'.\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('apps-toolbar-menu-search').'</a>';
+                       $markers['BUTTONLIST_ADDITIONAL'] = '<a href="#" onclick="toggleSearchToolbox(); return false;" title="'
+                               . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.searchIcon', TRUE) . '">'
+                               . IconUtility::getSpriteIcon('apps-toolbar-menu-search').'</a>';
                }
                // Build the <body> for the module
                $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
@@ -526,4 +543,25 @@ class RecordList {
                echo $this->content;
        }
 
+       /**
+        * @return BackendUserAuthentication
+        */
+       protected function getBackendUserAuthentication() {
+               return $GLOBALS['BE_USER'];
+       }
+
+       /**
+        * @return LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
+
+       /**
+        * @return DocumentTemplate
+        */
+       protected function getDocumentTemplate() {
+               return $GLOBALS['TBE_TEMPLATE'];
+       }
+
 }
index ef5e2fa..cea2568 100644 (file)
@@ -14,8 +14,17 @@ namespace TYPO3\CMS\Recordlist\RecordList;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Module\BaseScriptClass;
+use TYPO3\CMS\Backend\RecordList\AbstractRecordList;
+use TYPO3\CMS\Backend\Template\DocumentTemplate;
+use TYPO3\CMS\Backend\Tree\View\PageTreeView;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\Database\DatabaseConnection;
+use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\HttpUtility;
+use TYPO3\CMS\Core\Utility\MathUtility;
 
 /**
  * Child class for rendering of Web > List (not the final class.
@@ -24,7 +33,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  * @see \TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList
  */
-class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractRecordList {
+class AbstractDatabaseRecordList extends AbstractRecordList {
 
        /**
         * Specify a list of tables which are the only ones allowed to be displayed.
@@ -106,7 +115,7 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
        /**
         * Containing which fields to display in extended mode
         *
-        * @var array
+        * @var string[]
         */
        public $displayFields;
 
@@ -205,7 +214,7 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
        /**
         * Loaded with page record with version overlay if any.
         *
-        * @var array
+        * @var string[]
         */
        public $pageRecord = array();
 
@@ -226,14 +235,14 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
        /**
         * TSconfig which overwrites TCA-Settings
         *
-        * @var array
+        * @var mixed[][]
         */
        public $tableTSconfigOverTCA = array();
 
        /**
         * Array of collapsed / uncollapsed tables in multi table view
         *
-        * @var array
+        * @var int[][]
         */
        public $tablesCollapsed = array();
 
@@ -275,39 +284,39 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
        /**
         * Cache for record path
         *
-        * @var array
+        * @var mixed[]
         */
        public $recPath_cache = array();
 
        /**
         * Fields to display for the current table
         *
-        * @var array
+        * @var string[]
         */
        public $setFields = array();
 
        /**
         * Used for tracking next/prev uids
         *
-        * @var array
+        * @var int[][]
         */
        public $currentTable = array();
 
        /**
         * Used for tracking duplicate values of fields
         *
-        * @var array
+        * @var string[]
         */
        public $duplicateStack = array();
 
        /**
-        * @var array Module configuration
+        * @var array[] Module configuration
         */
        public $modTSconfig;
 
        /**
         * Override/add urlparameters in listUrl() method
-        * @var array
+        * @var string[]
         */
        protected $overrideUrlParameters = array();
 
@@ -322,7 +331,9 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
         * @param int $showLimit Limit of records to be listed.
         * @return void
         */
-       public function start($id, $table, $pointer, $search = '', $levels = '', $showLimit = 0) {
+       public function start($id, $table, $pointer, $search = '', $levels = 0, $showLimit = 0) {
+               $backendUser = $this->getBackendUserAuthentication();
+               $db = $this->getDatabaseConnection();
                // Setting internal variables:
                // sets the parent id
                $this->id = (int)$id;
@@ -332,8 +343,8 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
                }
                $this->firstElementNumber = $pointer;
                $this->searchString = trim($search);
-               $this->searchLevels = trim($levels);
-               $this->showLimit = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($showLimit, 0, 10000);
+               $this->searchLevels = (int)$levels;
+               $this->showLimit = MathUtility::forceIntegerInRange($showLimit, 0, 10000);
                // Setting GPvars:
                $this->csvOutput = GeneralUtility::_GP('csv') ? TRUE : FALSE;
                $this->sortField = GeneralUtility::_GP('sortField');
@@ -349,22 +360,22 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
                $this->HTMLcode = '';
                // Limits
                if (isset($this->modTSconfig['properties']['itemsLimitPerTable'])) {
-                       $this->itemsLimitPerTable = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int)$this->modTSconfig['properties']['itemsLimitPerTable'], 1, 10000);
+                       $this->itemsLimitPerTable = MathUtility::forceIntegerInRange((int)$this->modTSconfig['properties']['itemsLimitPerTable'], 1, 10000);
                }
                if (isset($this->modTSconfig['properties']['itemsLimitSingleTable'])) {
-                       $this->itemsLimitSingleTable = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int)$this->modTSconfig['properties']['itemsLimitSingleTable'], 1, 10000);
+                       $this->itemsLimitSingleTable = MathUtility::forceIntegerInRange((int)$this->modTSconfig['properties']['itemsLimitSingleTable'], 1, 10000);
                }
                // Set search levels:
-               $searchLevels = (int)$this->searchLevels;
-               $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
-               // This will hide records from display - it has nothing todo with user rights!!
-               if ($pidList = $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages')) {
-                       if ($pidList = $GLOBALS['TYPO3_DB']->cleanIntList($pidList)) {
+               $searchLevels = $this->searchLevels;
+               $this->perms_clause = $backendUser->getPagePermsClause(1);
+               // This will hide records from display - it has nothing to do with user rights!!
+               if ($pidList = $backendUser->getTSConfigVal('options.hideRecords.pages')) {
+                       if ($pidList = $db->cleanIntList($pidList)) {
                                $this->perms_clause .= ' AND pages.uid NOT IN (' . $pidList . ')';
                        }
                }
                // Get configuration of collapsed tables from user uc and merge with sanitized GP vars
-               $this->tablesCollapsed = is_array($GLOBALS['BE_USER']->uc['moduleData']['list']) ? $GLOBALS['BE_USER']->uc['moduleData']['list'] : array();
+               $this->tablesCollapsed = is_array($backendUser->uc['moduleData']['list']) ? $backendUser->uc['moduleData']['list'] : array();
                $collapseOverride = GeneralUtility::_GP('collapse');
                if (is_array($collapseOverride)) {
                        foreach ($collapseOverride as $collapseTable => $collapseValue) {
@@ -373,16 +384,16 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
                                }
                        }
                        // Save modified user uc
-                       $GLOBALS['BE_USER']->uc['moduleData']['list'] = $this->tablesCollapsed;
-                       $GLOBALS['BE_USER']->writeUC($GLOBALS['BE_USER']->uc);
+                       $backendUser->uc['moduleData']['list'] = $this->tablesCollapsed;
+                       $backendUser->writeUC($backendUser->uc);
                        $returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
                        if ($returnUrl !== '') {
-                               \TYPO3\CMS\Core\Utility\HttpUtility::redirect($returnUrl);
+                               HttpUtility::redirect($returnUrl);
                        }
                }
                if ($searchLevels > 0) {
                        $allowedMounts = $this->getSearchableWebmounts($this->id, $searchLevels, $this->perms_clause);
-                       $pidList = implode(',', $GLOBALS['TYPO3_DB']->cleanIntArray($allowedMounts));
+                       $pidList = implode(',', $db->cleanIntArray($allowedMounts));
                        $this->pidSelect = 'pid IN (' . $pidList . ')';
                } elseif ($searchLevels < 0) {
                        // Search everywhere
@@ -406,15 +417,16 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
        public function generateList() {
                // Set page record in header
                $this->pageRecord = BackendUtility::getRecordWSOL('pages', $this->id);
+               $hideTablesArray = GeneralUtility::trimExplode(',', $this->hideTables);
                // Traverse the TCA table array:
                foreach ($GLOBALS['TCA'] as $tableName => $value) {
                        // Checking if the table should be rendered:
                        // Checks that we see only permitted/requested tables:
-                       if ((!$this->table || $tableName == $this->table) && (!$this->tableList || GeneralUtility::inList($this->tableList, $tableName)) && $GLOBALS['BE_USER']->check('tables_select', $tableName)) {
+                       if ((!$this->table || $tableName == $this->table) && (!$this->tableList || GeneralUtility::inList($this->tableList, $tableName)) && $this->getBackendUserAuthentication()->check('tables_select', $tableName)) {
                                // Don't show table if hidden by TCA ctrl section
                                $hideTable = $GLOBALS['TCA'][$tableName]['ctrl']['hideTable'] ? TRUE : FALSE;
                                // Don't show table if hidden by pageTSconfig mod.web_list.hideTables
-                               if (in_array($tableName, GeneralUtility::trimExplode(',', $this->hideTables))) {
+                               if (in_array($tableName, $hideTablesArray)) {
                                        $hideTable = TRUE;
                                }
                                // Override previous selection if table is enabled or hidden by TSconfig TCA override mod.web_list.table
@@ -429,7 +441,7 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
                                        $this->iLimit = isset($GLOBALS['TCA'][$tableName]['interface']['maxSingleDBListItems']) ? (int)$GLOBALS['TCA'][$tableName]['interface']['maxSingleDBListItems'] : $this->itemsLimitSingleTable;
                                } else {
                                        // if there are no records in table continue current foreach
-                                       $firstRow = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
+                                       $firstRow = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
                                                'uid',
                                                $tableName,
                                                $this->pidSelect . BackendUtility::deleteClause($tableName) . BackendUtility::versioningPlaceholderClause($tableName)
@@ -458,7 +470,7 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
                                        $fields = array();
                                }
                                // Find ID to use (might be different for "versioning_followPages" tables)
-                               if ((int)$this->searchLevels === 0) {
+                               if ($this->searchLevels === 0) {
                                        $this->pidSelect = 'pid=' . (int)$this->id;
                                }
                                // Finally, render the list:
@@ -468,12 +480,25 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
        }
 
        /**
+        * To be implemented in extending classes.
+        *
+        * @param string $tableName
+        * @param int $id
+        * @param string $fields List of fields to show in the listing. Pseudo fields will be added including the record header.
+        * @return string HTML code
+        */
+       public function getTable($tableName, $id, $fields) {
+               return '';
+       }
+
+       /**
         * Creates the search box
         *
         * @param bool $formFields If TRUE, the search box is wrapped in its own form-tags
         * @return string HTML for the search box
         */
-       public function getSearchBox($formFields = 1) {
+       public function getSearchBox($formFields = TRUE) {
+               $lang = $this->getLanguageService();
                // Setting form-elements, if applicable:
                $formElements = array('', '');
                if ($formFields) {
@@ -481,11 +506,11 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
                }
                // Make level selector:
                $opt = array();
-               $parts = explode('|', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.enterSearchLevels'));
+               $parts = explode('|', $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.enterSearchLevels'));
                foreach ($parts as $kv => $label) {
-                       $opt[] = '<option value="' . $kv . '"' . ($kv == (int)$this->searchLevels ? ' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>';
+                       $opt[] = '<option value="' . $kv . '"' . ($kv ==$this->searchLevels ? ' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>';
                }
-               $lMenu = '<select class="form-control" name="search_levels" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.search_levels', TRUE) . '" id="search_levels">' . implode('', $opt) . '</select>';
+               $lMenu = '<select class="form-control" name="search_levels" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.search_levels', TRUE) . '" id="search_levels">' . implode('', $opt) . '</select>';
                // Table with the search box:
                $content = '<div class="db_list-searchbox-form db_list-searchbox-toolbar" id="db_list-searchbox-toolbar" style="display: ' . ($this->searchString == '' ? 'none' : 'block') . ';">
                        ' . $formElements[0] . '
@@ -493,25 +518,25 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
                                        <div class="row">
                                                <div class="col-xs-3 col-md-3 col-lg-3">
                                                        <div class="input-group">
-                                                               <label class="pull-left" for="search_field">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.label.searchString', TRUE) . ': </label>
-                                                               <input class="form-control" type="search" placeholder="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.enterSearchString', TRUE) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.searchString', TRUE) . '" name="search_field" id="search_field" value="' . htmlspecialchars($this->searchString) . '" />
+                                                               <label class="pull-left" for="search_field">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.label.searchString', TRUE) . ': </label>
+                                                               <input class="form-control" type="search" placeholder="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.enterSearchString', TRUE) . '" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.searchString', TRUE) . '" name="search_field" id="search_field" value="' . htmlspecialchars($this->searchString) . '" />
                                                        </div>
                                                </div>
                                                <div class="col-xs-3 col-md-3 col-lg-3">
                                                        <div class="input-group">
-                                                               <label class="pull-left" for="search_levels">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.label.search_levels', TRUE) . ': </label>
+                                                               <label class="pull-left" for="search_levels">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.label.search_levels', TRUE) . ': </label>
                                                                ' . $lMenu . '
                                                        </div>
                                                </div>
                                                <div class="col-xs-3 col-md-3 col-lg-3">
                                                        <div class="input-group">
-                                                               <label class="pull-left" for="showLimit">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.label.limit', TRUE) . ': </label>
-                                                               <input class="form-control" type="number" min="0" max="10000" placeholder="10" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.limit', TRUE) . '" name="showLimit" id="showLimit" value="' . htmlspecialchars(($this->showLimit ? $this->showLimit : '')) . '" />
+                                                               <label class="pull-left" for="showLimit">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.label.limit', TRUE) . ': </label>
+                                                               <input class="form-control" type="number" min="0" max="10000" placeholder="10" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.limit', TRUE) . '" name="showLimit" id="showLimit" value="' . htmlspecialchars(($this->showLimit ? $this->showLimit : '')) . '" />
                                                        </div>
                                                </div>
                                                <div class="col-xs-3 col-md-3 col-lg-3">
                                                        <div class="input-group">
-                                                               <input type="submit" class="btn btn-default btn-block" name="search" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.search', TRUE) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.search', TRUE) . '" />
+                                                               <input type="submit" class="btn btn-default btn-block" name="search" value="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.search', TRUE) . '" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.search', TRUE) . '" />
                                                        </div>
                                                </div>
                                        </div>
@@ -531,14 +556,15 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
         * @return void
         */
        public function setDispFields() {
+               $backendUser = $this->getBackendUserAuthentication();
                // Getting from session:
-               $dispFields = $GLOBALS['BE_USER']->getModuleData('list/displayFields');
+               $dispFields = $backendUser->getModuleData('list/displayFields');
                // If fields has been inputted, then set those as the value and push it to session variable:
                if (is_array($this->displayFields)) {
                        reset($this->displayFields);
                        $tKey = key($this->displayFields);
                        $dispFields[$tKey] = $this->displayFields[$tKey];
-                       $GLOBALS['BE_USER']->pushModuleData('list/displayFields', $dispFields);
+                       $backendUser->pushModuleData('list/displayFields', $dispFields);
                }
                // Setting result:
                $this->setFields = $dispFields;
@@ -547,7 +573,7 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
        /**
         * Create thumbnail code for record/field
         *
-        * @param array $row Record array
+        * @param mixed[] $row Record array
         * @param string $table Table (record is from)
         * @param string $field Field name for which thumbnail are to be rendered.
         * @return string HTML for thumbnails, if any.
@@ -563,7 +589,7 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
         * @param int $id Page id (NOT USED! $this->pidSelect is used instead)
         * @param string $addWhere Additional part for where clause
         * @param string $fieldList Field list to select, * for all (for "SELECT [fieldlist] FROM ...")
-        * @return array Returns query array
+        * @return string[] Returns query array
         */
        public function makeQueryArray($table, $id, $addWhere = '', $fieldList = '*') {
                $hookObjectsArr = array();
@@ -594,7 +620,7 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
                        'FROM' => $table,
                        'WHERE' => $this->pidSelect . ' ' . $pC . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table) . ' ' . $addWhere . ' ' . $search,
                        'GROUPBY' => '',
-                       'ORDERBY' => $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy),
+                       'ORDERBY' => $this->getDatabaseConnection()->stripOrderBy($orderBy),
                        'LIMIT' => $limit
                );
                // Filter out records that are translated, if TSconfig mod.web_list.hideTranslations is set
@@ -620,12 +646,12 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
        /**
         * Based on input query array (query for selecting count(*) from a table) it will select the number of records and set the value in $this->totalItems
         *
-        * @param array $queryParts Query array
+        * @param string[] $queryParts Query array
         * @return void
         * @see makeQueryArray()
         */
        public function setTotalItems($queryParts) {
-               $this->totalItems = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', $queryParts['FROM'], $queryParts['WHERE']);
+               $this->totalItems = $this->getDatabaseConnection()->exec_SELECTcountRows('*', $queryParts['FROM'], $queryParts['WHERE']);
        }
 
        /**
@@ -639,13 +665,13 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
        public function makeSearchString($table, $currentPid = -1) {
                $result = '';
                $currentPid = (int)$currentPid;
-               $tablePidField = $table == 'pages' ? 'uid' : 'pid';
+               $tablePidField = $table === 'pages' ? 'uid' : 'pid';
                // Make query, only if table is valid and a search string is actually defined:
                if ($this->searchString) {
                        $result = ' AND 0=1';
                        $searchableFields = $this->getSearchFields($table);
                        if (count($searchableFields) > 0) {
-                               if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->searchString)) {
+                               if (MathUtility::canBeInterpretedAsInteger($this->searchString)) {
                                        $whereParts = array(
                                                'uid=' . $this->searchString
                                        );
@@ -669,7 +695,8 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
                                        }
                                } else {
                                        $whereParts = array();
-                                       $like = '\'%' . $GLOBALS['TYPO3_DB']->quoteStr($GLOBALS['TYPO3_DB']->escapeStrForLike($this->searchString, $table), $table) . '%\'';
+                                       $db = $this->getDatabaseConnection();
+                                       $like = '\'%' . $db->quoteStr($db->escapeStrForLike($this->searchString, $table), $table) . '%\'';
                                        foreach ($searchableFields as $fieldName) {
                                                if (isset($GLOBALS['TCA'][$table]['columns'][$fieldName])) {
                                                        $fieldConfig = &$GLOBALS['TCA'][$table]['columns'][$fieldName]['config'];
@@ -704,7 +731,7 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
         * Fetches a list of fields to use in the Backend search for the given table.
         *
         * @param string $tableName
-        * @return array
+        * @return string[]
         */
        protected function getSearchFields($tableName) {
                $fieldArray = array();
@@ -738,11 +765,10 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
         * @return string The linked table label
         */
        public function linkWrapTable($table, $code) {
-               if ($this->table != $table) {
+               if ($this->table !== $table) {
                        return '<a href="' . htmlspecialchars($this->listURL('', $table, 'firstElementNumber')) . '">' . $code . '</a>';
-               } else {
-                       return '<a href="' . htmlspecialchars($this->listURL('', '', 'sortField,sortRev,table,firstElementNumber')) . '">' . $code . '</a>';
                }
+               return '<a href="' . htmlspecialchars($this->listURL('', '', 'sortField,sortRev,table,firstElementNumber')) . '">' . $code . '</a>';
        }
 
        /**
@@ -751,15 +777,16 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
         * @param string $table Table name
         * @param int $uid Item uid
         * @param string $code Item title (not htmlspecialchars()'ed yet)
-        * @param array $row Item row
+        * @param mixed[] $row Item row
         * @return string The item title. Ready for HTML output (is htmlspecialchars()'ed)
         */
        public function linkWrapItems($table, $uid, $code, $row) {
+               $lang = $this->getLanguageService();
                $origCode = $code;
                // If the title is blank, make a "no title" label:
                if ((string)$code === '') {
-                       $code = '<i>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', 1) . ']</i> - ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs(
-                                               BackendUtility::getRecordTitle($table, $row), $GLOBALS['BE_USER']->uc['titleLen']));
+                       $code = '<i>[' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', 1) . ']</i> - ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs(
+                                               BackendUtility::getRecordTitle($table, $row), $this->getBackendUserAuthentication()->uc['titleLen']));
                } else {
                        $code = htmlspecialchars(GeneralUtility::fixed_lgd_cs($code, $this->fixedL), ENT_QUOTES, 'UTF-8', FALSE);
                        if ($code != htmlspecialchars($origCode)) {
@@ -770,7 +797,7 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
                        case 'edit':
                                // If the listed table is 'pages' we have to request the permission settings for each page:
                                if ($table == 'pages') {
-                                       $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(BackendUtility::getRecord('pages', $row['uid']));
+                                       $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', $row['uid']));
                                        $permsEdit = $localCalcPerms & 2;
                                } else {
                                        $permsEdit = $this->calcPerms & 16;
@@ -779,19 +806,19 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
                                if ($permsEdit) {
                                        $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
                                        $code = '<a href="#" onclick="' . htmlspecialchars(
-                                                       BackendUtility::editOnClick($params, $this->backPath, -1)) . '" title="' . $GLOBALS['LANG']->getLL('edit', TRUE) . '">' . $code . '</a>';
+                                                       BackendUtility::editOnClick($params, $this->backPath, -1)) . '" title="' . $lang->getLL('edit', TRUE) . '">' . $code . '</a>';
                                }
                                break;
                        case 'show':
                                // "Show" link (only pages and tt_content elements)
                                if ($table == 'pages' || $table == 'tt_content') {
                                        $code = '<a href="#" onclick="' . htmlspecialchars(
-                                                       BackendUtility::viewOnClick(($table == 'tt_content' ? $this->id . '#' . $row['uid'] : $row['uid']))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">' . $code . '</a>';
+                                                       BackendUtility::viewOnClick(($table == 'tt_content' ? $this->id . '#' . $row['uid'] : $row['uid']))) . '" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">' . $code . '</a>';
                                }
                                break;
                        case 'info':
                                // "Info": (All records)
-                               $code = '<a href="#" onclick="' . htmlspecialchars(('top.launchView(\'' . $table . '\', \'' . $row['uid'] . '\'); return false;')) . '" title="' . $GLOBALS['LANG']->getLL('showInfo', TRUE) . '">' . $code . '</a>';
+                               $code = '<a href="#" onclick="' . htmlspecialchars(('top.launchView(\'' . $table . '\', \'' . $row['uid'] . '\'); return false;')) . '" title="' . $lang->getLL('showInfo', TRUE) . '">' . $code . '</a>';
                                break;
                        default:
                                // Output the label now:
@@ -831,18 +858,18 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
         * The GPvars "sortField" and "sortRev" are also included UNLESS they are found in the $exclList variable.
         *
         * @param string $altId Alternative id value. Enter blank string for the current id ($this->id)
-        * @param string $table Tablename to display. Enter "-1" for the current table.
-        * @param string $exclList Commalist of fields NOT to include ("sortField", "sortRev" or "firstElementNumber")
+        * @param string $table Table name to display. Enter "-1" for the current table.
+        * @param string $exclList Comma separated list of fields NOT to include ("sortField", "sortRev" or "firstElementNumber")
         * @return string URL
         */
-       public function listURL($altId = '', $table = -1, $exclList = '') {
+       public function listURL($altId = '', $table = '-1', $exclList = '') {
                $urlParameters = array();
                if ((string)$altId !== '') {
                        $urlParameters['id'] = $altId;
                } else {
                        $urlParameters['id'] = $this->id;
                }
-               if ($table === -1) {
+               if ($table === '-1') {
                        $urlParameters['table'] = $this->table;
                } else {
                        $urlParameters['table'] = $table;
@@ -892,9 +919,10 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
         * @param string $table Table name
         * @param bool $dontCheckUser If set, users access to the field (non-exclude-fields) is NOT checked.
         * @param bool $addDateFields If set, also adds crdate and tstamp fields (note: they will also be added if user is admin or dontCheckUser is set)
-        * @return array Array, where values are fieldnames to include in query
+        * @return string[] Array, where values are fieldnames to include in query
         */
-       public function makeFieldList($table, $dontCheckUser = 0, $addDateFields = 0) {
+       public function makeFieldList($table, $dontCheckUser = FALSE, $addDateFields = FALSE) {
+               $backendUser = $this->getBackendUserAuthentication();
                // Init fieldlist array:
                $fieldListArr = array();
                // Check table:
@@ -902,7 +930,7 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
                        if (isset($GLOBALS['TCA'][$table]['columns']) && is_array($GLOBALS['TCA'][$table]['columns'])) {
                                // Traverse configured columns and add them to field array, if available for user.
                                foreach ($GLOBALS['TCA'][$table]['columns'] as $fN => $fieldValue) {
-                                       if ($dontCheckUser || (!$fieldValue['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $fN)) && $fieldValue['config']['type'] != 'passthrough') {
+                                       if ($dontCheckUser || (!$fieldValue['exclude'] || $backendUser->check('non_exclude_fields', $table . ':' . $fN)) && $fieldValue['config']['type'] != 'passthrough') {
                                                $fieldListArr[] = $fN;
                                        }
                                }
@@ -911,7 +939,7 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
                                $fieldListArr[] = 'pid';
 
                                // Add date fields
-                               if ($dontCheckUser || $GLOBALS['BE_USER']->isAdmin() || $addDateFields) {
+                               if ($dontCheckUser || $backendUser->isAdmin() || $addDateFields) {
                                        if ($GLOBALS['TCA'][$table]['ctrl']['tstamp']) {
                                                $fieldListArr[] = $GLOBALS['TCA'][$table]['ctrl']['tstamp'];
                                        }
@@ -920,14 +948,14 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
                                        }
                                }
                                // Add more special fields:
-                               if ($dontCheckUser || $GLOBALS['BE_USER']->isAdmin()) {
+                               if ($dontCheckUser || $backendUser->isAdmin()) {
                                        if ($GLOBALS['TCA'][$table]['ctrl']['cruser_id']) {
                                                $fieldListArr[] = $GLOBALS['TCA'][$table]['ctrl']['cruser_id'];
                                        }
                                        if ($GLOBALS['TCA'][$table]['ctrl']['sortby']) {
                                                $fieldListArr[] = $GLOBALS['TCA'][$table]['ctrl']['sortby'];
                                        }
-                                       if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('version') && $GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
+                                       if (ExtensionManagementUtility::isLoaded('version') && $GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
                                                $fieldListArr[] = 't3ver_id';
                                                $fieldListArr[] = 't3ver_state';
                                                $fieldListArr[] = 't3ver_wsid';
@@ -946,18 +974,19 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
         * @param int $id Page id
         * @param int $depth Depth to go down
         * @param string $perms_clause select clause
-        * @return array
+        * @return int[]
         */
        protected function getSearchableWebmounts($id, $depth, $perms_clause) {
-               /** @var \TYPO3\CMS\Backend\Tree\View\PageTreeView $tree */
-               $tree = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\View\PageTreeView::class);
+               $backendUser = $this->getBackendUserAuthentication();
+               /** @var PageTreeView $tree */
+               $tree = GeneralUtility::makeInstance(PageTreeView::class);
                $tree->init('AND ' . $perms_clause);
                $tree->makeHTML = 0;
                $tree->fieldArray = array('uid', 'php_tree_stop');
                $idList = array();
 
-               $allowedMounts = !$GLOBALS['BE_USER']->isAdmin() && $id === 0
-                       ? $GLOBALS['BE_USER']->returnWebmounts()
+               $allowedMounts = !$backendUser->isAdmin() && $id === 0
+                       ? $backendUser->returnWebmounts()
                        : array($id);
 
                foreach ($allowedMounts as $allowedMount) {
@@ -980,14 +1009,14 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
        public function localizationRedirect($justLocalized) {
                list($table, $orig_uid, $language) = explode(':', $justLocalized);
                if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['languageField'] && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) {
-                       $localizedRecord = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid', $table, $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '=' . (int)$language . ' AND ' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . '=' . (int)$orig_uid . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table));
+                       $localizedRecord = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('uid', $table, $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '=' . (int)$language . ' AND ' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . '=' . (int)$orig_uid . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table));
                        if (is_array($localizedRecord)) {
                                // Create parameters and finally run the classic page module for creating a new page translation
                                $url = substr($this->listURL(), strlen($this->backPath));
                                $params = '&edit[' . $table . '][' . $localizedRecord['uid'] . ']=edit';
                                $returnUrl = '&returnUrl=' . rawurlencode($url);
                                $location = $GLOBALS['BACK_PATH'] . 'alt_doc.php?' . $params . $returnUrl;
-                               \TYPO3\CMS\Core\Utility\HttpUtility::redirect($location);
+                               HttpUtility::redirect($location);
                        }
                }
        }
@@ -995,11 +1024,24 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
        /**
         * Set URL parameters to override or add in the listUrl() method.
         *
-        * @param array $urlParameters
+        * @param string[] $urlParameters
         * @return void
         */
        public function setOverrideUrlParameters(array $urlParameters) {
                $this->overrideUrlParameters = $urlParameters;
        }
 
+       /**
+        * @return BackendUserAuthentication
+        */
+       protected function getBackendUserAuthentication() {
+               return $GLOBALS['BE_USER'];
+       }
+
+       /**
+        * @return DatabaseConnection
+        */
+       protected function getDatabaseConnection() {
+               return $GLOBALS['TYPO3_DB'];
+       }
 }
index 54f22d0..6e097bb 100644 (file)
@@ -14,11 +14,15 @@ namespace TYPO3\CMS\Recordlist\RecordList;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Database\DatabaseConnection;
+use TYPO3\CMS\Backend\RecordList\RecordListGetTableHookInterface;
+use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Core\Messaging\FlashMessageService;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\Utility\MathUtility;
+use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Class for rendering of Web>List module
@@ -35,7 +39,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
         * Used to indicate which tables (values in the array) that can have a
         * create-new-record link. If the array is empty, all tables are allowed.
         *
-        * @var array
+        * @var string[]
         */
        public $allowedNewTables = array();
 
@@ -43,7 +47,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
         * Used to indicate which tables (values in the array) that cannot have a
         * create-new-record link. If the array is empty, all tables are allowed.
         *
-        * @var array
+        * @var string[]
         */
        public $deniedNewTables = array();
 
@@ -112,14 +116,14 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
        /**
         * Set to the page record (see writeTop())
         *
-        * @var array
+        * @var string[]
         */
        public $pageRow = array();
 
        /**
         * Used to accumulate CSV lines for CSV export.
         *
-        * @var array
+        * @var string[]
         */
        protected $csvLines = array();
 
@@ -140,28 +144,21 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
        /**
         * Tracking names of elements (for clipboard use)
         *
-        * @var array
+        * @var string[]
         */
        public $CBnames = array();
 
        /**
-        * Used to track which elements has duplicates and how many
-        *
-        * @var array
-        */
-       public $duplicateStack = array();
-
-       /**
         * [$tablename][$uid] = number of references to this record
         *
-        * @var array
+        * @var int[][]
         */
        protected $referenceCount = array();
 
        /**
         * Translations of the current record
         *
-        * @var array
+        * @var string[]
         */
        public $translations;
 
@@ -174,17 +171,27 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
        public $selFieldList;
 
        /**
-        * @var array
+        * @var mixed[]
         */
        public $pageinfo;
 
        /**
+        * Injected by RecordList
+        *
+        * @var string[]
+        */
+       public $MOD_MENU;
+
+       /**
         * Create the panel of buttons for submitting the form or otherwise perform
         * operations.
         *
-        * @return array All available buttons as an assoc. array
+        * @return string[] All available buttons as an assoc. array
         */
        public function getButtons() {
+               $module = $this->getModule();
+               $backendUser = $this->getBackendUserAuthentication();
+               $lang = $this->getLanguageService();
                $buttons = array(
                        'csh' => '',
                        'view' => '',
@@ -202,7 +209,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                        'export' => ''
                );
                // Get users permissions for this page record:
-               $localCalcPerms = $GLOBALS['BE_USER']->calcPerms($this->pageRow);
+               $localCalcPerms = $backendUser->calcPerms($this->pageRow);
                // CSH
                if ((string)$this->id === '') {
                        $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'list_module_noId');
@@ -214,26 +221,26 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                if (isset($this->id)) {
                        // View Exclude doktypes 254,255 Configuration:
                        // mod.web_list.noViewWithDokTypes = 254,255
-                       if (isset($GLOBALS['SOBE']->modTSconfig['properties']['noViewWithDokTypes'])) {
-                               $noViewDokTypes = GeneralUtility::trimExplode(',', $GLOBALS['SOBE']->modTSconfig['properties']['noViewWithDokTypes'], TRUE);
+                       if (isset($module->modTSconfig['properties']['noViewWithDokTypes'])) {
+                               $noViewDokTypes = GeneralUtility::trimExplode(',', $module->modTSconfig['properties']['noViewWithDokTypes'], TRUE);
                        } else {
                                //default exclusion: doktype 254 (folder), 255 (recycler)
                                $noViewDokTypes = array(
-                                       \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SYSFOLDER,
-                                       \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_RECYCLER
+                                       PageRepository::DOKTYPE_SYSFOLDER,
+                                       PageRepository::DOKTYPE_RECYCLER
                                );
                        }
                        if (!in_array($this->pageRow['doktype'], $noViewDokTypes)) {
                                $onClick = htmlspecialchars(BackendUtility::viewOnClick($this->id, $this->backPath, BackendUtility::BEgetRootLine($this->id)));
                                $buttons['view'] = '<a href="#" onclick="' . $onClick . '" title="'
-                                       . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">'
+                                       . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">'
                                        . IconUtility::getSpriteIcon('actions-document-view') . '</a>';
                        }
                        // New record
-                       if (!$GLOBALS['SOBE']->modTSconfig['properties']['noCreateRecordsLink']) {
+                       if (!$module->modTSconfig['properties']['noCreateRecordsLink']) {
                                $onClick = htmlspecialchars(('return jumpExt(\'' . $this->backPath . 'db_new.php?id=' . $this->id . '\');'));
                                $buttons['new_record'] = '<a href="#" onclick="' . $onClick . '" title="'
-                                       . $GLOBALS['LANG']->getLL('newRecordGeneral', TRUE) . '">'
+                                       . $lang->getLL('newRecordGeneral', TRUE) . '">'
                                        . IconUtility::getSpriteIcon('actions-document-new') . '</a>';
                        }
                        // If edit permissions are set, see
@@ -243,7 +250,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                $params = '&edit[pages][' . $this->pageRow['uid'] . ']=edit';
                                $onClick = htmlspecialchars(BackendUtility::editOnClick($params, $this->backPath, -1));
                                $buttons['edit'] = '<a href="#" onclick="' . $onClick . '" title="'
-                                       . $GLOBALS['LANG']->getLL('editPage', TRUE) . '">'
+                                       . $lang->getLL('editPage', TRUE) . '">'
                                        . IconUtility::getSpriteIcon('actions-page-open') . '</a>';
                        }
                        // Paste
@@ -252,39 +259,39 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                if (count($elFromTable)) {
                                        $onClick = htmlspecialchars(('return ' . $this->clipObj->confirmMsg('pages', $this->pageRow, 'into', $elFromTable)));
                                        $buttons['paste'] = '<a href="' . htmlspecialchars($this->clipObj->pasteUrl('', $this->id))
-                                               . '" onclick="' . $onClick . '" title="' . $GLOBALS['LANG']->getLL('clip_paste', TRUE) . '">'
+                                               . '" onclick="' . $onClick . '" title="' . $lang->getLL('clip_paste', TRUE) . '">'
                                                . IconUtility::getSpriteIcon('actions-document-paste-after') . '</a>';
                                }
                        }
                        // Cache
                        $buttons['cache'] = '<a href="' . htmlspecialchars(($this->listURL() . '&clear_cache=1')) . '" title="'
-                               . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.clear_cache', TRUE) . '">'
+                               . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.clear_cache', TRUE) . '">'
                                . IconUtility::getSpriteIcon('actions-system-cache-clear') . '</a>';
                        if (
-                               $this->table && (!isset($GLOBALS['SOBE']->modTSconfig['properties']['noExportRecordsLinks'])
-                               || (isset($GLOBALS['SOBE']->modTSconfig['properties']['noExportRecordsLinks'])
-                                       && !$GLOBALS['SOBE']->modTSconfig['properties']['noExportRecordsLinks']))
+                               $this->table && (!isset($module->modTSconfig['properties']['noExportRecordsLinks'])
+                               || (isset($module->modTSconfig['properties']['noExportRecordsLinks'])
+                                       && !$module->modTSconfig['properties']['noExportRecordsLinks']))
                        ) {
                                // CSV
                                $buttons['csv'] = '<a href="' . htmlspecialchars(($this->listURL() . '&csv=1')) . '" title="'
-                                       . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.csv', TRUE) . '">'
+                                       . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.csv', TRUE) . '">'
                                        . IconUtility::getSpriteIcon('mimetypes-text-csv') . '</a>';
                                // Export
                                if (ExtensionManagementUtility::isLoaded('impexp')) {
                                        $url = BackendUtility::getModuleUrl('xMOD_tximpexp', array('tx_impexp[action]' => 'export'));
                                        $buttons['export'] = '<a href="' . htmlspecialchars($url . '&tx_impexp[list][]='
                                                        . rawurlencode($this->table . ':' . $this->id)) . '" title="'
-                                               . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.export', TRUE) . '">'
+                                               . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.export', TRUE) . '">'
                                                . IconUtility::getSpriteIcon('actions-document-export-t3d') . '</a>';
                                }
                        }
                        // Reload
                        $buttons['reload'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="'
-                               . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.reload', TRUE) . '">'
+                               . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.reload', TRUE) . '">'
                                . IconUtility::getSpriteIcon('actions-system-refresh') . '</a>';
                        // Shortcut
-                       if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
-                               $buttons['shortcut'] = $GLOBALS['TBE_TEMPLATE']->makeShortcutIcon(
+                       if ($backendUser->mayMakeShortcut()) {
+                               $buttons['shortcut'] = $this->getDocumentTemplate()->makeShortcutIcon(
                                        'id, imagemode, pointer, table, search_field, search_levels, showLimit, sortField, sortRev',
                                        implode(',', array_keys($this->MOD_MENU)),
                                        'web_list'
@@ -294,7 +301,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                        if ($this->returnUrl) {
                                $href = htmlspecialchars(GeneralUtility::linkThisUrl($this->returnUrl, array('id' => $this->id)));
                                $buttons['back'] = '<a href="' . $href . '" class="typo3-goBack" title="'
-                                       . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack', TRUE) . '">'
+                                       . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack', TRUE) . '">'
                                        . IconUtility::getSpriteIcon('actions-view-go-back') . '</a>';
                        }
                }
@@ -311,6 +318,9 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
         * @return string HTML table with the listing for the record.
         */
        public function getTable($table, $id, $rowList) {
+               $backendUser = $this->getBackendUserAuthentication();
+               $lang = $this->getLanguageService();
+               $db = $this->getDatabaseConnection();
                // Init
                $addWhere = '';
                $titleCol = $GLOBALS['TCA'][$table]['ctrl']['label'];
@@ -405,17 +415,17 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                $selectFields = array_unique($selectFields);
                $fieldListFields = $this->makeFieldList($table, 1);
                if (empty($fieldListFields) && $GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) {
-                       $message = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:missingTcaColumnsMessage', TRUE), $table, $table);
-                       $messageTitle = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:missingTcaColumnsMessageTitle', TRUE);
+                       $message = sprintf($lang->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:missingTcaColumnsMessage', TRUE), $table, $table);
+                       $messageTitle = $lang->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:missingTcaColumnsMessageTitle', TRUE);
                        $flashMessage = GeneralUtility::makeInstance(
-                               \TYPO3\CMS\Core\Messaging\FlashMessage::class,
+                               FlashMessage::class,
                                $message,
                                $messageTitle,
-                               \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING,
+                               FlashMessage::WARNING,
                                TRUE
                        );
-                       /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
-                       $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
+                       /** @var $flashMessageService FlashMessageService */
+                       $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
                        /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
                        $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
                        $defaultFlashMessageQueue->enqueue($flashMessage);
@@ -428,8 +438,8 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'])) {
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] as $classData) {
                                $hookObject = GeneralUtility::getUserObj($classData);
-                               if (!$hookObject instanceof \TYPO3\CMS\Backend\RecordList\RecordListGetTableHookInterface) {
-                                       throw new \UnexpectedValueException('$hookObject must implement interface ' . \TYPO3\CMS\Backend\RecordList\RecordListGetTableHookInterface::class, 1195114460);
+                               if (!$hookObject instanceof RecordListGetTableHookInterface) {
+                                       throw new \UnexpectedValueException('$hookObject must implement interface ' . RecordListGetTableHookInterface::class, 1195114460);
                                }
                                $hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
                        }
@@ -475,13 +485,13 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                        $this->showLimit = $this->totalItems;
                                        $this->iLimit = $this->totalItems;
                                }
-                               $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
-                               $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
+                               $result = $db->exec_SELECT_queryArray($queryParts);
+                               $dbCount = $db->sql_num_rows($result);
                        }
                }
                // If any records was selected, render the list:
                if ($dbCount) {
-                       $tableTitle = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title'], TRUE);
+                       $tableTitle = $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title'], TRUE);
                        if ($tableTitle === '') {
                                $tableTitle = $table;
                        }
@@ -492,8 +502,8 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                        . '</span> (<span class="t3js-table-total-items">' . $this->totalItems . '</span>)';
                        } else {
                                $icon = $this->table
-                                       ? IconUtility::getSpriteIcon('actions-view-table-collapse', array('title' => $GLOBALS['LANG']->getLL('contractView', TRUE)))
-                                       : IconUtility::getSpriteIcon('actions-view-table-expand', array('title' => $GLOBALS['LANG']->getLL('expandView', TRUE)));
+                                       ? IconUtility::getSpriteIcon('actions-view-table-collapse', array('title' => $lang->getLL('contractView', TRUE)))
+                                       : IconUtility::getSpriteIcon('actions-view-table-expand', array('title' => $lang->getLL('expandView', TRUE)));
                                $theData[$titleCol] = $this->linkWrapTable($table, $tableTitle . ' (<span class="t3js-table-total-items">' . $this->totalItems . '</span>) ' . $icon);
                        }
                        if ($listOnlyInSingleTableMode) {
@@ -504,8 +514,8 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                if (!$this->table) {
                                        $href = htmlspecialchars(($this->listURL() . '&collapse[' . $table . ']=' . ($tableCollapsed ? '0' : '1')));
                                        $title = $tableCollapsed
-                                               ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.expandTable', TRUE)
-                                               : $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.collapseTable', TRUE);
+                                               ? $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.expandTable', TRUE)
+                                               : $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.collapseTable', TRUE);
                                        $icon = $tableCollapsed
                                                ? IconUtility::getSpriteIcon('actions-view-list-expand', array('class' => 'collapseIcon'))
                                                : IconUtility::getSpriteIcon('actions-view-list-collapse', array('class' => 'collapseIcon'));
@@ -515,7 +525,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                        }
                        // Render table rows only if in multi table view and not collapsed or if in
                        // single table view
-                       $iOut = '';
+                       $rowOutput = '';
                        if (!$listOnlyInSingleTableMode && (!$tableCollapsed || $this->table)) {
                                // Fixing a order table for sortby tables
                                $this->currentTable = array();
@@ -525,19 +535,19 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                $prevPrevUid = 0;
                                // Get first two rows and initialize prevPrevUid and prevUid if on page > 1
                                if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
-                                       $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
+                                       $row = $db->sql_fetch_assoc($result);
                                        $prevPrevUid = -((int)$row['uid']);
-                                       $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
+                                       $row = $db->sql_fetch_assoc($result);
                                        $prevUid = $row['uid'];
                                }
                                $accRows = array();
                                // Accumulate rows here
-                               while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
+                               while ($row = $db->sql_fetch_assoc($result)) {
                                        if (!$this->isRowListingConditionFulfilled($table, $row)) {
                                                continue;
                                        }
                                        // In offline workspace, look for alternative record:
-                                       BackendUtility::workspaceOL($table, $row, $GLOBALS['BE_USER']->workspace, TRUE);
+                                       BackendUtility::workspaceOL($table, $row, $backendUser->workspace, TRUE);
                                        if (is_array($row)) {
                                                $accRows[] = $row;
                                                $currentIdList[] = $row['uid'];
@@ -552,7 +562,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                                }
                                        }
                                }
-                               $GLOBALS['TYPO3_DB']->sql_free_result($result);
+                               $db->sql_free_result($result);
                                $this->totalRowCount = count($accRows);
                                // CSV initiated
                                if ($this->csvOutput) {
@@ -568,7 +578,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                        if ($cc < $this->iLimit) {
                                                $cc++;
                                                $this->translations = FALSE;
-                                               $iOut .= $this->renderListRow($table, $row, $cc, $titleCol, $thumbsCol);
+                                               $rowOutput .= $this->renderListRow($table, $row, $cc, $titleCol, $thumbsCol);
                                                // If localization view is enabled it means that the selected records are
                                                // either default or All language and here we will not select translations
                                                // which point to the main record:
@@ -585,10 +595,10 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                                                                $lRow = is_array($tmpRow) ? $tmpRow : $lRow;
                                                                        }
                                                                        // In offline workspace, look for alternative record:
-                                                                       BackendUtility::workspaceOL($table, $lRow, $GLOBALS['BE_USER']->workspace, TRUE);
-                                                                       if (is_array($lRow) && $GLOBALS['BE_USER']->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
+                                                                       BackendUtility::workspaceOL($table, $lRow, $backendUser->workspace, TRUE);
+                                                                       if (is_array($lRow) && $backendUser->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
                                                                                $currentIdList[] = $lRow['uid'];
-                                                                               $iOut .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 18);
+                                                                               $rowOutput .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 18);
                                                                        }
                                                                }
                                                        }
@@ -600,14 +610,14 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                // Record navigation is added to the beginning and end of the table if in single
                                // table mode
                                if ($this->table) {
-                                       $iOut = $this->renderListNavigation('top') . $iOut . $this->renderListNavigation('bottom');
+                                       $rowOutput = $this->renderListNavigation('top') . $rowOutput . $this->renderListNavigation('bottom');
                                } else {
                                        // Show that there are more records than shown
                                        if ($this->totalItems > $this->itemsLimitPerTable) {
                                                $countOnFirstPage = $this->totalItems > $this->itemsLimitSingleTable ? $this->itemsLimitSingleTable : $this->totalItems;
                                                $hasMore = $this->totalItems > $this->itemsLimitSingleTable;
                                                $colspan = $this->showIcon ? count($this->fieldArray) + 1 : count($this->fieldArray);
-                                               $iOut .= '<tr><td colspan="' . $colspan . '">
+                                               $rowOutput .= '<tr><td colspan="' . $colspan . '">
                                                                <a href="' . htmlspecialchars(($this->listURL() . '&table=' . rawurlencode($table))) . '">'
                                                        . '<img' . IconUtility::skinImg($this->backPath, 'gfx/pildown.gif', 'width="14" height="14"') . ' alt="" />'
                                                        . ' <i>[1 - ' . $countOnFirstPage . ($hasMore ? '+' : '') . ']</i></a>
@@ -618,7 +628,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                $out .= $this->renderListHeader($table, $currentIdList);
                        }
                        // The list of records is added after the header:
-                       $out .= $iOut;
+                       $out .= $rowOutput;
                        // ... and it is all wrapped in a table:
                        $out = '
 
@@ -654,7 +664,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
         * This function serves as a dummy method to be overriden in extending classes.
         *
         * @param string $table Table name
-        * @param array $row Record
+        * @param string[] $row Record
         * @return bool True, if all conditions are fulfilled.
         */
        protected function isRowListingConditionFulfilled($table, $row) {
@@ -665,7 +675,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
         * Rendering a single row for the list
         *
         * @param string $table Table name
-        * @param array $row Current record
+        * @param mixed[] $row Current record
         * @param int $cc Counter, counting for each time an element is rendered (used for alternating colors)
         * @param string $titleCol Table field (column) where header value is found
         * @param string $thumbsCol Table field (column) where (possible) thumbnails can be found
@@ -675,129 +685,130 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
         * @see getTable()
         */
        public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0) {
-               $iOut = '';
+               if (!is_array($row)) {
+                       return '';
+               }
+               $rowOutput = '';
                $id_orig = NULL;
                // If in search mode, make sure the preview will show the correct page
                if ((string)$this->searchString !== '') {
                        $id_orig = $this->id;
                        $this->id = $row['pid'];
                }
-               if (is_array($row)) {
-                       // Add special classes for first and last row
-                       $rowSpecial = '';
-                       if ($cc == 1 && $indent == 0) {
-                               $rowSpecial .= ' firstcol';
-                       }
-                       if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
-                               $rowSpecial .= ' lastcol';
-                       }
+               // Add special classes for first and last row
+               $rowSpecial = '';
+               if ($cc == 1 && $indent == 0) {
+                       $rowSpecial .= ' firstcol';
+               }
+               if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
+                       $rowSpecial .= ' lastcol';
+               }
 
-                       $row_bgColor = ' class="' . $rowSpecial . '"';
-
-                       // Overriding with versions background color if any:
-                       $row_bgColor = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : $row_bgColor;
-                       // Incr. counter.
-                       $this->counter++;
-                       // The icon with link
-                       $altText = htmlspecialchars(BackendUtility::getRecordIconAltText($row, $table));
-                       $iconImg = IconUtility::getSpriteIconForRecord(
-                               $table,
-                               $row,
-                               array('title' => $altText, 'style' => $indent ? ' margin-left: ' . $indent . 'px;' : '')
-                       );
-                       $theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
-                       // Preparing and getting the data-array
-                       $theData = array();
-                       $localizationMarkerClass = '';
-                       foreach ($this->fieldArray as $fCol) {
-                               if ($fCol == $titleCol) {
-                                       $recTitle = BackendUtility::getRecordTitle($table, $row, FALSE, TRUE);
-                                       $warning = '';
-                                       // If the record is edit-locked by another user, we will show a little warning sign:
-                                       if ($lockInfo = BackendUtility::isRecordLocked($table, $row['uid'])) {
-                                               $warning = '<a href="#" onclick="alert('
-                                                       . GeneralUtility::quoteJSvalue($lockInfo['msg']) . '); return false;" title="'
-                                                       . htmlspecialchars($lockInfo['msg']) . '">'
-                                                       . IconUtility::getSpriteIcon('status-warning-in-use') . '</a>';
-                                       }
-                                       $theData[$fCol] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
-                                       // Render thumbnails, if:
-                                       // - a thumbnail column exists
-                                       // - there is content in it
-                                       // - the thumbnail column is visible for the current type
-                                       $type = 0;
-                                       if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) {
-                                               $typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type'];
-                                               $type = $row[$typeColumn];
-                                       }
-                                       // If current type doesn't exist, set it to 0 (or to 1 for historical reasons,
-                                       // if 0 doesn't exist)
-                                       if (!isset($GLOBALS['TCA'][$table]['types'][$type])) {
-                                               $type = isset($GLOBALS['TCA'][$table]['types'][0]) ? 0 : 1;
-                                       }
-                                       $visibleColumns = $GLOBALS['TCA'][$table]['types'][$type]['showitem'];
+               $row_bgColor = ' class="' . $rowSpecial . '"';
+
+               // Overriding with versions background color if any:
+               $row_bgColor = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : $row_bgColor;
+               // Incr. counter.
+               $this->counter++;
+               // The icon with link
+               $altText = htmlspecialchars(BackendUtility::getRecordIconAltText($row, $table));
+               $iconImg = IconUtility::getSpriteIconForRecord(
+                       $table,
+                       $row,
+                       array('title' => $altText, 'style' => $indent ? ' margin-left: ' . $indent . 'px;' : '')
+               );
+               $theIcon = $this->clickMenuEnabled ? $this->getModule()->doc->wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
+               // Preparing and getting the data-array
+               $theData = array();
+               $localizationMarkerClass = '';
+               foreach ($this->fieldArray as $fCol) {
+                       if ($fCol == $titleCol) {
+                               $recTitle = BackendUtility::getRecordTitle($table, $row, FALSE, TRUE);
+                               $warning = '';
+                               // If the record is edit-locked by another user, we will show a little warning sign:
+                               if ($lockInfo = BackendUtility::isRecordLocked($table, $row['uid'])) {
+                                       $warning = '<a href="#" onclick="alert('
+                                               . GeneralUtility::quoteJSvalue($lockInfo['msg']) . '); return false;" title="'
+                                               . htmlspecialchars($lockInfo['msg']) . '">'
+                                               . IconUtility::getSpriteIcon('status-warning-in-use') . '</a>';
+                               }
+                               $theData[$fCol] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
+                               // Render thumbnails, if:
+                               // - a thumbnail column exists
+                               // - there is content in it
+                               // - the thumbnail column is visible for the current type
+                               $type = 0;
+                               if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) {
+                                       $typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type'];
+                                       $type = $row[$typeColumn];
+                               }
+                               // If current type doesn't exist, set it to 0 (or to 1 for historical reasons,
+                               // if 0 doesn't exist)
+                               if (!isset($GLOBALS['TCA'][$table]['types'][$type])) {
+                                       $type = isset($GLOBALS['TCA'][$table]['types'][0]) ? 0 : 1;
+                               }
+                               $visibleColumns = $GLOBALS['TCA'][$table]['types'][$type]['showitem'];
 
-                                       if ($this->thumbs &&
-                                               trim($row[$thumbsCol]) &&
-                                               preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1
-                                       ) {
-                                               $theData[$fCol] .= '<br />' . $this->thumbCode($row, $table, $thumbsCol);
-                                       }
-                                       if (
-                                               isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
-                                               && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0
-                                               && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0
-                                       ) {
-                                               // It's a translated record with a language parent
-                                               $localizationMarkerClass = ' localization';
-                                       }
-                               } elseif ($fCol == 'pid') {
-                                       $theData[$fCol] = $row[$fCol];
-                               } elseif ($fCol == '_PATH_') {
-                                       $theData[$fCol] = $this->recPath($row['pid']);
-                               } elseif ($fCol == '_REF_') {
-                                       $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
-                               } elseif ($fCol == '_CONTROL_') {
-                                       $theData[$fCol] = $this->makeControl($table, $row);
-                               } elseif ($fCol == '_CLIPBOARD_') {
-                                       $theData[$fCol] = $this->makeClip($table, $row);
-                               } elseif ($fCol == '_LOCALIZATION_') {
-                                       list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
-                                       $theData[$fCol] = $lC1;
-                                       $theData[$fCol . 'b'] = $lC2;
-                               } elseif ($fCol == '_LOCALIZATION_b') {
-                                       // deliberately empty
-                               } else {
-                                       $tmpProc = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid']);
-                                       $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
-                                       if ($this->csvOutput) {
-                                               $row[$fCol] = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
-                                       }
+                               if ($this->thumbs &&
+                                       trim($row[$thumbsCol]) &&
+                                       preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1
+                               ) {
+                                       $theData[$fCol] .= '<br />' . $this->thumbCode($row, $table, $thumbsCol);
+                               }
+                               if (
+                                       isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
+                                       && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0
+                                       && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0
+                               ) {
+                                       // It's a translated record with a language parent
+                                       $localizationMarkerClass = ' localization';
+                               }
+                       } elseif ($fCol == 'pid') {
+                               $theData[$fCol] = $row[$fCol];
+                       } elseif ($fCol == '_PATH_') {
+                               $theData[$fCol] = $this->recPath($row['pid']);
+                       } elseif ($fCol == '_REF_') {
+                               $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
+                       } elseif ($fCol == '_CONTROL_') {
+                               $theData[$fCol] = $this->makeControl($table, $row);
+                       } elseif ($fCol == '_CLIPBOARD_') {
+                               $theData[$fCol] = $this->makeClip($table, $row);
+                       } elseif ($fCol == '_LOCALIZATION_') {
+                               list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
+                               $theData[$fCol] = $lC1;
+                               $theData[$fCol . 'b'] = $lC2;
+                       } elseif ($fCol == '_LOCALIZATION_b') {
+                               // deliberately empty
+                       } else {
+                               $tmpProc = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid']);
+                               $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
+                               if ($this->csvOutput) {
+                                       $row[$fCol] = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
                                }
                        }
-                       // Reset the ID if it was overwritten
-                       if ((string)$this->searchString !== '') {
-                               $this->id = $id_orig;
-                       }
-                       // Add row to CSV list:
-                       if ($this->csvOutput) {
-                               $this->addToCSV($row, $table);
-                       }
-                       // Add classes to table cells
-                       $this->addElement_tdCssClass[$titleCol] = 'col-title' . $localizationMarkerClass;
-                       if (!$this->dontShowClipControlPanels) {
-                               $this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
-                               $this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard';
-                       }
-                       $this->addElement_tdCssClass['_PATH_'] = 'col-path';
-                       $this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa';
-                       $this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
-                       // Create element in table cells:
-                       $theData['uid'] = $row['uid'];
-                       $iOut .= $this->addelement(1, $theIcon, $theData, $row_bgColor);
-                       // Finally, return table row element:
-                       return $iOut;
                }
+               // Reset the ID if it was overwritten
+               if ((string)$this->searchString !== '') {
+                       $this->id = $id_orig;
+               }
+               // Add row to CSV list:
+               if ($this->csvOutput) {
+                       $this->addToCSV($row, $table);
+               }
+               // Add classes to table cells
+               $this->addElement_tdCssClass[$titleCol] = 'col-title' . $localizationMarkerClass;
+               if (!$this->dontShowClipControlPanels) {
+                       $this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
+                       $this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard';
+               }
+               $this->addElement_tdCssClass['_PATH_'] = 'col-path';
+               $this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa';
+               $this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
+               // Create element in table cells:
+               $theData['uid'] = $row['uid'];
+               $rowOutput .= $this->addelement(1, $theIcon, $theData, $row_bgColor);
+               // Finally, return table row element:
+               return $rowOutput;
        }
 
        /**
@@ -809,10 +820,11 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
         * @return int The number of references to record $uid in table
         */
        protected function getReferenceCount($tableName, $uid) {
+               $db = $this->getDatabaseConnection();
                if (!isset($this->referenceCount[$tableName][$uid])) {
-                       $where = 'ref_table = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($tableName, 'sys_refindex')
+                       $where = 'ref_table = ' . $db->fullQuoteStr($tableName, 'sys_refindex')
                                . ' AND ref_uid = ' . $uid . ' AND deleted = 0';
-                       $numberOfReferences = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'sys_refindex', $where);
+                       $numberOfReferences = $db->exec_SELECTcountRows('*', 'sys_refindex', $where);
                        $this->referenceCount[$tableName][$uid] = $numberOfReferences;
                }
                return $this->referenceCount[$tableName][$uid];
@@ -822,13 +834,14 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
         * Rendering the header row for a table
         *
         * @param string $table Table name
-        * @param array $currentIdList Array of the currently displayed uids of the table
+        * @param int[] $currentIdList Array of the currently displayed uids of the table
         * @throws \UnexpectedValueException
         * @return string Header table row
         * @access private
         * @see getTable()
         */
        public function renderListHeader($table, $currentIdList) {
+               $lang = $this->getLanguageService();
                // Init:
                $theData = array();
                $icon = '';
@@ -839,19 +852,19 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                        switch ((string)$fCol) {
                                case '_PATH_':
                                        // Path
-                                       $theData[$fCol] = '<i>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels._PATH_', TRUE) . ']</i>';
+                                       $theData[$fCol] = '<i>[' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels._PATH_', TRUE) . ']</i>';
                                        break;
                                case '_REF_':
                                        // References
-                                       $theData[$fCol] = '<i>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:c__REF_', TRUE) . ']</i>';
+                                       $theData[$fCol] = '<i>[' . $lang->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:c__REF_', TRUE) . ']</i>';
                                        break;
                                case '_LOCALIZATION_':
                                        // Path
-                                       $theData[$fCol] = '<i>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels._LOCALIZATION_', TRUE) . ']</i>';
+                                       $theData[$fCol] = '<i>[' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels._LOCALIZATION_', TRUE) . ']</i>';
                                        break;
                                case '_LOCALIZATION_b':
                                        // Path
-                                       $theData[$fCol] = $GLOBALS['LANG']->getLL('Localize', TRUE);
+                                       $theData[$fCol] = $lang->getLL('Localize', TRUE);
                                        break;
                                case '_CLIPBOARD_':
                                        // Clipboard:
@@ -863,13 +876,13 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                                $href = htmlspecialchars($this->clipObj->pasteUrl($table, $this->id));
                                                $onClick = htmlspecialchars('return ' . $this->clipObj->confirmMsg('pages', $this->pageRow, 'into', $elFromTable));
                                                $cells['pasteAfter'] = '<a class="btn" href="' . $href . '" onclick="' . $onClick
-                                                       . '" title="' . $GLOBALS['LANG']->getLL('clip_paste', TRUE) . '">'
+                                                       . '" title="' . $lang->getLL('clip_paste', TRUE) . '">'
                                                        . IconUtility::getSpriteIcon('actions-document-paste-after') . '</a>';
                                        }
                                        // If the numeric clipboard pads are enabled, display the control icons for that:
                                        if ($this->clipObj->current != 'normal') {
                                                // The "select" link:
-                                               $spriteIcon = IconUtility::getSpriteIcon('actions-edit-copy', array('title' => $GLOBALS['LANG']->getLL('clip_selectMarked', TRUE)));
+                                               $spriteIcon = IconUtility::getSpriteIcon('actions-edit-copy', array('title' => $lang->getLL('clip_selectMarked', TRUE)));
                                                $cells['copyMarked'] = $this->linkClipboardHeaderIcon($spriteIcon, $table, 'setCB');
                                                // The "edit marked" link:
                                                $editIdList = implode(',', $currentIdList);
@@ -877,19 +890,19 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                                $params = '&edit[' . $table . '][' . $editIdList . ']=edit&disHelp=1';
                                                $onClick = htmlspecialchars(BackendUtility::editOnClick($params, $this->backPath, -1));
                                                $cells['edit'] = '<a class="btn" href="#" onclick="' . $onClick . '" title="'
-                                                       . $GLOBALS['LANG']->getLL('clip_editMarked', TRUE) . '">'
+                                                       . $lang->getLL('clip_editMarked', TRUE) . '">'
                                                        . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
                                                // The "Delete marked" link:
                                                $cells['delete'] = $this->linkClipboardHeaderIcon(
-                                                       IconUtility::getSpriteIcon('actions-edit-delete', array('title' => $GLOBALS['LANG']->getLL('clip_deleteMarked', TRUE))),
+                                                       IconUtility::getSpriteIcon('actions-edit-delete', array('title' => $lang->getLL('clip_deleteMarked', TRUE))),
                                                        $table,
                                                        'delete',
-                                                       sprintf($GLOBALS['LANG']->getLL('clip_deleteMarkedWarning'), $GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title']))
+                                                       sprintf($lang->getLL('clip_deleteMarkedWarning'), $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']))
                                                );
                                                // The "Select all" link:
                                                $onClick = htmlspecialchars(('checkOffCB(\'' . implode(',', $this->CBnames) . '\', this); return false;'));
                                                $cells['markAll'] = '<a class="btn" rel="" href="#" onclick="' . $onClick . '" title="'
-                                                       . $GLOBALS['LANG']->getLL('clip_markRecords', TRUE) . '">'
+                                                       . $lang->getLL('clip_markRecords', TRUE) . '">'
                                                        . IconUtility::getSpriteIcon('actions-document-select') . '</a>';
                                        } else {
                                                $cells['empty'] = '';
@@ -904,8 +917,8 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
                                                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
                                                        $hookObject = GeneralUtility::getUserObj($classData);
-                                                       if (!$hookObject instanceof \TYPO3\CMS\Recordlist\RecordList\RecordListHookInterface) {
-                                                               throw new \UnexpectedValueException('$hookObject must implement interface ' . \TYPO3\CMS\Recordlist\RecordList\RecordListHookInterface::class, 1195567850);
+                                                       if (!$hookObject instanceof RecordListHookInterface) {
+                                                               throw new \UnexpectedValueException('$hookObject must implement interface ' . RecordListHookInterface::class, 1195567850);
                                                        }
                                                        $cells = $hookObject->renderListHeaderActions($table, $currentIdList, $cells, $this);
                                                }
@@ -930,11 +943,11 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
 
                                                                $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue($newContentWizScriptPath) . ');';
                                                                $icon = '<a class="btn btn-success" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
-                                                                       . $GLOBALS['LANG']->getLL('new', TRUE) . '">' . $spriteIcon . '</a>';
+                                                                       . $lang->getLL('new', TRUE) . '">' . $spriteIcon . '</a>';
                                                        } elseif ($table == 'pages' && $this->newWizards) {
                                                                $href = $this->backPath . 'db_new.php?id=' . $this->id
                                                                        . '&pagesOnly=1&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'));
-                                                               $icon = '<a class="btn success" href="' . htmlspecialchars($href) . '" title="' . $GLOBALS['LANG']->getLL('new', TRUE) . '">'
+                                                               $icon = '<a class="btn success" href="' . htmlspecialchars($href) . '" title="' . $lang->getLL('new', TRUE) . '">'
                                                                        . $spriteIcon . '</a>';
                                                        } else {
                                                                $params = '&edit[' . $table . '][' . $this->id . ']=new';
@@ -942,7 +955,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                                                        $params .= '&overrideVals[pages_language_overlay][doktype]=' . (int)$this->pageRow['doktype'];
                                                                }
                                                                $icon = '<a class="btn btn-success" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $this->backPath, -1))
-                                                                       . '" title="' . $GLOBALS['LANG']->getLL('new', TRUE) . '">' . $spriteIcon . '</a>';
+                                                                       . '" title="' . $lang->getLL('new', TRUE) . '">' . $spriteIcon . '</a>';
                                                        }
                                                }
                                                // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
@@ -953,7 +966,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                                        }
                                                        $params = '&edit[' . $table . '][' . $editIdList . ']=edit&columnsOnly=' . implode(',', $this->fieldArray) . '&disHelp=1';
                                                        $icon .= '<a class="btn" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $this->backPath, -1))
-                                                               . '" title="' . $GLOBALS['LANG']->getLL('editShownColumns', TRUE) . '">'
+                                                               . '" title="' . $lang->getLL('editShownColumns', TRUE) . '">'
                                                                . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
                                                        $icon = '<div class="btn-group">' . $icon . '</div>';
                                                }
@@ -969,7 +982,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                        // at the end
                                        $sortLabel = BackendUtility::getItemLabel($table, $fCol);
                                        if ($sortLabel !== NULL) {
-                                               $sortLabel = $GLOBALS['LANG']->sL($sortLabel, TRUE);
+                                               $sortLabel = $lang->sL($sortLabel, TRUE);
                                                $sortLabel = rtrim(trim($sortLabel), ':');
                                        } else {
                                                // No TCA field, only output the $fCol variable with square brackets []
@@ -981,7 +994,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                                // If the numeric clipboard pads are selected, show duplicate sorting link:
                                                if ($this->clipNumPane()) {
                                                        $theData[$fCol] .= '<a class="btn" href="' . htmlspecialchars($this->listURL('', -1) . '&duplicateField=' . $fCol)
-                                                               . '" title="' . $GLOBALS['LANG']->getLL('clip_duplicates', TRUE) . '">'
+                                                               . '" title="' . $lang->getLL('clip_duplicates', TRUE) . '">'
                                                                . IconUtility::getSpriteIcon('actions-document-duplicates-select') . '</a>';
                                                }
                                                // If the table can be edited, add link for editing THIS field for all
@@ -992,7 +1005,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                                                $editIdList = '\'+editList(\'' . $table . '\',\'' . $editIdList . '\')+\'';
                                                        }
                                                        $params = '&edit[' . $table . '][' . $editIdList . ']=edit&columnsOnly=' . $fCol . '&disHelp=1';
-                                                       $iTitle = sprintf($GLOBALS['LANG']->getLL('editThisColumn'), $sortLabel);
+                                                       $iTitle = sprintf($lang->getLL('editThisColumn'), $sortLabel);
                                                        $theData[$fCol] .= '<a class="btn" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $this->backPath, -1))
                                                                . '" title="' . htmlspecialchars($iTitle) . '">'
                                                                . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
@@ -1013,8 +1026,8 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
                                $hookObject = GeneralUtility::getUserObj($classData);
-                               if (!$hookObject instanceof \TYPO3\CMS\Recordlist\RecordList\RecordListHookInterface) {
-                                       throw new \UnexpectedValueException('$hookObject must implement interface ' . \TYPO3\CMS\Recordlist\RecordList\RecordListHookInterface::class, 1195567855);
+                               if (!$hookObject instanceof RecordListHookInterface) {
+                                       throw new \UnexpectedValueException('$hookObject must implement interface ' . RecordListHookInterface::class, 1195567855);
                                }
                                $theData = $hookObject->renderListHeader($table, $currentIdList, $theData, $this);
                        }
@@ -1047,14 +1060,15 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                if ($totalPages <= 1) {
                        return '';
                }
+               $content = '';
                $listURL = $this->listURL('', $this->table);
                // 1 = first page
                // 0 = first element
                $currentPage = floor($this->firstElementNumber / $this->iLimit) + 1;
                // Compile first, previous, next, last and refresh buttons
                if ($currentPage > 1) {
-                       $labelFirst = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:first');
-                       $labelPrevious = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:previous');
+                       $labelFirst = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:first');
+                       $labelPrevious = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:previous');
                        $first = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage(1) . '">'
                                . IconUtility::getSpriteIcon('actions-view-paging-first', array('title' => $labelFirst)) . '</a></li>';
                        $previous = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage - 1) . '">'
@@ -1064,8 +1078,8 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                        $previous = '<li class="disabled"><span>' . IconUtility::getSpriteIcon('actions-view-paging-previous') . '</span></li>';
                }
                if ($currentPage < $totalPages) {
-                       $labelNext = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:next');
-                       $labelLast = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:last');
+                       $labelNext = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:next');
+                       $labelLast = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:last');
                        $next = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage + 1) . '">'
                                . IconUtility::getSpriteIcon('actions-view-paging-next', array('title' => $labelNext)) . '</a></li>';
                        $last = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($totalPages) . '">'
@@ -1077,7 +1091,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                $reload = '<li><a href="#" onclick="document.dblistForm.action=\'' . $listURL
                        . '&pointer=\'+calculatePointer(document.getElementById(\'jumpPage-' . $renderPart
                        . '\').value); document.dblistForm.submit(); return true;" title="'
-                       . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:reload', TRUE) . '">'
+                       . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:reload', TRUE) . '">'
                        . IconUtility::getSpriteIcon('actions-system-refresh') . '</a></li>';
                if ($renderPart === 'top') {
                        // Add js to traverse a page select input to a pointer value
@@ -1103,7 +1117,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                        . '&pointer=\'+calculatePointer(this.value); document.dblistForm.submit(); } return true;" />
                        ';
                $pageIndicatorText = sprintf(
-                       $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:pageIndicator'),
+                       $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:pageIndicator'),
                        $pageNumberInput,
                        $totalPages
                );
@@ -1113,7 +1127,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                } else {
                        $lastElementNumber = $this->totalItems;
                }
-               $rangeIndicator = '<li><span>' . sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:rangeIndicator'), ($this->firstElementNumber + 1), $lastElementNumber) . '</span></li>';
+               $rangeIndicator = '<li><span>' . sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:rangeIndicator'), ($this->firstElementNumber + 1), $lastElementNumber) . '</span></li>';
 
                $titleColumn = $this->fieldArray[0];
                $data = array(
@@ -1144,7 +1158,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
         * Creates the control panel for a single record in the listing.
         *
         * @param string $table The table
-        * @param array $row The record for which to make the control panel.
+        * @param mixed[] $row The record for which to make the control panel.
         * @throws \UnexpectedValueException
         * @return string HTML table with the control panel (unless disabled)
         */
@@ -1152,6 +1166,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                if ($this->dontShowClipControlPanels) {
                        return '';
                }
+               $module = $this->getModule();
                $rowUid = $row['uid'];
                if (ExtensionManagementUtility::isLoaded('version') && isset($row['_ORIG_uid'])) {
                        $rowUid = $row['_ORIG_uid'];
@@ -1160,7 +1175,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                // If the listed table is 'pages' we have to request the permission settings for each page:
                $localCalcPerms = 0;
                if ($table == 'pages') {
-                       $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(BackendUtility::getRecord('pages', $row['uid']));
+                       $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', $row['uid']));
                }
                // This expresses the edit permissions for this particular element:
                $permsEdit = $table == 'pages' && $localCalcPerms & 2 || $table != 'pages' && $this->calcPerms & 16;
@@ -1174,7 +1189,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                                '',
                                                ($table === 'tt_content' ? '#' . $row['uid'] : '')
                                        )
-                               ) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">'
+                               ) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">'
                                . IconUtility::getSpriteIcon('actions-document-view') . '</a>';
                }
                // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
@@ -1184,22 +1199,22 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                ? IconUtility::getSpriteIcon('actions-document-open-read-only')
                                : IconUtility::getSpriteIcon('actions-document-open');
                        $cells['edit'] = '<a class="btn" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $this->backPath, -1))
-                               . '" title="' . $GLOBALS['LANG']->getLL('edit', TRUE) . '">' . $spriteIcon . '</a>';
+                               . '" title="' . $this->getLanguageService()->getLL('edit', TRUE) . '">' . $spriteIcon . '</a>';
                }
                // "Move" wizard link for pages/tt_content elements:
                if ($table == 'tt_content' && $permsEdit || $table == 'pages') {
                        $onClick = 'return jumpExt(\'' . $this->backPath . 'move_el.php?table=' . $table . '&uid=' . $row['uid'] . '\');';
-                       $linkTitleLL = $GLOBALS['LANG']->getLL('move_' . ($table === 'tt_content' ? 'record' : 'page'), TRUE);
+                       $linkTitleLL = $this->getLanguageService()->getLL('move_' . ($table === 'tt_content' ? 'record' : 'page'), TRUE);
                        $spriteIcon = $table === 'tt_content'
                                ? IconUtility::getSpriteIcon('actions-document-move')
                                : IconUtility::getSpriteIcon('actions-page-move');
                        $cells['move'] = '<a class="btn" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $linkTitleLL . '">' . $spriteIcon . '</a>';
                }
                // If the extended control panel is enabled OR if we are seeing a single table:
-               if ($GLOBALS['SOBE']->MOD_SETTINGS['bigControlPanel'] || $this->table) {
+               if ($module->MOD_SETTINGS['bigControlPanel'] || $this->table) {
                        // "Info": (All records)
                        $onClick = 'top.launchView(\'' . $table . '\', \'' . $row['uid'] . '\'); return false;';
-                       $cells['viewBig'] = '<a class="btn" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $GLOBALS['LANG']->getLL('showInfo', TRUE) . '">'
+                       $cells['viewBig'] = '<a class="btn" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $this->getLanguageService()->getLL('showInfo', TRUE) . '">'
                                . IconUtility::getSpriteIcon('actions-document-info') . '</a>';
                        // If the table is NOT a read-only table, then show these links:
                        if (!$GLOBALS['TCA'][$table]['ctrl']['readOnly']) {
@@ -1207,11 +1222,11 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                $moduleUrl = BackendUtility::getModuleUrl('record_history', array('element' => $table . ':' . $row['uid']));
                                $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue($this->backPath . $moduleUrl) . ',\'#latest\');';
                                $cells['history'] = '<a class="btn" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
-                                       . $GLOBALS['LANG']->getLL('history', TRUE) . '">'
+                                       . $this->getLanguageService()->getLL('history', TRUE) . '">'
                                        . IconUtility::getSpriteIcon('actions-document-history-open') . '</a>';
                                // Versioning:
                                if (ExtensionManagementUtility::isLoaded('version') && !ExtensionManagementUtility::isLoaded('workspaces')) {
-                                       $vers = BackendUtility::selectVersionsOfRecord($table, $row['uid'], 'uid', $GLOBALS['BE_USER']->workspace, FALSE, $row);
+                                       $vers = BackendUtility::selectVersionsOfRecord($table, $row['uid'], 'uid', $this->getBackendUserAuthentication()->workspace, FALSE, $row);
                                        // If table can be versionized.
                                        if (is_array($vers)) {
                                                $versionIcon = 'no-version';
@@ -1222,15 +1237,15 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                                        'table' => $table, 'uid' => $row['uid']
                                                ));
                                                $cells['version'] = '<a class="btn" href="' . htmlspecialchars($href) . '" title="'
-                                                       . $GLOBALS['LANG']->getLL('displayVersions', TRUE) . '">'
+                                                       . $this->getLanguageService()->getLL('displayVersions', TRUE) . '">'
                                                        . IconUtility::getSpriteIcon(('status-version-' . $versionIcon)) . '</a>';
                                        }
                                }
                                // "Edit Perms" link:
-                               if ($table === 'pages' && $GLOBALS['BE_USER']->check('modules', 'system_BeuserTxPermission') && ExtensionManagementUtility::isLoaded('beuser')) {
+                               if ($table === 'pages' && $this->getBackendUserAuthentication()->check('modules', 'system_BeuserTxPermission') && ExtensionManagementUtility::isLoaded('beuser')) {
                                        $href = BackendUtility::getModuleUrl('system_BeuserTxPermission') . '&id=' . $row['uid'] . '&return_id=' . $row['uid'] . '&edit=1';
                                        $cells['perms'] = '<a class="btn" href="' . htmlspecialchars($href) . '" title="'
-                                               . $GLOBALS['LANG']->getLL('permissions', TRUE) . '">'
+                                               . $this->getLanguageService()->getLL('permissions', TRUE) . '">'
                                                . IconUtility::getSpriteIcon('status-status-locked') . '</a>';
                                }
                                // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row
@@ -1240,7 +1255,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                                if ($this->showNewRecLink($table)) {
                                                        $params = '&edit[' . $table . '][' . -($row['_MOVE_PLH'] ? $row['_MOVE_PLH_uid'] : $row['uid']) . ']=new';
                                                        $cells['new'] = '<a class="btn" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $this->backPath, -1))
-                                                               . '" title="' . $GLOBALS['LANG']->getLL('new' . ($table == 'pages ' ? 'Page' : 'Record'), TRUE) . '">'
+                                                               . '" title="' . $this->getLanguageService()->getLL('new' . ($table == 'pages ' ? 'Page' : 'Record'), TRUE) . '">'
                                                                . ($table == 'pages' ? IconUtility::getSpriteIcon('actions-page-new') : IconUtility::getSpriteIcon('actions-document-new')) . '</a>';
                                                }
                                        }
@@ -1251,8 +1266,8 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                                // Up
                                                $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prev'][$row['uid']];
                                                $cells['moveUp'] = '<a class="btn" href="#" onclick="'
-                                                       . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');')
-                                                       . '" title="' . $GLOBALS['LANG']->getLL('moveUp', TRUE) . '">'
+                                                       . htmlspecialchars('return jumpToUrl(\'' . $module->doc->issueCommand($params, -1) . '\');')
+                                                       . '" title="' . $this->getLanguageService()->getLL('moveUp', TRUE) . '">'
                                                        . IconUtility::getSpriteIcon('actions-move-up') . '</a>';
                                        } else {
                                                $cells['moveUp'] = $this->spaceIcon;
@@ -1261,8 +1276,8 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                                // Down
                                                $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['next'][$row['uid']];
                                                $cells['moveDown'] = '<a class="btn" href="#" onclick="'
-                                                       . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');')
-                                                       . '" title="' . $GLOBALS['LANG']->getLL('moveDown', TRUE) . '">'
+                                                       . htmlspecialchars('return jumpToUrl(\'' . $module->doc->issueCommand($params, -1) . '\');')
+                                                       . '" title="' . $this->getLanguageService()->getLL('moveDown', TRUE) . '">'
                                                        . IconUtility::getSpriteIcon('actions-move-down') . '</a>';
                                        } else {
                                                $cells['moveDown'] = $this->spaceIcon;
@@ -1273,26 +1288,26 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                if (
                                        $permsEdit && $hiddenField && $GLOBALS['TCA'][$table]['columns'][$hiddenField]
                                        && (!$GLOBALS['TCA'][$table]['columns'][$hiddenField]['exclude']
-                                               || $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $hiddenField))
+                                               || $this->getBackendUserAuthentication()->check('non_exclude_fields', $table . ':' . $hiddenField))
                                ) {
                                        if ($row[$hiddenField]) {
                                                $params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=0';
                                                $cells['hide'] = '<a class="btn t3js-record-hide" data-state="hidden" href="#"'
                                                        . ' data-params="' . htmlspecialchars($params) . '"'
-                                                       . ' title="' . $GLOBALS['LANG']->getLL(('unHide' . ($table == 'pages' ? 'Page' : '')), TRUE) . '">'
+                                                       . ' title="' . $this->getLanguageService()->getLL(('unHide' . ($table == 'pages' ? 'Page' : '')), TRUE) . '">'
                                                        . IconUtility::getSpriteIcon('actions-edit-unhide') . '</a>';
                                        } else {
                                                $params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=1';
                                                $cells['hide'] = '<a class="btn t3js-record-hide" data-state="visible" href="#"'
                                                        . ' data-params="' . htmlspecialchars($params) . '"'
-                                                       . ' title="' . $GLOBALS['LANG']->getLL(('hide' . ($table == 'pages' ? 'Page' : '')), TRUE) . '">'
+                                                       . ' title="' . $this->getLanguageService()->getLL(('hide' . ($table == 'pages' ? 'Page' : '')), TRUE) . '">'
                                                        . IconUtility::getSpriteIcon('actions-edit-hide') . '</a>';
                                        }
                                }
                                // "Delete" link:
                                if ($table == 'pages' && $localCalcPerms & 4 || $table != 'pages' && $this->calcPerms & 16) {
                                        // Check if the record version is in "deleted" state, because that will switch the action to "restore"
-                                       if ($GLOBALS['BE_USER']->workspace > 0 && isset($row['t3ver_state']) && (int)$row['t3ver_state'] === 2) {
+                                       if ($this->getBackendUserAuthentication()->workspace > 0 && isset($row['t3ver_state']) && (int)$row['t3ver_state'] === 2) {
                                                $actionName = 'restore';
                                                $refCountMsg = '';
                                        } else {
@@ -1300,19 +1315,19 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                                $refCountMsg = BackendUtility::referenceCount(
                                                        $table,
                                                        $row['uid'],
-                                                       ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.referencesToRecord'),
+                                                       ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.referencesToRecord'),
                                                        $this->getReferenceCount($table, $row['uid'])) . BackendUtility::translationCount($table, $row['uid'],
-                                                       ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.translationsOfRecord')
+                                                       ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.translationsOfRecord')
                                                );
                                        }
 
                                        $titleOrig = BackendUtility::getRecordTitle($table, $row, FALSE, TRUE);
                                        $title = GeneralUtility::fixed_lgd_cs($titleOrig, $this->fixedL);
-                                       $warningText = $GLOBALS['LANG']->getLL($actionName . 'Warning') . ' "' . $title . '" ' . '[' . $table . ':' . $row['uid'] . ']' . $refCountMsg;
+                                       $warningText = $this->getLanguageService()->getLL($actionName . 'Warning') . ' "' . $title . '" ' . '[' . $table . ':' . $row['uid'] . ']' . $refCountMsg;
 
                                        $params = 'cmd[' . $table . '][' . $row['uid'] . '][delete]=1';
                                        $icon = IconUtility::getSpriteIcon('actions-edit-' . $actionName);
-                                       $linkTitle = $GLOBALS['LANG']->getLL($actionName, TRUE);
+                                       $linkTitle = $this->getLanguageService()->getLL($actionName, TRUE);
                                        $cells['delete'] = '<a class="btn t3js-record-delete" href="#" '
                                                . ' data-l10parent="' . htmlspecialchars($row['l10n_parent']) . '"'
                                                . ' data-params="' . htmlspecialchars($params) . '" data-title="' . htmlspecialchars($titleOrig) . '"'
@@ -1325,18 +1340,18 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                        if ($this->calcPerms & 8) {
                                                $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . -$this->id;
                                                $cells['moveLeft'] = '<a class="btn" href="#" onclick="'
-                                                       . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');')
-                                                       . '" title="' . $GLOBALS['LANG']->getLL('prevLevel', TRUE) . '">'
+                                                       . htmlspecialchars('return jumpToUrl(\'' . $module->doc->issueCommand($params, -1) . '\');')
+                                                       . '" title="' . $this->getLanguageService()->getLL('prevLevel', TRUE) . '">'
                                                        . IconUtility::getSpriteIcon('actions-move-left') . '</a>';
                                        }
                                        // Down (Paste as subpage to the page right above)
                                        if ($this->currentTable['prevUid'][$row['uid']]) {
-                                               $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(BackendUtility::getRecord('pages', $this->currentTable['prevUid'][$row['uid']]));
+                                               $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', $this->currentTable['prevUid'][$row['uid']]));
                                                if ($localCalcPerms & 8) {
                                                        $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prevUid'][$row['uid']];
                                                        $cells['moveRight'] = '<a class="btn" href="#" onclick="'
-                                                               . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');')
-                                                               . '" title="' . $GLOBALS['LANG']->getLL('nextLevel', TRUE) . '">'
+                                                               . htmlspecialchars('return jumpToUrl(\'' . $module->doc->issueCommand($params, -1) . '\');')
+                                                               . '" title="' . $this->getLanguageService()->getLL('nextLevel', TRUE) . '">'
                                                                . IconUtility::getSpriteIcon('actions-move-right') . '</a>';
                                                } else {
                                                        $cells['moveRight'] = $this->spaceIcon;
@@ -1368,8 +1383,8 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
                                $hookObject = GeneralUtility::getUserObj($classData);
-                               if (!$hookObject instanceof \TYPO3\CMS\Recordlist\RecordList\RecordListHookInterface) {
-                                       throw new \UnexpectedValueException('$hookObject must implement interface ' . \TYPO3\CMS\Recordlist\RecordList\RecordListHookInterface::class, 1195567840);
+                               if (!$hookObject instanceof RecordListHookInterface) {
+                                       throw new \UnexpectedValueException('$hookObject must implement interface ' . RecordListHookInterface::class, 1195567840);
                                }
                                $cells = $hookObject->makeControl($table, $row, $cells, $this);
                        }
@@ -1384,7 +1399,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
         * Creates the clipboard panel for a single record in the listing.
         *
         * @param string $table The table
-        * @param array $row The record for which to make the clipboard panel.
+        * @param mixed[] $row The record for which to make the clipboard panel.
         * @throws \UnexpectedValueException
         * @return string HTML table with the clipboard panel (unless disabled)
         */
@@ -1409,11 +1424,11 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                        } else {
                                $cells['copy'] = '<a class="btn" href="#" onclick="'
                                        . htmlspecialchars('return jumpSelf(\'' . $this->clipObj->selUrlDB($table, $row['uid'], 1, ($isSel == 'copy'), array('returnUrl' => '')) . '\');')
-                                       . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.copy', TRUE) . '">'
+                                       . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.copy', TRUE) . '">'
                                        . (!$isSel == 'copy' ? IconUtility::getSpriteIcon('actions-edit-copy') : IconUtility::getSpriteIcon('actions-edit-copy-release')) . '</a>';
                                $cells['cut'] = '<a class="btn" href="#" onclick="'
                                        . htmlspecialchars('return jumpSelf(\'' . $this->clipObj->selUrlDB($table, $row['uid'], 0, ($isSel == 'cut'), array('returnUrl' => '')) . '\');')
-                                       . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.cut', TRUE) . '">'
+                                       . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.cut', TRUE) . '">'
                                        . (!$isSel == 'cut' ? IconUtility::getSpriteIcon('actions-edit-cut') : IconUtility::getSpriteIcon('actions-edit-cut-release')) . '</a>';
                        }
                } else {
@@ -1422,12 +1437,12 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                        $n = $table . '|' . $row['uid'];
                        $this->CBnames[] = $n;
                        // Check if the current element is selected and if so, prepare to set the checkbox as selected:
-                       $checked = $this->clipObj->isSelected($table, $row['uid']) ? ' checked="checked"' : '';
+                       $checked = $this->clipObj->isSelected($table, $row['uid']) ? 'checked="checked" ' : '';
                        // If the "duplicateField" value is set then select all elements which are duplicates...
                        if ($this->duplicateField && isset($row[$this->duplicateField])) {
                                $checked = '';
                                if (in_array($row[$this->duplicateField], $this->duplicateStack)) {
-                                       $checked = ' checked="checked"';
+                                       $checked = 'checked="checked" ';
                                }
                                $this->duplicateStack[] = $row[$this->duplicateField];
                        }
@@ -1435,7 +1450,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                        $cells['select'] = $isL10nOverlay
                                ? $this->spaceIcon
                                : '<div class="btn-checkbox-holder"><input type="hidden" name="CBH[' . $n . ']" value="0" /><input type="checkbox"'
-                                       . ' name="CBC[' . $n . ']" value="1" class="smallCheckboxes btn-checkbox"' . $checked . ' /><span class="btn"><span class="t3-icon fa"></span></span></div>';
+                                       . ' name="CBC[' . $n . ']" value="1" class="smallCheckboxes btn-checkbox" ' . $checked . '/><span class="btn"><span class="t3-icon fa"></span></span></div>';
                }
                // Now, looking for selected elements from the current table:
                $elFromTable = $this->clipObj->elFromTable($table);
@@ -1445,7 +1460,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                ? $this->spaceIcon
                                : '<a class="btn" href="' . htmlspecialchars($this->clipObj->pasteUrl($table, -$row['uid'])) . '" onclick="'
                                        . htmlspecialchars(('return ' . $this->clipObj->confirmMsg($table, $row, 'after', $elFromTable)))
-                                       . '" title="' . $GLOBALS['LANG']->getLL('clip_pasteAfter', TRUE) . '">'
+                                       . '" title="' . $this->getLanguageService()->getLL('clip_pasteAfter', TRUE) . '">'
                                        . IconUtility::getSpriteIcon('actions-document-paste-after') . '</a>';
                }
                // Now, looking for elements in general:
@@ -1453,7 +1468,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                if ($table == 'pages' && count($elFromTable)) {
                        $cells['pasteInto'] = '<a class="btn" href="' . htmlspecialchars($this->clipObj->pasteUrl('', $row['uid']))
                                . '" onclick="' . htmlspecialchars('return ' . $this->clipObj->confirmMsg($table, $row, 'into', $elFromTable))
-                               . '" title="' . $GLOBALS['LANG']->getLL('clip_pasteInto', TRUE) . '">'
+                               . '" title="' . $this->getLanguageService()->getLL('clip_pasteInto', TRUE) . '">'
                                . IconUtility::getSpriteIcon('actions-document-paste-into') . '</a>';
                }
                /**
@@ -1466,8 +1481,8 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
                                $hookObject = GeneralUtility::getUserObj($classData);
-                               if (!$hookObject instanceof \TYPO3\CMS\Recordlist\RecordList\RecordListHookInterface) {
-                                       throw new \UnexpectedValueException('$hookObject must implement interface ' . \TYPO3\CMS\Recordlist\RecordList\RecordListHookInterface::class, 1195567845);
+                               if (!$hookObject instanceof RecordListHookInterface) {
+                                       throw new \UnexpectedValueException('$hookObject must implement interface ' . RecordListHookInterface::class, 1195567845);
                                }
                                $cells = $hookObject->makeClip($table, $row, $cells, $this);
                        }
@@ -1486,10 +1501,11 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
         * @return string HTML of reference a link, will be empty if there are no
         */
        protected function createReferenceHtml($tableName, $uid) {
-               $referenceCount = $this->getDatabaseConnection()->exec_SELECTcountRows(
+               $db = $this->getDatabaseConnection();
+               $referenceCount = $db->exec_SELECTcountRows(
                        '*',
                        'sys_refindex',
-                       'ref_table = ' . $this->getDatabaseConnection()->fullQuoteStr($tableName, 'sys_refindex') .
+                       'ref_table = ' . $db->fullQuoteStr($tableName, 'sys_refindex') .
                        ' AND ref_uid = ' . $uid . ' AND deleted = 0'
                );
                return $this->generateReferenceToolTip($referenceCount, '\'' . $tableName . '\', \'' . $uid . '\'');
@@ -1499,8 +1515,8 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
         * Creates the localization panel
         *
         * @param string $table The table
-        * @param array $row The record for which to make the localization panel.
-        * @return array Array with key 0/1 with content for column 1 and 2
+        * @param mixed[] $row The record for which to make the localization panel.
+        * @return string[] Array with key 0/1 with content for column 1 and 2
         */
        public function makeLocalizationPanel($table, $row) {
                $out = array(
@@ -1517,9 +1533,9 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                        // Traverse page translations and add icon for each language that does NOT yet exist:
                        $lNew = '';
                        foreach ($this->pageOverlays as $lUid_OnPage => $lsysRec) {
-                               if (!isset($translations['translations'][$lUid_OnPage]) && $GLOBALS['BE_USER']->checkLanguageAccess($lUid_OnPage)) {
+                               if (!isset($translations['translations'][$lUid_OnPage]) && $this->getBackendUserAuthentication()->checkLanguageAccess($lUid_OnPage)) {
                                        $url = substr($this->listURL(), strlen($this->backPath));
-                                       $href = $GLOBALS['SOBE']->doc->issueCommand('&cmd[' . $table . '][' . $row['uid'] . '][localize]='
+                                       $href = $this->getModule()->doc->issueCommand('&cmd[' . $table . '][' . $row['uid'] . '][localize]='
                                                . $lUid_OnPage, $url . '&justLocalized=' . rawurlencode($table . ':' . $row['uid'] . ':' . $lUid_OnPage));
                                        $language = BackendUtility::getRecord('sys_language', $lUid_OnPage, 'title');
                                        if ($this->languageIconTitles[$lUid_OnPage]['flagIcon']) {
@@ -1549,6 +1565,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
         * @return string HTML table with the selector box (name: displayFields['.$table.'][])
         */
        public function fieldSelectBox($table, $formFields = TRUE) {
+               $lang = $this->getLanguageService();
                // Init:
                $formElements = array('', '');
                if ($formFields) {
@@ -1570,7 +1587,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                foreach ($fields as $fN) {
                        // Field label
                        $fL = is_array($GLOBALS['TCA'][$table]['columns'][$fN])
-                               ? rtrim($GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['columns'][$fN]['label']), ':')
+                               ? rtrim($lang->sL($GLOBALS['TCA'][$table]['columns'][$fN]['label']), ':')
                                : '[' . $fN . ']';
                        $opt[] = '
                                                                                        <option value="' . $fN . '"'
@@ -1579,7 +1596,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                // Compile the options into a multiple selector box:
                $lMenu = '
                                                                                <select size="'
-                       . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(count($fields) + 1, 3, 20)
+                       . MathUtility::forceIntegerInRange(count($fields) + 1, 3, 20)
                        . '" multiple="multiple" name="displayFields[' . $table . '][]">' . implode('', $opt) . '
                                                                                </select>
                                ';
@@ -1595,7 +1612,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                        </td>
                                        <td>
                                                <input class="btn btn-default" type="submit" name="search" value="'
-                                               . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.setFields', TRUE) . '" />
+                                               . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.setFields', TRUE) . '" />
                                        </td>
                                </tr>
                        </table>
@@ -1672,7 +1689,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
         * this function as much as you like without performance problems.
         *
         * @param int $pid The page id for which to get the path
-        * @return string The path.
+        * @return mixed[] The path.
         */
        public function recPath($pid) {
                if (!isset($this->recPath_cache[$pid])) {
@@ -1735,7 +1752,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
        /**
         * Adds selected columns of one table row as CSV line.
         *
-        * @param array $row Record array, from which the values of fields found in $this->fieldArray will be listed in the CSV output.
+        * @param mixed[] $row Record array, from which the values of fields found in $this->fieldArray will be listed in the CSV output.
         * @return void
         */
        protected function addToCSV(array $row = array()) {
@@ -1747,8 +1764,8 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
        /**
         * Remove control fields from row for CSV export
         *
-        * @param array $row fieldNames => fieldValues
-        * @return array Input array reduces by control fields
+        * @param mixed[] $row fieldNames => fieldValues
+        * @return mixed[] Input array reduces by control fields
         */
        static protected function removeControlFieldsFromFieldRow(array $row = array()) {
                // Possible control fields in a list row
@@ -1766,7 +1783,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
        /**
         * Adds input row of values to the internal csvLines array as a CSV formatted line
         *
-        * @param array $csvRow Array with values to be listed.
+        * @param mixed[] $csvRow Array with values to be listed.
         * @return void
         */
        public function setCsvRow($csvRow) {
@@ -1796,11 +1813,24 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
        }
 
        /**
-        * Returns the database connection
         * @return DatabaseConnection
         */
        protected function getDatabaseConnection() {
                return $GLOBALS['TYPO3_DB'];
        }
 
+       /**
+        * @return BaseScriptClass
+        */
+       protected function getModule() {
+               return $GLOBALS['SOBE'];
+       }
+
+       /**
+        * @return DocumentTemplate
+        */
+       protected function getDocumentTemplate() {
+               return $GLOBALS['TBE_TEMPLATE'];
+       }
+
 }