[CLEANUP] Cleanup code in ElementBrowser 60/25360/11
authorMarkus Klein <klein.t3@mfc-linz.at>
Wed, 13 Nov 2013 02:49:51 +0000 (03:49 +0100)
committerBenjamin Mack <benni@typo3.org>
Thu, 30 Jan 2014 12:09:42 +0000 (13:09 +0100)
This patch does not change functionality.
It just fixes formatting issues of the code and
corrects phpdoc.

Resolves: #53580
Releases: 6.2
Change-Id: I39a7ec757e6dfce8282053c3259a84edc2ba5588
Reviewed-on: https://review.typo3.org/25360
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Benjamin Mack
Tested-by: Benjamin Mack
typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php

index 78ebed4..07229d0 100644 (file)
@@ -27,6 +27,8 @@ namespace TYPO3\CMS\Recordlist\Browser;
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
 
+use TYPO3\CMS\Core\Resource\File;
+use TYPO3\CMS\Core\Resource\Folder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
@@ -46,56 +48,69 @@ class ElementBrowser {
         */
        protected $recordList = NULL;
 
-       // Internal, static:
-       // Current site URL (Frontend)
        /**
-        * @todo Define visibility
+        * Current site URL (Frontend)
+        *
+        * @var string
+        * @internal
         */
        public $siteURL;
 
-       // the script to link to
        /**
+        * the script to link to
+        *
         * @todo Define visibility
         */
        public $thisScript;
 
-       // RTE specific TSconfig
        /**
+        * RTE specific TSconfig
+        *
         * @todo Define visibility
         */
        public $thisConfig;
 
-       // Target (RTE specific)
        /**
+        * Target (RTE specific)
+        *
         * @todo Define visibility
         */
        public $setTarget;
 
-       // CSS Class (RTE specific)
        /**
+        * CSS Class (RTE specific)
+        *
         * @todo Define visibility
         */
        public $setClass;
 
-       // title (RTE specific)
        /**
+        * title (RTE specific)
+        *
         * @todo Define visibility
         */
        public $setTitle;
 
-       // Backend template object
        /**
         * @todo Define visibility
         */
+       public $setParams;
+
+       /**
+        * Backend template object
+        *
+        * @todo Define visibility
+        * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
+        */
        public $doc;
 
-       // Holds information about files
        /**
+        * Holds information about files
+        *
         * @todo Define visibility
         */
        public $elements = array();
 
-       // GPvars:      (Input variables from outside)
        /**
         * The mode determines the main kind of output from the element browser.
         * There are these options for values: rte, db, file, filedrag, wizard.
@@ -106,6 +121,7 @@ class ElementBrowser {
         *
         * @see main()
         * @todo Define visibility
+        * @var string
         */
        public $mode;
 
@@ -135,26 +151,31 @@ class ElementBrowser {
         * mode="file"/"filedrag"). Example value: "/www/htdocs/typo3/32/3dsplm/fileadmin/css/"
         *
         * @todo Define visibility
+        * @var string
         */
        public $expandFolder;
 
        /**
         * the folder object of a parent folder that was selected
         *
-        * @param \TYPO3\CMS\Core\Resource\Folder
+        * @var Folder
         */
        protected $selectedFolder;
 
        /**
-        * TYPO3 Element Browser, wizard mode parameters. There is a heap of parameters there, better debug() them out if you need something... :-)
+        * TYPO3 Element Browser, wizard mode parameters. There is a heap of parameters there,
+        * better debug() them out if you need something... :-)
         *
         * @todo Define visibility
+        * @var array
         */
        public $P;
 
        /**
-        * Active with TYPO3 Element Browser: Contains the name of the form field for which this window opens - thus allows us to make references back to the main window in which the form is.
-        * Example value: "data[pages][39][bodytext]|||tt_content|" or "data[tt_content][NEW3fba56fde763d][image]|||gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai|"
+        * Active with TYPO3 Element Browser: Contains the name of the form field for which this window
+        * opens - thus allows us to make references back to the main window in which the form is.
+        * Example value: "data[pages][39][bodytext]|||tt_content|"
+        * or "data[tt_content][NEW3fba56fde763d][image]|||gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai|"
         *
         * Values:
         * 0: form field name reference, eg. "data[tt_content][123][image]"
@@ -171,6 +192,7 @@ class ElementBrowser {
         * $allowedTablesOrFileTypes = $pArr[3];
         *
         * @todo Define visibility
+        * @var string
         */
        public $bparams;
 
@@ -179,6 +201,7 @@ class ElementBrowser {
         * Example value: "tt_content:NEW3fba58c969f5c:bodytext:23:text:23:"
         *
         * @todo Define visibility
+        * @var string
         */
        public $RTEtsConfigParams;
 
@@ -197,21 +220,28 @@ class ElementBrowser {
        public $pointer;
 
        /**
-        * Used with the link selector: Contains the GET input information about the CURRENT link in the RTE/TCEform field. This consists of "href", "target" and "title" keys. This information is passed around in links.
+        * Used with the link selector: Contains the GET input information about the CURRENT link
+        * in the RTE/TCEform field. This consists of "href", "target" and "title" keys.
+        * This information is passed around in links.
         *
         * @todo Define visibility
+        * @var array
         */
        public $curUrlArray;
 
        /**
-        * Used with the link selector: Contains a processed version of the input values from curUrlInfo. This is splitted into pageid, content element id, label value etc. This is used for the internal processing of that information.
+        * Used with the link selector: Contains a processed version of the input values from curUrlInfo.
+        * This is splitted into pageid, content element id, label value etc.
+        * This is used for the internal processing of that information.
         *
         * @todo Define visibility
+        * @var array
         */
        public $curUrlInfo;
 
        /**
-        * array which holds hook objects (initialised in init() )
+        * array which holds hook objects (initialised in init())
+        * @var \TYPO3\CMS\Core\ElementBrowser\ElementBrowserHookInterface[]
         */
        protected $hookObjects = array();
 
@@ -226,6 +256,7 @@ class ElementBrowser {
         *
         * @return void
         * @todo Define visibility
+        * @throws \UnexpectedValueException
         */
        public function init() {
                // Main GPvars:
@@ -285,9 +316,14 @@ class ElementBrowser {
                                'title' => $currentLinkParts[3],
                                'params' => $currentLinkParts[4]
                        );
-                       $this->curUrlArray = is_array(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('curUrl')) ? array_merge($initialCurUrlArray, GeneralUtility::_GP('curUrl')) : $initialCurUrlArray;
+                       $this->curUrlArray = is_array(GeneralUtility::_GP('curUrl'))
+                               ? array_merge($initialCurUrlArray, GeneralUtility::_GP('curUrl'))
+                               : $initialCurUrlArray;
                        // Additional fields for page links
-                       if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendUrlArray']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendUrlArray'])) {
+                       if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendUrlArray'])
+                               && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendUrlArray'])
+                       ) {
+                               $conf = array();
                                $_params = array(
                                        'conf' => &$conf,
                                        'linkParts' => $currentLinkParts
@@ -301,18 +337,18 @@ class ElementBrowser {
                        // pageid == 0 means that this is not an internal (page) link
                        if ($this->curUrlInfo['pageid'] == 0 && $this->curUrlArray['href']) {
                                // Check if there is the FAL API
-                               if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($this->curUrlArray['href'], 'file:')) {
+                               if (GeneralUtility::isFirstPartOfStr($this->curUrlArray['href'], 'file:')) {
                                        $this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'], $this->siteURL);
                                        // Remove the "file:" prefix
                                        $currentLinkParts[0] = rawurldecode(substr($this->curUrlArray['href'], 5));
                                } elseif (file_exists(PATH_site . rawurldecode($this->curUrlArray['href']))) {
-                                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($this->curUrlArray['href'], PATH_site)) {
+                                       if (GeneralUtility::isFirstPartOfStr($this->curUrlArray['href'], PATH_site)) {
                                                $currentLinkParts[0] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->curUrlArray['href']);
                                        }
                                        $this->curUrlInfo = $this->parseCurUrl($this->siteURL . $this->curUrlArray['href'], $this->siteURL);
                                } elseif (strstr($this->curUrlArray['href'], '@')) {
                                        // check for email link
-                                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($this->curUrlArray['href'], 'mailto:')) {
+                                       if (GeneralUtility::isFirstPartOfStr($this->curUrlArray['href'], 'mailto:')) {
                                                $currentLinkParts[0] = substr($this->curUrlArray['href'], 7);
                                        }
                                        $this->curUrlInfo = $this->parseCurUrl('mailto:' . $this->curUrlArray['href'], $this->siteURL);
@@ -403,7 +439,7 @@ class ElementBrowser {
                        }
                        unset($this->P['fieldChangeFunc']['alert']);
                        $update = '';
-                       foreach ($this->P['fieldChangeFunc'] as $k => $v) {
+                       foreach ($this->P['fieldChangeFunc'] as $v) {
                                $update .= '
                                window.opener.' . $v;
                        }
@@ -447,7 +483,8 @@ class ElementBrowser {
                                        return false;
                                }
                                function checkReference() {     //
-                                       if (window.opener && window.opener.document && window.opener.document.' . $this->P['formName'] . ' && window.opener.document.' . $this->P['formName'] . '["' . $this->P['itemName'] . '"] ) {
+                                       if (window.opener && window.opener.document && window.opener.document.' . $this->P['formName']
+                                               . ' && window.opener.document.' . $this->P['formName'] . '["' . $this->P['itemName'] . '"] ) {
                                                return window.opener.document.' . $this->P['formName'] . '["' . $this->P['itemName'] . '"];
                                        } else {
                                                close();
@@ -516,7 +553,8 @@ class ElementBrowser {
                        function jumpToUrl(URL,anchor) {        //
                                var add_act = URL.indexOf("act=")==-1 ? "&act=' . $this->act . '" : "";
                                var add_mode = URL.indexOf("mode=")==-1 ? "&mode=' . $this->mode . '" : "";
-                               var theLocation = URL + add_act + add_mode + add_href + add_target + add_class + add_title + add_params' . ($addPassOnParams ? '+"' . $addPassOnParams . '"' : '') . '+(typeof(anchor)=="string"?anchor:"");
+                               var theLocation = URL + add_act + add_mode + add_href + add_target + add_class + add_title + add_params'
+                                       . ($addPassOnParams ? '+"' . $addPassOnParams . '"' : '') . '+(typeof(anchor)=="string"?anchor:"");
                                window.location.href = theLocation;
                                return false;
                        }
@@ -530,6 +568,7 @@ class ElementBrowser {
                // This is JavaScript especially for the TBE Element Browser!
                $formFieldName = 'data[' . $pArr[0] . '][' . $pArr[1] . '][' . $pArr[2] . ']';
                // insertElement - Call check function (e.g. for uniqueness handling):
+               $JScodeCheck = '';
                if ($pArr[4] && $pArr[5]) {
                        $JScodeCheck = '
                                        // Call a check function in the opener window (e.g. for uniqueness handling):
@@ -546,6 +585,7 @@ class ElementBrowser {
                        ';
                }
                // insertElement - Call helper function:
+               $JScodeHelper = '';
                if ($pArr[4] && $pArr[6]) {
                        $JScodeHelper = '
                                                // Call helper function to manage data in the opener window:
@@ -558,6 +598,7 @@ class ElementBrowser {
                        ';
                }
                // insertElement - perform action commands:
+               $JScodeActionMultiple = '';
                if ($pArr[4] && $pArr[7]) {
                        // Call user defined action function:
                        $JScodeAction = '
@@ -572,7 +613,8 @@ class ElementBrowser {
                        $JScodeActionMultiple = '
                                                // Call helper function to manage data in the opener window:
                                        if (parent.window.opener) {
-                                               parent.window.opener.' . $pArr[7] . 'Multiple("' . addslashes($pArr[4]) . '",table,uid,type,"' . addslashes($pArr[0]) . '");
+                                               parent.window.opener.' . $pArr[7] . 'Multiple("' . addslashes($pArr[4]) . '",table,uid,type,"'
+                                               . addslashes($pArr[0]) . '");
                                        } else {
                                                alert("Error - reference to main window is not set properly!");
                                                parent.close();
@@ -585,7 +627,8 @@ class ElementBrowser {
                } else {
                        $JScodeAction = '
                                        if (setReferences()) {
-                                               parent.window.opener.group_change("add","' . $pArr[0] . '","' . $pArr[1] . '","' . $pArr[2] . '",elRef,targetDoc);
+                                               parent.window.opener.group_change("add","' . $pArr[0] . '","' . $pArr[1] . '","' . $pArr[2]
+                                                       . '",elRef,targetDoc);
                                        } else {
                                                alert("Error - reference to main window is not set properly!");
                                        }
@@ -598,13 +641,15 @@ class ElementBrowser {
 
                        function launchView(url) {      //
                                var thePreviewWindow="";
-                               thePreviewWindow = window.open("' . $GLOBALS['BACK_PATH'] . 'show_item.php?table="+url,"ShowItem","height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
+                               thePreviewWindow = window.open("' . $GLOBALS['BACK_PATH'] . 'show_item.php?table="+url,"ShowItem",'
+                               . '"height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
                                if (thePreviewWindow && thePreviewWindow.focus) {
                                        thePreviewWindow.focus();
                                }
                        }
                        function setReferences() {      //
-                               if (parent.window.opener && parent.window.opener.content && parent.window.opener.content.document.editform && parent.window.opener.content.document.editform["' . $formFieldName . '"]) {
+                               if (parent.window.opener && parent.window.opener.content && parent.window.opener.content.document.editform'
+                                       . '&& parent.window.opener.content.document.editform["' . $formFieldName . '"]) {
                                        targetDoc = parent.window.opener.content.document;
                                        elRef = targetDoc.editform["' . $formFieldName . '"];
                                        return true;
@@ -640,7 +685,11 @@ class ElementBrowser {
                        }
                ';
                // extends JavaScript code
-               if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendJScode']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendJScode'])) {
+               if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendJScode'])
+                       && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendJScode'])
+               ) {
+                       $conf = array();
+                       $update = '';
                        $_params = array(
                                'conf' => &$conf,
                                'wizardUpdate' => $update,
@@ -704,7 +753,7 @@ class ElementBrowser {
         * @return string Modified content variable.
         * @todo Define visibility
         */
-       public function main_rte($wiz = 0) {
+       public function main_rte($wiz = FALSE) {
                // Starting content:
                $content = $this->doc->startPage('RTE link');
 
@@ -798,7 +847,11 @@ class ElementBrowser {
                                                        <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
                                                                <tr>
                                                                        <td style="width: 96px;">' . $GLOBALS['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 type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', TRUE) . '" onclick="browse_links_setTarget(\'\');browse_links_setValue(\'mailto:\'+document.lurlform.lemail.value); return link_current();" /></td>
+                                                                       <td><input type="text" name="lemail"' . $this->doc->formWidth(20) . ' value="'
+                                                       . htmlspecialchars(($this->curUrlInfo['act'] == 'mail' ? $this->curUrlInfo['info'] : ''))
+                                                       . '" /> ' . '<input type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', TRUE)
+                                                       . '" onclick="browse_links_setTarget(\'\');browse_links_setValue(\'mailto:\'+'
+                                                       . 'document.lurlform.lemail.value); return link_current();" /></td>
                                                                </tr>
                                                        </table>
                                                </form>';
@@ -814,7 +867,10 @@ class ElementBrowser {
                                                        <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
                                                                <tr>
                                                                        <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 type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', TRUE) . '" onclick="browse_links_setValue(document.lurlform.lurl.value); return link_current();" /></td>
+                                                                       <td><input type="text" name="lurl"' . $this->doc->formWidth(30) . ' value="'
+                                                       . htmlspecialchars(($this->curUrlInfo['act'] == 'url' ? $this->curUrlInfo['info'] : 'http://'))
+                                                       . '" /> ' . '<input type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', TRUE)
+                                                       . '" onclick="browse_links_setValue(document.lurlform.lurl.value); return link_current();" /></td>
                                                                </tr>
                                                        </table>
                                                </form>';
@@ -835,14 +891,15 @@ class ElementBrowser {
                                        }
                                }
                                // Create upload/create folder forms, if a path is given
+                               $selectedFolder = FALSE;
                                if ($this->expandFolder) {
-                                       $selectedFolder = FALSE;
+                                       $fileOrFolderObject = NULL;
                                        try {
                                                $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
                                        } catch (\Exception $e) {
                                        }
 
-                                       if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
+                                       if ($fileOrFolderObject instanceof Folder) {
                                                // It's a folder
                                                $selectedFolder = $fileOrFolderObject;
                                        } elseif ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
@@ -882,7 +939,8 @@ 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>
+                                                               <td class="c-wCell" valign="top">'
+                                                                       . $this->barheader(($GLOBALS['LANG']->getLL('folderTree') . ':')) . $tree . '</td>
                                                                <td class="c-wCell" valign="top">' . $files . '</td>
                                                        </tr>
                                                </table>
@@ -909,14 +967,16 @@ class ElementBrowser {
                                                                $title = $GLOBALS['LANG']->sL($title);
                                                        }
                                                        // Description:
-                                                       $description = $v[$k2i . '.']['description'] ? $GLOBALS['LANG']->sL($v[($k2i . '.')]['description'], TRUE) . '<br />' : '';
+                                                       $description = $v[$k2i . '.']['description']
+                                                               ? $GLOBALS['LANG']->sL($v[($k2i . '.')]['description'], TRUE) . '<br />'
+                                                               : '';
                                                        // URL + onclick event:
                                                        $onClickEvent = '';
                                                        if (isset($v[$k2i . '.']['target'])) {
                                                                $onClickEvent .= 'browse_links_setTarget(\'' . $v[($k2i . '.')]['target'] . '\');';
                                                        }
                                                        $v[$k2i . '.']['url'] = str_replace('###_URL###', $this->siteURL, $v[$k2i . '.']['url']);
-                                                       if (substr($v[$k2i . '.']['url'], 0, 7) == 'http://' || substr($v[$k2i . '.']['url'], 0, 7) == 'mailto:') {
+                                                       if (substr($v[$k2i . '.']['url'], 0, 7) === 'http://' || substr($v[$k2i . '.']['url'], 0, 7) === 'mailto:') {
                                                                $onClickEvent .= 'cur_href=unescape(\'' . rawurlencode($v[($k2i . '.')]['url']) . '\');link_current();';
                                                        } else {
                                                                $onClickEvent .= 'link_spec(unescape(\'' . $this->siteURL . rawurlencode($v[($k2i . '.')]['url']) . '\'));';
@@ -926,7 +986,15 @@ class ElementBrowser {
                                                        // Adding link to menu of user defined links:
                                                        $subcats[$k2i] = '
                                                                        <tr>
-                                                                               <td class="bgColor4">' . $A[0] . '<strong>' . htmlspecialchars($title) . ($this->curUrlInfo['info'] == $v[$k2i . '.']['url'] ? '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_right.gif', 'width="5" height="9"') . ' class="c-blinkArrowR" alt="" />' : '') . '</strong><br />' . $description . $A[1] . '</td>
+                                                                               <td class="bgColor4">' . $A[0] . '<strong>' . htmlspecialchars($title)
+                                                                                       . ($this->curUrlInfo['info'] == $v[$k2i . '.']['url']
+                                                                                               ? '<img' . IconUtility::skinImg(
+                                                                                                                               $GLOBALS['BACK_PATH'],
+                                                                                                                               'gfx/blinkarrow_right.gif',
+                                                                                                                               'width="5" height="9"'
+                                                                                                       ) . ' class="c-blinkArrowR" alt="" />'
+                                                                                               : '')
+                                                                                       . '</strong><br />' . $description . $A[1] . '</td>
                                                                        </tr>';
                                                }
                                        }
@@ -940,7 +1008,8 @@ 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>
+                                                                       <td class="bgColor5" class="c-wCell" valign="top"><strong>'
+                                                                               . $GLOBALS['LANG']->getLL('special', TRUE) . '</strong></td>
                                                                </tr>
                                                                ' . implode('', $subcats) . '
                                                        </table>
@@ -948,17 +1017,25 @@ class ElementBrowser {
                                }
                                break;
                        case 'page':
-                               $pagetree = GeneralUtility::makeInstance('rtePageTree');
-                               $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->addField('nav_title');
-                               $tree = $pagetree->getBrowsableTree();
+                               $pageTree = GeneralUtility::makeInstance('rtePageTree');
+                               $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->addField('nav_title');
+                               $tree = $pageTree->getBrowsableTree();
                                $cElements = $this->expandPage();
                                // Outputting Temporary DB mount notice:
+                               $dbmount = '';
                                if (intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint'))) {
-                                       $link = '<a href="' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript(array('setTempDBmount' => 0))) . '">' . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xlf:labels.temporaryDBmount', TRUE) . '</a>';
-                                       $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $link, '', \TYPO3\CMS\Core\Messaging\FlashMessage::INFO);
+                                       $link = '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('setTempDBmount' => 0)))
+                                               . '">' . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xlf:labels.temporaryDBmount', TRUE)
+                                               . '</a>';
+                                       $flashMessage = GeneralUtility::makeInstance(
+                                               'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
+                                               $link,
+                                               '',
+                                               \TYPO3\CMS\Core\Messaging\FlashMessage::INFO
+                                       );
                                        $dbmount = $flashMessage->render();
                                }
                                $content .= '
@@ -968,7 +1045,9 @@ 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') . ':')) . $dbmount . $tree . '</td>
+                                                               <td class="c-wCell" valign="top">'
+                                                                       . $this->barheader(($GLOBALS['LANG']->getLL('pageTree') . ':')) . $dbmount . $tree
+                                                                       . '</td>
                                                                <td class="c-wCell" valign="top">' . $cElements . '</td>
                                                        </tr>
                                                </table>
@@ -989,7 +1068,9 @@ class ElementBrowser {
                                        <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkParams">
                                                <tr>
                                                        <td style="width: 96px;">' . $GLOBALS['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>
+                                                       <td><input type="text" name="lparams" class="typo3-link-input" onchange="'
+                                                               . 'browse_links_setParams(this.value);" value="' . htmlspecialchars($this->setParams)
+                                                               . '" /></td>
                                                </tr>
                                        </table>
                                </form>
@@ -1004,7 +1085,9 @@ class ElementBrowser {
                                        <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkClass">
                                                <tr>
                                                        <td style="width: 96px;">' . $GLOBALS['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>
+                                                       <td><input type="text" name="lclass" class="typo3-link-input" onchange="'
+                                                               . 'browse_links_setClass(this.value);" value="' . htmlspecialchars($this->setClass)
+                                                               . '" /></td>
                                                </tr>
                                        </table>
                                </form>
@@ -1019,14 +1102,19 @@ class ElementBrowser {
                                        <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTitle">
                                                <tr>
                                                        <td style="width: 96px;">' . $GLOBALS['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>
+                                                       <td><input type="text" name="ltitle" class="typo3-link-input" onchange="'
+                                                               . 'browse_links_setTitle(this.value);" value="' . htmlspecialchars($this->setTitle)
+                                                               . '" /></td>
                                                </tr>
                                        </table>
                                </form>
                        ';
                }
                // additional fields for page links
-               if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['addFields_PageLink']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['addFields_PageLink'])) {
+               if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['addFields_PageLink'])
+                       && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['addFields_PageLink'])
+               ) {
+                       $conf = array();
                        $_params = array(
                                'conf' => &$conf
                        );
@@ -1046,22 +1134,32 @@ class ElementBrowser {
                                        <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
                                                <tr>
                                                        <td>' . $GLOBALS['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><input type="text" name="ltarget" onchange="browse_links_setTarget(this.value);" value="'
+                                                               . htmlspecialchars($this->setTarget) . '"' . $this->doc->formWidth(10) . ' /></td>
                                                        <td>
-                                                               <select name="ltarget_type" onchange="browse_links_setTarget(this.options[this.selectedIndex].value);document.ltargetform.ltarget.value=this.options[this.selectedIndex].value;this.selectedIndex=0;">
+                                                               <select name="ltarget_type" onchange="browse_links_setTarget('
+                                                                       . 'this.options[this.selectedIndex].value);document.ltargetform.ltarget.value='
+                                                                       . 'this.options[this.selectedIndex].value;this.selectedIndex=0;">
                                                                        <option></option>
                                                                        <option value="_top">' . $GLOBALS['LANG']->getLL('top', TRUE) . '</option>
                                                                        <option value="_blank">' . $GLOBALS['LANG']->getLL('newWindow', TRUE) . '</option>
                                                                </select>
                                                        </td>
                                                        <td>';
-                       if (($this->curUrlInfo['act'] == 'page' || $this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder') && $this->curUrlArray['href'] && $this->curUrlInfo['act'] == $this->act) {
+                       if (($this->curUrlInfo['act'] == 'page' || $this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder')
+                               && $this->curUrlArray['href'] && $this->curUrlInfo['act'] == $this->act
+                       ) {
                                $ltarget .= '
-                                                       <input type="submit" value="' . $GLOBALS['LANG']->getLL('update', TRUE) . '" onclick="return link_current();" />';
+                                                       <input type="submit" value="' . $GLOBALS['LANG']->getLL('update', TRUE)
+                                                               . '" onclick="return link_current();" />';
                        }
                        $selectJS = '
-                               if (document.ltargetform.popup_width.options[document.ltargetform.popup_width.selectedIndex].value>0 && document.ltargetform.popup_height.options[document.ltargetform.popup_height.selectedIndex].value>0) {
-                                       document.ltargetform.ltarget.value = document.ltargetform.popup_width.options[document.ltargetform.popup_width.selectedIndex].value+"x"+document.ltargetformbrowse_links_setTarget.popup_height.options[document.ltargetform.popup_height.selectedIndex].value;
+                               if (document.ltargetform.popup_width.options[document.ltargetform.popup_width.selectedIndex].value>0'
+                                       . ' && document.ltargetform.popup_height.options[document.ltargetform.popup_height.selectedIndex].value>0) {
+                                       document.ltargetform.ltarget.value = document.ltargetform.popup_width.options['
+                                               . 'document.ltargetform.popup_width.selectedIndex].value+"x"'
+                                               . '+document.ltargetformbrowse_links_setTarget.popup_height.options['
+                                               . 'document.ltargetform.popup_height.selectedIndex].value;
                                        browse_links_setTarget(document.ltargetform.ltarget.value);
                                        browse_links_setClass(document.lclassform.lclass.value);
                                        browse_links_setTitle(document.ltitleform.ltitle.value);
@@ -1159,7 +1257,8 @@ class ElementBrowser {
                        <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBrecords">
                                <tr>';
                if ($withTree) {
-                       $content .= '<td class="c-wCell" valign="top">' . $this->barheader(($GLOBALS['LANG']->getLL('pageTree') . ':')) . $tree . '</td>';
+                       $content .= '<td class="c-wCell" valign="top">'
+                               . $this->barheader(($GLOBALS['LANG']->getLL('pageTree') . ':')) . $tree . '</td>';
                }
                $content .= '<td class="c-wCell" valign="top">' . $cElements . '</td>
                                </tr>
@@ -1189,7 +1288,8 @@ class ElementBrowser {
                $content = $this->doc->startPage('TBE file selector');
                // Init variable:
                $pArr = explode('|', $this->bparams);
-               // The key number 3 of the pArr contains the "allowed" string. Disallowed is not passed to the element browser at all but only filtered out in TCEMain afterwards
+               // The key number 3 of the pArr contains the "allowed" string. Disallowed is not passed to
+               // the element browser at all but only filtered out in TCEMain afterwards
                $allowed = $pArr[3];
                if ($allowed !== 'sys_file') {
                        $allowedFileExtensions = $allowed;
@@ -1245,18 +1345,19 @@ class ElementBrowser {
                }
                // Getting flag for showing/not showing thumbnails:
                $noThumbs = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
+               $_MOD_SETTINGS = array();
                if (!$noThumbs) {
                        // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
                        $_MOD_MENU = array('displayThumbs' => '');
                        $_MCONF['name'] = 'file_list';
                        $_MOD_SETTINGS = BackendUtility::getModuleData($_MOD_MENU, GeneralUtility::_GP('SET'), $_MCONF['name']);
                }
-               $noThumbs = $noThumbs ? $noThumbs : !$_MOD_SETTINGS['displayThumbs'];
+               $noThumbs = $noThumbs ? $noThumbs : empty($_MOD_SETTINGS['displayThumbs']);
                // Create folder tree:
-               $foldertree = GeneralUtility::makeInstance('TBE_FolderTree');
-               $foldertree->thisScript = $this->thisScript;
-               $foldertree->ext_noTempRecyclerDirs = $this->mode == 'filedrag';
-               $tree = $foldertree->getBrowsableTree();
+               $folderTree = GeneralUtility::makeInstance('TBE_FolderTree');
+               $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') {
@@ -1275,7 +1376,8 @@ 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') . ':')) . $tree . '</td>
+                                       <td class="c-wCell" valign="top">' . $this->barheader(($GLOBALS['LANG']->getLL('folderTree') . ':'))
+                                               . $tree . '</td>
                                        <td class="c-wCell" valign="top">' . $files . '</td>
                                </tr>
                        </table>
@@ -1321,10 +1423,10 @@ class ElementBrowser {
                        $createFolder = '';
                }
                // Create folder tree:
-               $foldertree = GeneralUtility::makeInstance('TBE_FolderTree');
-               $foldertree->thisScript = $this->thisScript;
-               $foldertree->ext_noTempRecyclerDirs = $this->mode == 'filedrag';
-               $tree = $foldertree->getBrowsableTree(FALSE);
+               $folderTree = GeneralUtility::makeInstance('TBE_FolderTree');
+               $folderTree->thisScript = $this->thisScript;
+               $folderTree->ext_noTempRecyclerDirs = $this->mode == 'filedrag';
+               $tree = $folderTree->getBrowsableTree(FALSE);
                list(, , $specUid) = explode('_', $this->PM);
                if ($this->mode == 'filedrag') {
                        $folders = $this->TBE_dragNDrop($this->selectedFolder, $parameters[3]);
@@ -1339,7 +1441,8 @@ 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') . ':')) . $tree . '</td>
+                                       <td class="c-wCell" valign="top">' . $this->barheader(($GLOBALS['LANG']->getLL('folderTree') . ':'))
+                                               . $tree . '</td>
                                        <td class="c-wCell" valign="top">' . $folders . '</td>
                                </tr>
                        </table>
@@ -1375,7 +1478,10 @@ class ElementBrowser {
                        $expPageId = $this->curUrlInfo['pageid'];
                }
                // 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)) {
+               if ($expPageId
+                       && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($expPageId)
+                       && $GLOBALS['BE_USER']->isInWebMount($expPageId)
+               ) {
                        // Set header:
                        $out .= $this->barheader($GLOBALS['LANG']->getLL('contentElements') . ':');
                        // Create header for listing, showing the page title/icon:
@@ -1385,7 +1491,14 @@ class ElementBrowser {
                        $picon .= BackendUtility::getRecordTitle('pages', $mainPageRec, TRUE);
                        $out .= $picon . '<br />';
                        // Look up tt_content elements from the expanded page:
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,header,hidden,starttime,endtime,fe_group,CType,colPos,bodytext', 'tt_content', 'pid=' . intval($expPageId) . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content'), '', 'colPos,sorting');
+                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
+                               'uid,header,hidden,starttime,endtime,fe_group,CType,colPos,bodytext',
+                               'tt_content',
+                               'pid=' . intval($expPageId) . BackendUtility::deleteClause('tt_content')
+                                       . BackendUtility::versioningPlaceholderClause('tt_content'),
+                               '',
+                               'colPos,sorting'
+                       );
                        $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
                        // Traverse list of records:
                        $c = 0;
@@ -1393,20 +1506,30 @@ class ElementBrowser {
                                $c++;
                                $icon = IconUtility::getSpriteIconForRecord('tt_content', $row);
                                if ($this->curUrlInfo['act'] == 'page' && $this->curUrlInfo['cElement'] == $row['uid']) {
-                                       $arrCol = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif', 'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />';
+                                       $arrCol = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif', 'width="5" height="9"')
+                                               . ' class="c-blinkArrowL" alt="" />';
                                } else {
                                        $arrCol = '';
                                }
                                // Putting list element HTML together:
-                               $out .= '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], ('gfx/ol/join' . ($c == $cc ? 'bottom' : '') . '.gif'), 'width="18" height="16"') . ' alt="" />' . $arrCol . '<a href="#" onclick="return link_typo3Page(\'' . $expPageId . '\',\'#' . $row['uid'] . '\');">' . $icon . BackendUtility::getRecordTitle('tt_content', $row, TRUE) . '</a><br />';
+                               $out .= '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], ('gfx/ol/join' . ($c == $cc ? 'bottom' : '')
+                                               . '.gif'), 'width="18" height="16"') . ' alt="" />' . $arrCol
+                                       . '<a href="#" onclick="return link_typo3Page(\'' . $expPageId . '\',\'#' . $row['uid'] . '\');">'
+                                       . $icon . BackendUtility::getRecordTitle('tt_content', $row, TRUE) . '</a><br />';
                                // Finding internal anchor points:
-                               if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('text,textpic', $row['CType'])) {
+                               if (GeneralUtility::inList('text,textpic', $row['CType'])) {
                                        $split = preg_split('/(<a[^>]+name=[\'"]?([^"\'>[:space:]]+)[\'"]?[^>]*>)/i', $row['bodytext'], -1, PREG_SPLIT_DELIM_CAPTURE);
                                        foreach ($split as $skey => $sval) {
                                                if ($skey % 3 == 2) {
                                                        // Putting list element HTML together:
                                                        $sval = substr($sval, 0, 100);
-                                                       $out .= '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/line.gif', 'width="18" height="16"') . ' alt="" />' . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], ('gfx/ol/join' . ($skey + 3 > count($split) ? 'bottom' : '') . '.gif'), 'width="18" height="16"') . ' alt="" />' . '<a href="#" onclick="return link_typo3Page(\'' . $expPageId . '\',\'#' . rawurlencode($sval) . '\');">' . htmlspecialchars((' <A> ' . $sval)) . '</a><br />';
+                                                       $out .= '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/line.gif',
+                                                                       'width="18" height="16"') . ' alt="" />'
+                                                               . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], ('gfx/ol/join'
+                                                                       . ($skey + 3 > count($split) ? 'bottom' : '') . '.gif'), 'width="18" height="16"')
+                                                                       . ' alt="" />' . '<a href="#" onclick="return link_typo3Page(\'' . $expPageId
+                                                                       . '\',\'#' . rawurlencode($sval) . '\');">' . htmlspecialchars((' <A> ' . $sval))
+                                                                       . '</a><br />';
                                                }
                                        }
                                }
@@ -1418,13 +1541,16 @@ class ElementBrowser {
        /**
         * For TYPO3 Element Browser: This lists all content elements from the given list of tables
         *
-        * @param string $tables Commalist of tables. Set to "*" if you want all tables.
+        * @param string $tables Comma separated list of tables. Set to "*" if you want all tables.
         * @return string HTML output.
         * @todo Define visibility
         */
        public function TBE_expandPage($tables) {
                $out = '';
-               if ($this->expandPage >= 0 && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->expandPage) && $GLOBALS['BE_USER']->isInWebMount($this->expandPage)) {
+               if ($this->expandPage >= 0
+                       && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->expandPage)
+                       && $GLOBALS['BE_USER']->isInWebMount($this->expandPage)
+               ) {
                        // Set array with table names to list:
                        if (trim($tables) === '*') {
                                $tablesArr = array_keys($GLOBALS['TCA']);
@@ -1434,7 +1560,8 @@ class ElementBrowser {
                        reset($tablesArr);
                        // Headline for selecting records:
                        $out .= $this->barheader($GLOBALS['LANG']->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.
+                       // 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 = intval($GLOBALS['BE_USER']->uc['titleLen']);
                        $mainPageRec = BackendUtility::getRecordWSOL('pages', $this->expandPage);
                        $ATag = '';
@@ -1444,35 +1571,37 @@ class ElementBrowser {
                        if (is_array($mainPageRec)) {
                                $picon = IconUtility::getSpriteIconForRecord('pages', $mainPageRec);
                                if (in_array('pages', $tablesArr)) {
-                                       $ATag = '<a href="#" onclick="return insertElement(\'pages\', \'' . $mainPageRec['uid'] . '\', \'db\', ' . GeneralUtility::quoteJSvalue($mainPageRec['title']) . ', \'\', \'\', \'\',\'\',1);">';
-                                       $ATag2 = '<a href="#" onclick="return insertElement(\'pages\', \'' . $mainPageRec['uid'] . '\', \'db\', ' . GeneralUtility::quoteJSvalue($mainPageRec['title']) . ', \'\', \'\', \'\',\'\',0);">';
-                                       $ATag_alt = substr($ATag, 0, -4) . ',\'\',1);">';
+                                       $ATag = '<a href="#" onclick="return insertElement(\'pages\', \'' . $mainPageRec['uid'] . '\', \'db\', '
+                                               . GeneralUtility::quoteJSvalue($mainPageRec['title']) . ', \'\', \'\', \'\',\'\',1);">';
+                                       $ATag2 = '<a href="#" onclick="return insertElement(\'pages\', \'' . $mainPageRec['uid'] . '\', \'db\', '
+                                               . GeneralUtility::quoteJSvalue($mainPageRec['title']) . ', \'\', \'\', \'\',\'\',0);">';
                                        $ATag_e = '</a>';
                                }
                        }
-                       $pBicon = $ATag2 ? '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' alt="" />' : '';
-                       $pText = htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($mainPageRec['title'], $titleLen));
+                       $pBicon = $ATag2 ? '<img'
+                               . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"')
+                               . ' alt="" />' : '';
+                       $pText = htmlspecialchars(GeneralUtility::fixed_lgd_cs($mainPageRec['title'], $titleLen));
                        $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);
-                       $pageinfo = BackendUtility::readPageAccess($id, $perms_clause);
-                       $table = '';
+                       $pageInfo = BackendUtility::readPageAccess($id, $perms_clause);
                        // Generate the record list:
-                       /** @var $dblist \TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList */
-                       if (isset($this->recordList)) {
-                               $dblist = $this->recordList;
+                       /** @var $dbList \TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList */
+                       if (is_object($this->recordList)) {
+                               $dbList = $this->recordList;
                        } else {
-                               $dblist = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\RecordList\\ElementBrowserRecordList');
+                               $dbList = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\RecordList\\ElementBrowserRecordList');
                        }
-                       $dblist->thisScript = $this->thisScript;
-                       $dblist->backPath = $GLOBALS['BACK_PATH'];
-                       $dblist->thumbs = 0;
-                       $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageinfo);
-                       $dblist->noControlPanels = 1;
-                       $dblist->clickMenuEnabled = 0;
-                       $dblist->tableList = implode(',', $tablesArr);
+                       $dbList->thisScript = $this->thisScript;
+                       $dbList->backPath = $GLOBALS['BACK_PATH'];
+                       $dbList->thumbs = 0;
+                       $dbList->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageInfo);
+                       $dbList->noControlPanels = 1;
+                       $dbList->clickMenuEnabled = 0;
+                       $dbList->tableList = implode(',', $tablesArr);
                        $pArr = explode('|', $this->bparams);
                        // a string like "data[pages][79][storage_pid]"
                        $fieldPointerString = $pArr[0];
@@ -1481,18 +1610,20 @@ class ElementBrowser {
                        $relatingTableName = substr($fieldPointerParts[1], 0, -1);
                        $relatingFieldName = substr($fieldPointerParts[3], 0, -1);
                        if ($relatingTableName && $relatingFieldName) {
-                               $dblist->setRelatingTableAndField($relatingTableName, $relatingFieldName);
+                               $dbList->setRelatingTableAndField($relatingTableName, $relatingFieldName);
                        }
-                       $dblist->start($id, GeneralUtility::_GP('table'), $pointer, GeneralUtility::_GP('search_field'), GeneralUtility::_GP('search_levels'), GeneralUtility::_GP('showLimit'));
-                       $dblist->setDispFields();
-                       $dblist->generateList();
+                       $dbList->start($id, GeneralUtility::_GP('table'), $pointer, GeneralUtility::_GP('search_field'),
+                               GeneralUtility::_GP('search_levels'), GeneralUtility::_GP('showLimit')
+                       );
+                       $dbList->setDispFields();
+                       $dbList->generateList();
                        //      Add the HTML for the record list to output variable:
-                       $out .= $dblist->HTMLcode;
+                       $out .= $dbList->HTMLcode;
                        // Add support for fieldselectbox in singleTableMode
-                       if ($dblist->table) {
-                               $out .= $dblist->fieldSelectBox($dblist->table);
+                       if ($dbList->table) {
+                               $out .= $dbList->fieldSelectBox($dbList->table);
                        }
-                       $out .= $dblist->getSearchBox();
+                       $out .= $dbList->getSearchBox();
                }
                // Return accumulated content:
                return $out;
@@ -1501,11 +1632,11 @@ class ElementBrowser {
        /**
         * Render list of folders inside a folder.
         *
-        * @param string $folder String of the current folder
+        * @param Folder $folder Folder
         * @return string HTML output
         * @todo Define visibility
         */
-       public function TBE_expandSubFolders(\TYPO3\CMS\Core\Resource\Folder $folder) {
+       public function TBE_expandSubFolders(Folder $folder) {
                $content = '';
                if ($folder->checkActionPermission('read')) {
                        $content .= $this->folderList($folder);
@@ -1522,16 +1653,16 @@ class ElementBrowser {
        /**
         * For RTE: This displays all files from folder. No thumbnails shown
         *
-        * @param \TYPO3\CMS\Core\Resource\Folder $folder The folder path to expand
-        * @param string $extensionList List of fileextensions to show
+        * @param Folder $folder The folder path to expand
+        * @param string $extensionList List of file extensions to show
         * @return string HTML output
         * @todo Define visibility
         */
-       public function expandFolder(\TYPO3\CMS\Core\Resource\Folder $folder, $extensionList = '') {
+       public function expandFolder(Folder $folder, $extensionList = '') {
                $out = '';
                $renderFolders = $this->act === 'folder';
                if ($folder->checkActionPermission('read')) {
-                       // Create header for filelisting:
+                       // Create header for file listing:
                        $out .= $this->barheader($GLOBALS['LANG']->getLL('files') . ':');
                        // Prepare current path value for comparison (showing red arrow)
                        $currentIdentifier = '';
@@ -1541,10 +1672,13 @@ class ElementBrowser {
                        // Create header element; The folder from which files are listed.
                        $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
                        $folderIcon = IconUtility::getSpriteIconForFile('folder');
-                       $folderIcon .= htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($folder->getIdentifier(), $titleLen));
-                       $picon = '<a href="#" onclick="return link_folder(\'file:' . $folder->getCombinedIdentifier() . '\');">' . $folderIcon . '</a>';
+                       $folderIcon .= htmlspecialchars(GeneralUtility::fixed_lgd_cs($folder->getIdentifier(), $titleLen));
+                       $picon = '<a href="#" onclick="return link_folder(\'file:' . $folder->getCombinedIdentifier() . '\');">'
+                               . $folderIcon . '</a>';
                        if ($this->curUrlInfo['act'] == 'folder' && $currentIdentifier == $folder->getCombinedIdentifier()) {
-                               $out .= '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif', 'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />';
+                               $out .= '<img'
+                                       . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif', 'width="5" height="9"')
+                                       . ' class="c-blinkArrowL" alt="" />';
                        }
                        $out .= $picon . '<br />';
                        // Get files from the folder:
@@ -1571,13 +1705,21 @@ class ElementBrowser {
                                        $itemUid = 'file:' . $fileIdentifier;
                                }
                                // If the listed file turns out to be the CURRENT file, then show blinking arrow:
-                               if (($this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder') && $currentIdentifier == $fileIdentifier) {
-                                       $arrCol = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif', 'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />';
+                               if (($this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder')
+                                       && $currentIdentifier == $fileIdentifier
+                               ) {
+                                       $arrCol = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif',
+                                                       'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />';
                                } else {
                                        $arrCol = '';
                                }
                                // Put it all together for the file element:
-                               $out .= '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], ('gfx/ol/join' . ($c == $totalItems ? 'bottom' : '') . '.gif'), 'width="18" height="16"') . ' alt="" />' . $arrCol . '<a href="#" onclick="return link_folder(\'' . $itemUid . '\');">' . $icon . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($fileOrFolderObject->getName(), $titleLen)) . '</a><br />';
+                               $out .= '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'],
+                                               ('gfx/ol/join' . ($c == $totalItems ? 'bottom' : '') . '.gif'),
+                                               'width="18" height="16"'
+                                       ) . ' alt="" />' . $arrCol . '<a href="#" onclick="return link_folder(\'' . $itemUid . '\');">'
+                                       . $icon . htmlspecialchars(GeneralUtility::fixed_lgd_cs($fileOrFolderObject->getName(), $titleLen))
+                                       . '</a><br />';
                        }
                }
                return $out;
@@ -1586,13 +1728,13 @@ class ElementBrowser {
        /**
         * For TYPO3 Element Browser: Expand folder of files.
         *
-        * @param \TYPO3\CMS\Core\Resource\Folder $folder The folder path to expand
+        * @param Folder $folder The folder path to expand
         * @param string $extensionList List of fileextensions to show
         * @param boolean $noThumbs Whether to show thumbnails or not. If set, no thumbnails are shown.
         * @return string HTML output
         * @todo Define visibility
         */
-       public function TBE_expandFolder(\TYPO3\CMS\Core\Resource\Folder $folder, $extensionList = '', $noThumbs = FALSE) {
+       public function TBE_expandFolder(Folder $folder, $extensionList = '', $noThumbs = FALSE) {
                if (!$folder->checkActionPermission('read')) {
                        return '';
                }
@@ -1604,114 +1746,127 @@ class ElementBrowser {
        /**
         * Render list of files.
         *
-        * @param array $files List of files. See \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir
-        * @param string \TYPO3\CMS\Core\Resource\Folder $folder If set a header with a folder icon and folder name are shown
+        * @param File[] $files List of files
+        * @param Folder $folder If set a header with a folder icon and folder name are shown
         * @param boolean $noThumbs Whether to show thumbnails or not. If set, no thumbnails are shown.
         * @return string HTML output
-        * @todo Define visibility
         */
-       public function fileList(array $files, \TYPO3\CMS\Core\Resource\Folder $folder = NULL, $noThumbs = 0) {
+       protected function fileList(array $files, Folder $folder = NULL, $noThumbs = FALSE) {
                $out = '';
-               // Listing the files:
-               if (is_array($files)) {
-                       $lines = array();
-                       // Create headline (showing number of files):
-                       $filesCount = count($files);
-                       $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files') . ' (%s):', $filesCount));
-                       $out .= '<div id="filelist">';
-                       $out .= $this->getBulkSelector($filesCount);
-                       $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
-                       // Create the header of current folder:
-                       if ($folder) {
-                               $folderIcon = IconUtility::getSpriteIconForFile('folder');
-                               $lines[] = '<tr class="t3-row-header">
-                                       <td colspan="4">' . $folderIcon . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($folder->getIdentifier(), $titleLen)) . '</td>
+               $lines = array();
+               // Create headline (showing number of files):
+               $filesCount = count($files);
+               $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files') . ' (%s):', $filesCount));
+               $out .= '<div id="filelist">';
+               $out .= $this->getBulkSelector($filesCount);
+               $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
+               // Create the header of current folder:
+               if ($folder) {
+                       $folderIcon = IconUtility::getSpriteIconForFile('folder');
+                       $lines[] = '<tr class="t3-row-header">
+                               <td colspan="4">' . $folderIcon
+                               . htmlspecialchars(GeneralUtility::fixed_lgd_cs($folder->getIdentifier(), $titleLen)) . '</td>
+                       </tr>';
+               }
+               if ($filesCount == 0) {
+                       $lines[] = '
+                               <tr class="file_list_normal">
+                                       <td colspan="4">No files found.</td>
                                </tr>';
+               }
+               // Init graphic object for reading file dimensions:
+               /** @var $imgObj \TYPO3\CMS\Core\Imaging\GraphicalFunctions */
+               $imgObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Imaging\\GraphicalFunctions');
+               $imgObj->init();
+               $imgObj->mayScaleUp = 0;
+               $imgObj->tempPath = PATH_site . $imgObj->tempPath;
+               // Traverse the file list:
+               foreach ($files as $fileObject) {
+                       $fileExtension = $fileObject->getExtension();
+                       // Thumbnail/size generation:
+                       if (GeneralUtility::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']), strtolower($fileExtension)) && !$noThumbs) {
+                               $imageUrl = $fileObject->process(
+                                       \TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW,
+                                       array('width' => 64, 'height' => 64)
+                               )->getPublicUrl(TRUE);
+                               $imgInfo = $imgObj->getImageDimensions($fileObject->getForLocalProcessing(FALSE));
+                               $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels';
+                               $clickIcon = '<img src="' . $imageUrl . '" hspace="5" vspace="5" border="1" />';
+                       } else {
+                               $clickIcon = '';
+                               $pDim = '';
                        }
-                       if ($filesCount == 0) {
+                       // Create file icon:
+                       $size = ' (' . GeneralUtility::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')';
+                       $icon = IconUtility::getSpriteIconForFile($fileExtension, array('title' => $fileObject->getName() . $size));
+                       // Create links for adding the file:
+                       $filesIndex = count($this->elements);
+                       $this->elements['file_' . $filesIndex] = array(
+                               'type' => 'file',
+                               'table' => 'sys_file',
+                               'uid' => $fileObject->getUid(),
+                               'fileName' => $fileObject->getName(),
+                               'filePath' => $fileObject->getUid(),
+                               'fileExt' => $fileExtension,
+                               'fileIcon' => $icon
+                       );
+                       $ATag = '<a href="#" onclick="return BrowseLinks.File.insertElement(\'file_' . $filesIndex . '\');">';
+                       $ATag_alt = substr($ATag, 0, -4) . ',1);">';
+                       $bulkCheckBox = '<input type="checkbox" class="typo3-bulk-item" name="file_' . $filesIndex . '" value="0" /> ';
+                       $ATag_e = '</a>';
+                       // Create link to showing details about the file in a window:
+                       $Ahref = $GLOBALS['BACK_PATH'] . 'show_item.php?type=file&table=_FILE&uid='
+                               . rawurlencode($fileObject->getCombinedIdentifier())
+                               . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'));
+                       $ATag2 = '<a href="' . htmlspecialchars($Ahref) . '">';
+                       $ATag2_e = '</a>';
+                       // Combine the stuff:
+                       $filenameAndIcon = $bulkCheckBox . $ATag_alt . $icon
+                               . htmlspecialchars(GeneralUtility::fixed_lgd_cs($fileObject->getName(), $titleLen)) . $ATag_e;
+                       // Show element:
+                       // Image...
+                       if ($pDim) {
                                $lines[] = '
                                        <tr class="file_list_normal">
-                                               <td colspan="4">No files found.</td>
+                                               <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)
+                                                       . '" 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>
+                                               <td nowrap="nowrap">&nbsp;' . $pDim . '</td>
+                                       </tr>';
+                               $lines[] = '
+                                       <tr>
+                                               <td class="filelistThumbnail" colspan="4">' . $ATag_alt . $clickIcon . $ATag_e . '</td>
+                                       </tr>';
+                       } else {
+                               $lines[] = '
+                                       <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)
+                                                       . '" 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>
+                                               <td>&nbsp;</td>
                                        </tr>';
                        }
-                       // Init graphic object for reading file dimensions:
-                       /** @var $imgObj \TYPO3\CMS\Core\Imaging\GraphicalFunctions */
-                       $imgObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Imaging\\GraphicalFunctions');
-                       $imgObj->init();
-                       $imgObj->mayScaleUp = 0;
-                       $imgObj->tempPath = PATH_site . $imgObj->tempPath;
-                       // Traverse the file list:
-                       foreach ($files as $fileObject) {
-                               $fileExtension = $fileObject->getExtension();
-                               // Thumbnail/size generation:
-                               if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']), strtolower($fileExtension)) && !$noThumbs) {
-                                       $imageUrl = $fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => 64, 'height' => 64))->getPublicUrl(TRUE);
-                                       $imgInfo = $imgObj->getImageDimensions($fileObject->getForLocalProcessing(FALSE));
-                                       $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels';
-                                       $clickIcon = '<img src="' . $imageUrl . '" hspace="5" vspace="5" border="1" />';
-                               } else {
-                                       $clickIcon = '';
-                                       $pDim = '';
-                               }
-                               // Create file icon:
-                               $size = ' (' . GeneralUtility::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')';
-                               $icon = IconUtility::getSpriteIconForFile($fileExtension, array('title' => $fileObject->getName() . $size));
-                               // Create links for adding the file:
-                               $filesIndex = count($this->elements);
-                               $this->elements['file_' . $filesIndex] = array(
-                                       'type' => 'file',
-                                       'table' => 'sys_file',
-                                       'uid' => $fileObject->getUid(),
-                                       'fileName' => $fileObject->getName(),
-                                       'filePath' => $fileObject->getUid(),
-                                       'fileExt' => $fileExtension,
-                                       'fileIcon' => $icon
-                               );
-                               $ATag = '<a href="#" onclick="return BrowseLinks.File.insertElement(\'file_' . $filesIndex . '\');">';
-                               $ATag_alt = substr($ATag, 0, -4) . ',1);">';
-                               $bulkCheckBox = '<input type="checkbox" class="typo3-bulk-item" name="file_' . $filesIndex . '" value="0" /> ';
-                               $ATag_e = '</a>';
-                               // Create link to showing details about the file in a window:
-                               $Ahref = $GLOBALS['BACK_PATH'] . 'show_item.php?type=file&table=_FILE&uid=' . rawurlencode($fileObject->getCombinedIdentifier()) . '&returnUrl=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI'));
-                               $ATag2 = '<a href="' . htmlspecialchars($Ahref) . '">';
-                               $ATag2_e = '</a>';
-                               // Combine the stuff:
-                               $filenameAndIcon = $bulkCheckBox . $ATag_alt . $icon . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($fileObject->getName(), $titleLen)) . $ATag_e;
-                               // Show element:
-                               // Image...
-                               if ($pDim) {
-                                       $lines[] = '
-                                               <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) . '" 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>
-                                                       <td nowrap="nowrap">&nbsp;' . $pDim . '</td>
-                                               </tr>';
-                                       $lines[] = '
-                                               <tr>
-                                                       <td class="filelistThumbnail" colspan="4">' . $ATag_alt . $clickIcon . $ATag_e . '</td>
-                                               </tr>';
-                               } else {
-                                       $lines[] = '
-                                               <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) . '" 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>
-                                                       <td>&nbsp;</td>
-                                               </tr>';
-                               }
-                       }
-                       // Wrap all the rows in table tags:
-                       $out .= '
-
-               <!--
-                       File listing
-               -->
-                               <table cellpadding="0" cellspacing="0" id="typo3-filelist">
-                                       ' . implode('', $lines) . '
-                               </table>';
                }
-               // Return accumulated content for filelisting:
+               // Wrap all the rows in table tags:
+               $out .= '
+
+       <!--
+               File listing
+       -->
+                       <table cellpadding="0" cellspacing="0" id="typo3-filelist">
+                               ' . implode('', $lines) . '
+                       </table>';
+               // Return accumulated content for file listing:
                $out .= '</div>';
                return $out;
        }
@@ -1719,91 +1874,89 @@ class ElementBrowser {
        /**
         * Render list of folders.
         *
-        * @param array $baseFolder List of folders. See \TYPO3\CMS\Core\Utility\GeneralUtility::get_dirs
-        * @param string $folders If set a header with a folder icon and folder name are shown
+        * @param Folder $baseFolder
         * @return string HTML output
         * @todo Define visibility
         */
-       public function folderList($baseFolder, $folders) {
+       public function folderList(Folder $baseFolder) {
                $content = '';
+               $folders = $baseFolder->getSubfolders();
+               $baseFolderPath = $baseFolder->getPublicUrl();
                // Create headline (showing number of folders):
                $content .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('folders') . ' (%s):', count($folders)));
                $titleLength = intval($GLOBALS['BE_USER']->uc['titleLen']);
                // Create the header of current folder:
-               if ($baseFolder) {
-                       if (strstr($baseFolder, ',') || strstr($baseFolder, '|')) {
+               $aTag = '<a href="#" onclick="return insertElement(\'\',\'' . rawurlencode($baseFolderPath)
+                       . '\', \'folder\', \'' . rawurlencode($baseFolderPath) . '\', unescape(\'' . rawurlencode($baseFolderPath)
+                       . '\'), \'\', \'\',\'\',1);">';
+               // Add the foder icon
+               $folderIcon = $aTag;
+               $folderIcon .= '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif',
+                               'width="18" height="16"') . ' alt="" />';
+               $folderIcon .= htmlspecialchars(GeneralUtility::fixed_lgd_cs(basename($baseFolder), $titleLength));
+               $folderIcon .= '</a>';
+               $content .= $folderIcon . '<br />';
+
+               $lines = array();
+               // Traverse the folder list:
+               foreach ($folders as $folderPath) {
+                       $pathInfo = pathinfo($folderPath);
+                       // Create folder icon:
+                       $icon = '<img src="clear.gif" width="16" height="16" alt="" /><img'
+                               . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif',
+                                       'width="16" height="16"') . ' title="' . htmlspecialchars(($pathInfo['basename']))
+                               . '" class="absmiddle" alt="" />';
+                       // Create links for adding the folder:
+                       if ($this->P['itemName'] != '' && $this->P['formName'] != '') {
+                               $aTag = '<a href="#" onclick="return set_folderpath(unescape(\'' . rawurlencode($folderPath)
+                                       . '\'));">';
+                       } else {
+                               $aTag = '<a href="#" onclick="return insertElement(\'\',\'' . rawurlencode($folderPath)
+                                       . '\', \'folder\', \'' . rawurlencode($folderPath) . '\', unescape(\''
+                                       . rawurlencode($folderPath) . '\'), \'' . $pathInfo['extension'] . '\', \'\');">';
+                       }
+                       if (strstr($folderPath, ',') || strstr($folderPath, '|')) {
                                // In case an invalid character is in the filepath, display error message:
                                $errorMessage = $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('invalidChar'), ', |'));
                                $aTag = ($aTag_alt = '<a href="#" onclick="alert(' . $errorMessage . ');return false;">');
                        } else {
                                // If foldername is OK, just add it:
-                               $aTag = '<a href="#" onclick="return insertElement(\'\',\'' . rawurlencode($baseFolder) . '\', \'folder\', \'' . rawurlencode($baseFolder) . '\', unescape(\'' . rawurlencode($baseFolder) . '\'), \'' . $fI['extension'] . '\', \'' . $ficon . '\');">';
                                $aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
                        }
                        $aTag_e = '</a>';
-                       // Add the foder icon
-                       $folderIcon = $aTag_alt;
-                       $folderIcon .= '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />';
-                       $folderIcon .= htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(basename($baseFolder), $titleLength));
-                       $folderIcon .= $aTag_e;
-                       $content .= $folderIcon . '<br />';
-               }
-               // Listing the folders:
-               if (is_array($folders)) {
-                       if (count($folders) > 0) {
-                               // Traverse the folder list:
-                               $lines = array();
-                               foreach ($folders as $folderPath) {
-                                       $pathInfo = pathinfo($folderPath);
-                                       // Create folder icon:
-                                       $icon = '<img src="clear.gif" width="16" height="16" alt="" /><img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif', 'width="16" height="16"') . ' title="' . htmlspecialchars(($pathInfo['basename'] . $size)) . '" class="absmiddle" alt="" />';
-                                       // Create links for adding the folder:
-                                       if ($this->P['itemName'] != '' && $this->P['formName'] != '') {
-                                               $aTag = '<a href="#" onclick="return set_folderpath(unescape(\'' . rawurlencode($folderPath) . '\'));">';
-                                       } else {
-                                               $aTag = '<a href="#" onclick="return insertElement(\'\',\'' . rawurlencode($folderPath) . '\', \'folder\', \'' . rawurlencode($folderPath) . '\', unescape(\'' . rawurlencode($folderPath) . '\'), \'' . $pathInfo['extension'] . '\', \'' . $ficon . '\');">';
-                                       }
-                                       if (strstr($folderPath, ',') || strstr($folderPath, '|')) {
-                                               // In case an invalid character is in the filepath, display error message:
-                                               $errorMessage = $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('invalidChar'), ', |'));
-                                               $aTag = ($aTag_alt = '<a href="#" onclick="alert(' . $errorMessage . ');return false;">');
-                                       } else {
-                                               // If foldername is OK, just add it:
-                                               $aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
-                                       }
-                                       $aTag_e = '</a>';
-                                       // Combine icon and folderpath:
-                                       $foldernameAndIcon = $aTag_alt . $icon . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(basename($folderPath), $titleLength)) . $aTag_e;
-                                       if ($this->P['itemName'] != '') {
-                                               $lines[] = '
-                                                       <tr class="bgColor4">
-                                                               <td nowrap="nowrap">' . $foldernameAndIcon . '&nbsp;</td>
-                                                               <td>&nbsp;</td>
-                                                       </tr>';
-                                       } else {
-                                               $lines[] = '
-                                                       <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) . '" alt="" />' . $aTag_e . ' </td>
-                                                               <td>&nbsp;</td>
-                                                       </tr>';
-                                       }
-                                       $lines[] = '
-                                                       <tr>
-                                                               <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
-                                                       </tr>';
-                               }
+                       // Combine icon and folderpath:
+                       $foldernameAndIcon = $aTag_alt . $icon
+                               . htmlspecialchars(GeneralUtility::fixed_lgd_cs(basename($folderPath), $titleLength)) . $aTag_e;
+                       if ($this->P['itemName'] != '') {
+                               $lines[] = '
+                                       <tr class="bgColor4">
+                                               <td nowrap="nowrap">' . $foldernameAndIcon . '&nbsp;</td>
+                                               <td>&nbsp;</td>
+                                       </tr>';
+                       } else {
+                               $lines[] = '
+                                       <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)
+                                       . '" alt="" />' . $aTag_e . ' </td>
+                                               <td>&nbsp;</td>
+                                       </tr>';
                        }
-                       // Wrap all the rows in table tags:
-                       $content .= '
-
-               <!--
-                       Folder listing
-               -->
-                               <table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList">
-                                       ' . implode('', $lines) . '
-                               </table>';
+                       $lines[] = '
+                                       <tr>
+                                               <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
+                                       </tr>';
                }
+               // Wrap all the rows in table tags:
+               $content .= '
+
+       <!--
+               Folder listing
+       -->
+                       <table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList">
+                               ' . implode('', $lines) . '
+                       </table>';
                // Return accumulated content for folderlisting:
                return $content;
        }
@@ -1812,92 +1965,101 @@ class ElementBrowser {
         * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
         * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
         *
-        * @param \TYPO3\CMS\Core\Resource\Folder $folder The folder path to expand
-        * @param string $extensionList List of fileextensions to show
+        * @param Folder $folder The folder path to expand
+        * @param string $extensionList List of file extensions to show
         * @return string HTML output
         * @todo Define visibility
         */
-       public function TBE_dragNDrop(\TYPO3\CMS\Core\Resource\Folder $folder, $extensionList = '') {
+       public function TBE_dragNDrop(Folder $folder, $extensionList = '') {
                if (!$folder) {
                        return '';
                }
+               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');
+               }
                $out = '';
-               if ($folder->getStorage()->isPublic()) {
-                       // Read files from directory:
-                       $extensionList = $extensionList == '*' ? '' : $extensionList;
-                       $files = $this->getFilesInFolder($folder, $extensionList);
-                       $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files') . ' (%s):', count($files)));
-                       $titleLen = intval($GLOBALS['BE_USER']->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 />';
-                       // Init row-array:
-                       $lines = array();
-                       // Add "drag-n-drop" message:
-                       $lines[] = '
-                               <tr>
-                                       <td colspan="2">' . $this->getMsgBox($GLOBALS['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
-                               $fileExtension = strtolower($fileObject->getExtension());
-                               if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('gif,jpeg,jpg,png', $fileExtension)) {
-                                       $imgInfo = @getimagesize($fileObject->getForLocalProcessing(FALSE));
-                                       $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels';
-                                       $size = ' (' . GeneralUtility::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')';
-                                       $filenameAndIcon = IconUtility::getSpriteIconForFile($fileExtension, array('title' => $fileObject->getName() . $size));
-                                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('noLimit')) {
-                                               $maxW = 10000;
-                                               $maxH = 10000;
-                                       } else {
-                                               $maxW = 380;
-                                               $maxH = 500;
-                                       }
-                                       $IW = $imgInfo[0];
-                                       $IH = $imgInfo[1];
-                                       if ($IW > $maxW) {
-                                               $IH = ceil($IH / $IW * $maxW);
-                                               $IW = $maxW;
-                                       }
-                                       if ($IH > $maxH) {
-                                               $IW = ceil($IW / $IH * $maxH);
-                                               $IH = $maxH;
-                                       }
-                                       // Make row:
-                                       $lines[] = '
-                                               <tr class="bgColor4">
-                                                       <td nowrap="nowrap">' . $filenameAndIcon . '&nbsp;</td>
-                                                       <td nowrap="nowrap">' . ($imgInfo[0] != $IW ? '<a href="' . htmlspecialchars(\TYPO3\CMS\Core\Utility\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>' : '') . $pDim . '&nbsp;</td>
-                                               </tr>';
-                                       $lines[] = '
-                                               <tr>
-                                                       <td colspan="2"><img src="' . $iUrl . '" data-htmlarea-file-uid="' . $fileObject->getUid() . '" width="' . $IW . '" height="' . $IH . '" border="1" alt="" /></td>
-                                               </tr>';
-                                       $lines[] = '
-                                               <tr>
-                                                       <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
-                                               </tr>';
+
+               // Read files from directory:
+               $extensionList = $extensionList == '*' ? '' : $extensionList;
+               $files = $this->getFilesInFolder($folder, $extensionList);
+
+               $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files') . ' (%s):', count($files)));
+               $titleLen = intval($GLOBALS['BE_USER']->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 />';
+               // Init row-array:
+               $lines = array();
+               // Add "drag-n-drop" message:
+               $lines[] = '
+                       <tr>
+                               <td colspan="2">' . $this->getMsgBox($GLOBALS['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
+                       $fileExtension = strtolower($fileObject->getExtension());
+                       if (GeneralUtility::inList('gif,jpeg,jpg,png', $fileExtension)) {
+                               $imgInfo = @getimagesize($fileObject->getForLocalProcessing(FALSE));
+                               $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels';
+                               $size = ' (' . GeneralUtility::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')';
+                               $filenameAndIcon = IconUtility::getSpriteIconForFile($fileExtension, array('title' => $fileObject->getName() . $size));
+                               if (GeneralUtility::_GP('noLimit')) {
+                                       $maxW = 10000;
+                                       $maxH = 10000;
+                               } else {
+                                       $maxW = 380;
+                                       $maxH = 500;
                                }
+                               $IW = $imgInfo[0];
+                               $IH = $imgInfo[1];
+                               if ($IW > $maxW) {
+                                       $IH = ceil($IH / $IW * $maxW);
+                                       $IW = $maxW;
+                               }
+                               if ($IH > $maxH) {
+                                       $IW = ceil($IW / $IH * $maxH);
+                                       $IH = $maxH;
+                               }
+                               // Make row:
+                               $lines[] = '
+                                       <tr class="bgColor4">
+                                               <td nowrap="nowrap">' . $filenameAndIcon . '&nbsp;</td>
+                                               <td nowrap="nowrap">' . ($imgInfo[0] != $IW
+                                               ? '<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>'
+                                               : '')
+                                       . $pDim . '&nbsp;</td>
+                                       </tr>';
+                               $lines[] = '
+                                       <tr>
+                                               <td colspan="2"><img src="' . $iUrl . '" data-htmlarea-file-uid="' . $fileObject->getUid()
+                                       . '" width="' . $IW . '" height="' . $IH . '" border="1" alt="" /></td>
+                                       </tr>';
+                               $lines[] = '
+                                       <tr>
+                                               <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
+                                       </tr>';
                        }
-                       // Finally, wrap all rows in a table tag:
-                       $out .= '
+               }
+               // Finally, wrap all rows in a table tag:
+               $out .= '
 
 
-       <!--
-               File listing / Drag-n-drop
-       -->
-                               <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
-                                       ' . implode('', $lines) . '
-                               </table>';
-               } else {
-                       // Print this warning if the folder is NOT a web folder:
-                       $out .= $this->barheader($GLOBALS['LANG']->getLL('files'));
-                       $out .= $this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'), 'icon_warning2');
-               }
+<!--
+       File listing / Drag-n-drop
+-->
+                       <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
+                               ' . implode('', $lines) . '
+                       </table>';
+
                return $out;
        }
 
@@ -1952,7 +2114,8 @@ class ElementBrowser {
         * @todo Define visibility
         */
        public function getMsgBox($in_msg, $icon = 'icon_note') {
-               $msg = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], ('gfx/' . $icon . '.gif'), 'width="18" height="16"') . ' alt="" />' . htmlspecialchars($in_msg);
+               $msg = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], ('gfx/' . $icon . '.gif'), 'width="18" height="16"')
+                       . ' alt="" />' . htmlspecialchars($in_msg);
                $msg = '
 
                        <!--
@@ -1976,22 +2139,23 @@ 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) && ($this->act === 'file' || $this->act === 'folder')) {
+               if (isset($str) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($str)
+                       && ($this->act === 'file' || $this->act === 'folder')
+               ) {
                        try {
                                $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($str);
-                               if (is_object($fileObject)) {
-                                       $str = $fileObject->getIdentifier();
-                               }
                        } catch (\TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException $e) {
-                               $str = '';
+                               $fileObject = NULL;
                        }
+                       $str = is_object($fileObject) ? $fileObject->getIdentifier() : '';
                }
                if (strlen($str)) {
                        return '
                                <!-- Print current URL -->
                                <table border="0" cellpadding="0" cellspacing="0" id="typo3-curUrl">
                                        <tr>
-                                               <td>' . $GLOBALS['LANG']->getLL('currentLink', TRUE) . ': ' . htmlspecialchars(rawurldecode($str)) . '</td>
+                                               <td>' . $GLOBALS['LANG']->getLL('currentLink', TRUE) . ': '
+                                                       . htmlspecialchars(rawurldecode($str)) . '</td>
                                        </tr>
                                </table>';
                } else {
@@ -2024,16 +2188,16 @@ class ElementBrowser {
                                $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);
-                               if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
+                               if ($fileOrFolderObject instanceof Folder) {
                                        $info['act'] = 'folder';
                                        $info['value'] = $fileOrFolderObject->getCombinedIdentifier();
-                               } elseif ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
+                               } elseif ($fileOrFolderObject instanceof File) {
                                        $info['act'] = 'file';
                                        $info['value'] = $fileOrFolderObject->getUid();
                                } else {
                                        $info['value'] = $rel;
                                }
-                       } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($href, $siteUrl)) {
+                       } elseif (GeneralUtility::isFirstPartOfStr($href, $siteUrl)) {
                                // If URL is on the current frontend website:
                                // URL is a file, which exists:
                                if (file_exists(PATH_site . rawurldecode($href))) {
@@ -2059,7 +2223,9 @@ class ElementBrowser {
                                                }
                                                $pageRow = BackendUtility::getRecordWSOL('pages', $id);
                                                $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
-                                               $info['value'] = ((((($GLOBALS['LANG']->getLL('page', TRUE) . ' \'') . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($pageRow['title'], $titleLen))) . '\' (ID:') . $id) . ($uP['fragment'] ? ', #' . $uP['fragment'] : '')) . ')';
+                                               $info['value'] = ((((($GLOBALS['LANG']->getLL('page', TRUE) . ' \'')
+                                                                               . htmlspecialchars(GeneralUtility::fixed_lgd_cs($pageRow['title'], $titleLen)))
+                                                                               . '\' (ID:') . $id) . ($uP['fragment'] ? ', #' . $uP['fragment'] : '')) . ')';
                                                $info['pageid'] = $id;
                                                $info['cElement'] = $uP['fragment'];
                                                $info['act'] = 'page';
@@ -2107,11 +2273,11 @@ class ElementBrowser {
         * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
         * The files are uploaded to the tce_file.php script in the core which will handle the upload.
         *
-        * @param \TYPO3\CMS\Core\Resource\Folder $folderObject Absolute filepath on server to which to upload.
+        * @param Folder $folderObject Absolute filepath on server to which to upload.
         * @return string HTML for an upload form.
         * @todo Define visibility
         */
-       public function uploadForm(\TYPO3\CMS\Core\Resource\Folder $folderObject) {
+       public function uploadForm(Folder $folderObject) {
                if (!$folderObject->checkActionPermission('write')) {
                        return '';
                }
@@ -2129,30 +2295,39 @@ class ElementBrowser {
                        <!--
                                Form, for uploading files:
                        -->
-                       <form action="' . $GLOBALS['BACK_PATH'] . 'tce_file.php" method="post" name="editform" id="typo3-uplFilesForm" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '">
+                       <form action="' . $GLOBALS['BACK_PATH'] . 'tce_file.php" method="post" name="editform"'
+                       . '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('LLL:EXT:lang/locallang_core.xlf:file_upload.php.pagetitle', TRUE) . ':')) . '</td>
+                                               <td>' . $this->barheader($GLOBALS['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> ' . htmlspecialchars($header) . '</td>
+                                               <td class="c-wCell c-hCell"><strong>' . $GLOBALS['LANG']->getLL('path', TRUE) . ':</strong> '
+                                                       . htmlspecialchars($header) . '</td>
                                        </tr>
                                        <tr>
                                                <td class="c-wCell c-hCell">';
                // Traverse the number of upload fields (default is 3):
                for ($a = 1; $a <= $count; $a++) {
-                       $code .= '<input type="file" multiple="multiple" name="upload_' . $a . '"' . $this->doc->formWidth(35) . ' size="50" />
-                               <input type="hidden" name="file[upload][' . $a . '][target]" value="' . htmlspecialchars($folderObject->getCombinedIdentifier()) . '" />
+                       $code .= '<input type="file" multiple="multiple" name="upload_' . $a . '"' . $this->doc->formWidth(35)
+                                       . ' size="50" />
+                               <input type="hidden" name="file[upload][' . $a . '][target]" value="'
+                                       . htmlspecialchars($folderObject->getCombinedIdentifier()) . '" />
                                <input type="hidden" name="file[upload][' . $a . '][data]" value="' . $a . '" /><br />';
                }
                // Make footer of upload form, including the submit button:
-               $redirectValue = $this->thisScript . '?act=' . $this->act . '&mode=' . $this->mode . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier()) . '&bparams=' . rawurlencode($this->bparams);
+               $redirectValue = $this->thisScript . '?act=' . $this->act . '&mode=' . $this->mode
+                       . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier())
+                       . '&bparams=' . rawurlencode($this->bparams);
                $code .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($redirectValue) . '" />';
                $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) . '</label>
+                               <label><input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> '
+                                       . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xlf:overwriteExistingFiles', TRUE) . '</label>
                        </div>
-                       <input type="submit" name="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_upload.php.submit', TRUE) . '" />
+                       <input type="submit" name="submit" value="'
+                                       . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_upload.php.submit', TRUE) . '" />
                ';
                $code .= '</td>
                                        </tr>
@@ -2165,11 +2340,11 @@ class ElementBrowser {
         * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
         * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
         *
-        * @param \TYPO3\CMS\Core\Resource\Folder $folderObject Absolute filepath on server in which to create the new folder.
+        * @param Folder $folderObject Absolute filepath on server in which to create the new folder.
         * @return string HTML for the create folder form.
         * @todo Define visibility
         */
-       public function createFolder(\TYPO3\CMS\Core\Resource\Folder $folderObject) {
+       public function createFolder(Folder $folderObject) {
                if (!$folderObject->checkActionPermission('write')) {
                        return '';
                }
@@ -2190,19 +2365,27 @@ 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('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.pagetitle') . ':')) . '</td>
+                                               <td>' . $this->barheader($GLOBALS['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>
+                                               <td class="c-wCell c-hCell"><strong>'
+                                                       . $GLOBALS['LANG']->getLL('path', TRUE) . ':</strong> ' . htmlspecialchars($header) . '</td>
                                        </tr>
                                        <tr>
                                                <td class="c-wCell c-hCell">';
                // Create the new-folder name field:
                $a = 1;
-               $code .= '<input' . $this->doc->formWidth(20) . ' type="text" name="file[newfolder][' . $a . '][data]" />' . '<input type="hidden" name="file[newfolder][' . $a . '][target]" value="' . htmlspecialchars($folderObject->getCombinedIdentifier()) . '" />';
+               $code .= '<input' . $this->doc->formWidth(20) . ' type="text" name="file[newfolder][' . $a . '][data]" />'
+                               . '<input type="hidden" name="file[newfolder][' . $a . '][target]" value="'
+                               . htmlspecialchars($folderObject->getCombinedIdentifier()) . '" />';
                // Make footer of upload form, including the submit button:
-               $redirectValue = $this->thisScript . '?act=' . $this->act . '&mode=' . $this->mode . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier()) . '&bparams=' . rawurlencode($this->bparams);
-               $code .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($redirectValue) . '" />' . '<input type="submit" name="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.submit', TRUE) . '" />';
+               $redirectValue = $this->thisScript . '?act=' . $this->act . '&mode=' . $this->mode
+                       . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier())
+                       . '&bparams=' . rawurlencode($this->bparams);
+               $code .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($redirectValue) . '" />'
+                       . '<input type="submit" name="submit" value="'
+                       . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.submit', TRUE) . '" />';
                $code .= '</td>
                                        </tr>
                                </table>
@@ -2218,24 +2401,36 @@ class ElementBrowser {
         * @todo Define visibility
         */
        public function getBulkSelector($filesCount) {
-               if ($filesCount) {
-                       $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);
-                       // Getting flag for showing/not showing thumbnails:
-                       $noThumbsInEB = $GLOBALS['BE_USER']->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' => '');
-                               $_MCONF['name'] = 'file_list';
-                               $_MOD_SETTINGS = BackendUtility::getModuleData($_MOD_MENU, GeneralUtility::_GP('SET'), $_MCONF['name']);
-                               $addParams = '&act=' . $this->act . '&mode=' . $this->mode . '&expandFolder=' . rawurlencode($this->selectedFolder->getCombinedIdentifier()) . '&bparams=' . rawurlencode($this->bparams);
-                               $thumbNailCheck = BackendUtility::getFuncCheck('', 'SET[displayThumbs]', $_MOD_SETTINGS['displayThumbs'], $this->thisScript, $addParams, 'id="checkDisplayThumbs"') . ' <label for="checkDisplayThumbs">' . $GLOBALS['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);
-                       }
+               if (!$filesCount) {
+                       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);
+               // Getting flag for showing/not showing thumbnails:
+               $noThumbsInEB = $GLOBALS['BE_USER']->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' => '');
+                       $_MCONF['name'] = 'file_list';
+                       $_MOD_SETTINGS = BackendUtility::getModuleData($_MOD_MENU, GeneralUtility::_GP('SET'), $_MCONF['name']);
+                       $addParams = '&act=' . $this->act . '&mode=' . $this->mode
+                               . '&expandFolder=' . rawurlencode($this->selectedFolder->getCombinedIdentifier())
+                               . '&bparams=' . rawurlencode($this->bparams);
+                       $thumbNailCheck = BackendUtility::getFuncCheck('', 'SET[displayThumbs]', $_MOD_SETTINGS['displayThumbs'],
+                                       $this->thisScript, $addParams, 'id="checkDisplayThumbs"')
+                               . ' <label for="checkDisplayThumbs">'
+                               . $GLOBALS['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);
                }
                return $out;
        }