[TASK] Add tool-function to strip PATH_site-part of paths
[Packages/TYPO3.CMS.git] / typo3 / sysext / recordlist / Classes / Browser / ElementBrowser.php
index c2309df..27ce173 100644 (file)
@@ -27,6 +27,10 @@ namespace TYPO3\CMS\Recordlist\Browser;
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Backend\Utility\IconUtility;
+
 /**
  * class for the Element Browser window.
  *
@@ -225,20 +229,20 @@ class ElementBrowser {
         */
        public function init() {
                // Main GPvars:
-               $this->pointer = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('pointer');
-               $this->bparams = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('bparams');
-               $this->P = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('P');
-               $this->RTEtsConfigParams = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('RTEtsConfigParams');
-               $this->expandPage = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('expandPage');
-               $this->expandFolder = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('expandFolder');
-               $this->PM = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('PM');
+               $this->pointer = GeneralUtility::_GP('pointer');
+               $this->bparams = GeneralUtility::_GP('bparams');
+               $this->P = GeneralUtility::_GP('P');
+               $this->RTEtsConfigParams = GeneralUtility::_GP('RTEtsConfigParams');
+               $this->expandPage = GeneralUtility::_GP('expandPage');
+               $this->expandFolder = GeneralUtility::_GP('expandFolder');
+               $this->PM = GeneralUtility::_GP('PM');
                // Find "mode"
-               $this->mode = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('mode');
+               $this->mode = GeneralUtility::_GP('mode');
                if (!$this->mode) {
                        $this->mode = 'rte';
                }
                // Creating backend template object:
-               $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
+               $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
                $this->doc->backPath = $GLOBALS['BACK_PATH'];
                // Load the Prototype library and browse_links.js
                $this->doc->getPageRenderer()->loadPrototype();
@@ -248,7 +252,7 @@ class ElementBrowser {
                $this->hookObjects = array();
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'])) {
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'] as $classData) {
-                               $processObject = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classData);
+                               $processObject = GeneralUtility::getUserObj($classData);
                                if (!$processObject instanceof \TYPO3\CMS\Core\ElementBrowser\ElementBrowserHookInterface) {
                                        throw new \UnexpectedValueException('$processObject must implement interface TYPO3\\CMS\\Core\\ElementBrowser\\ElementBrowserHookInterface', 1195039394);
                                }
@@ -259,21 +263,21 @@ class ElementBrowser {
                }
                // Site URL
                // Current site url
-               $this->siteURL = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
+               $this->siteURL = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
                // The script to link to
-               $this->thisScript = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('SCRIPT_NAME');
+               $this->thisScript = GeneralUtility::getIndpEnv('SCRIPT_NAME');
                // Init fileProcessor
-               $this->fileProcessor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\File\\BasicFileUtility');
+               $this->fileProcessor = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\File\\BasicFileUtility');
                $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
                // CurrentUrl - the current link url must be passed around if it exists
                if ($this->mode == 'wizard') {
-                       $currentValues = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, trim($this->P['currentValue']));
+                       $currentValues = GeneralUtility::trimExplode(LF, trim($this->P['currentValue']));
                        if (count($currentValues) > 0) {
                                $currentValue = array_pop($currentValues);
                        } else {
                                $currentValue = '';
                        }
-                       $currentLinkParts = \TYPO3\CMS\Core\Utility\GeneralUtility::unQuoteFilenames($currentValue, TRUE);
+                       $currentLinkParts = GeneralUtility::unQuoteFilenames($currentValue, TRUE);
                        $initialCurUrlArray = array(
                                'href' => $currentLinkParts[0],
                                'target' => $currentLinkParts[1],
@@ -281,7 +285,7 @@ class ElementBrowser {
                                'title' => $currentLinkParts[3],
                                'params' => $currentLinkParts[4]
                        );
-                       $this->curUrlArray = is_array(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('curUrl')) ? array_merge($initialCurUrlArray, \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('curUrl')) : $initialCurUrlArray;
+                       $this->curUrlArray = is_array(\TYPO3\CMS\Core\Utility\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'])) {
                                $_params = array(
@@ -289,7 +293,7 @@ class ElementBrowser {
                                        'linkParts' => $currentLinkParts
                                );
                                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendUrlArray'] as $objRef) {
-                                       $processor =& \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($objRef);
+                                       $processor =& GeneralUtility::getUserObj($objRef);
                                        $processor->extendUrlArray($_params, $this);
                                }
                        }
@@ -303,7 +307,7 @@ class ElementBrowser {
                                        $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)) {
-                                               $currentLinkParts[0] = substr($this->curUrlArray['href'], strlen(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'], '@')) {
@@ -326,14 +330,14 @@ class ElementBrowser {
                                $this->curUrlInfo = $this->parseCurUrl($this->siteURL . '?id=' . $this->curUrlArray['href'], $this->siteURL);
                        }
                } else {
-                       $this->curUrlArray = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('curUrl');
+                       $this->curUrlArray = GeneralUtility::_GP('curUrl');
                        if ($this->curUrlArray['all']) {
-                               $this->curUrlArray = \TYPO3\CMS\Core\Utility\GeneralUtility::get_tag_attributes($this->curUrlArray['all']);
+                               $this->curUrlArray = GeneralUtility::get_tag_attributes($this->curUrlArray['all']);
                        }
                        $this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'], $this->siteURL);
                }
                // Determine nature of current url:
-               $this->act = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('act');
+               $this->act = GeneralUtility::_GP('act');
                if (!$this->act) {
                        $this->act = $this->curUrlInfo['act'];
                }
@@ -342,8 +346,8 @@ class ElementBrowser {
                if ((string) $this->mode == 'rte') {
                        $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
                        $addPassOnParams .= '&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams);
-                       $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
-                       $this->thisConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
+                       $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
+                       $this->thisConfig = BackendUtility::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
                }
                // Initializing the target value (RTE)
                $this->setTarget = $this->curUrlArray['target'] != '-' ? rawurlencode($this->curUrlArray['target']) : '';
@@ -407,11 +411,11 @@ class ElementBrowser {
                        $P2['itemName'] = $this->P['itemName'];
                        $P2['formName'] = $this->P['formName'];
                        $P2['fieldChangeFunc'] = $this->P['fieldChangeFunc'];
-                       $P2['fieldChangeFuncHash'] = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac(serialize($this->P['fieldChangeFunc']));
+                       $P2['fieldChangeFuncHash'] = GeneralUtility::hmac(serialize($this->P['fieldChangeFunc']));
                        $P2['params']['allowedExtensions'] = $this->P['params']['allowedExtensions'];
                        $P2['params']['blindLinkOptions'] = $this->P['params']['blindLinkOptions'];
                        $P2['params']['blindLinkFields'] = $this->P['params']['blindLinkFields'];
-                       $addPassOnParams .= \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('P', $P2);
+                       $addPassOnParams .= GeneralUtility::implodeArrayForUrl('P', $P2);
                        $JScode .= '
                                function link_typo3Page(id,anchor) {    //
                                        updateValueInMainForm(id + (anchor ? anchor : ""));
@@ -512,7 +516,7 @@ 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 . '"' : '') . '+(anchor?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;
                        }
@@ -643,7 +647,7 @@ class ElementBrowser {
                                'addPassOnParams' => $addPassOnParams
                        );
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendJScode'] as $objRef) {
-                               $processor =& \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($objRef);
+                               $processor =& GeneralUtility::getUserObj($objRef);
                                $JScode .= $processor->extendJScode($_params, $this);
                        }
                }
@@ -662,26 +666,26 @@ class ElementBrowser {
        public function processSessionData($data) {
                $store = FALSE;
                switch ((string) $this->mode) {
-               case 'db':
-                       if (isset($this->expandPage)) {
-                               $data['expandPage'] = $this->expandPage;
-                               $store = TRUE;
-                       } else {
-                               $this->expandPage = $data['expandPage'];
-                       }
-                       break;
-               case 'file':
+                       case 'db':
+                               if (isset($this->expandPage)) {
+                                       $data['expandPage'] = $this->expandPage;
+                                       $store = TRUE;
+                               } else {
+                                       $this->expandPage = $data['expandPage'];
+                               }
+                               break;
+                       case 'file':
 
-               case 'filedrag':
+                       case 'filedrag':
 
-               case 'folder':
-                       if (isset($this->expandFolder)) {
-                               $data['expandFolder'] = $this->expandFolder;
-                               $store = TRUE;
-                       } else {
-                               $this->expandFolder = $data['expandFolder'];
-                       }
-                       break;
+                       case 'folder':
+                               if (isset($this->expandFolder)) {
+                                       $data['expandFolder'] = $this->expandFolder;
+                                       $store = TRUE;
+                               } else {
+                                       $this->expandFolder = $data['expandFolder'];
+                               }
+                               break;
                }
                return array($data, $store);
        }
@@ -704,14 +708,14 @@ class ElementBrowser {
                // Starting content:
                $content = $this->doc->startPage('RTE link');
                // Initializing the action value, possibly removing blinded values etc:
-               $allowedItems = array_diff(explode(',', 'page,file,folder,url,mail,spec'), \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->thisConfig['blindLinkOptions'], 1));
-               $allowedItems = array_diff($allowedItems, \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->P['params']['blindLinkOptions']));
+               $allowedItems = array_diff(explode(',', 'page,file,folder,url,mail,spec'), GeneralUtility::trimExplode(',', $this->thisConfig['blindLinkOptions'], TRUE));
+               $allowedItems = array_diff($allowedItems, GeneralUtility::trimExplode(',', $this->P['params']['blindLinkOptions']));
                // Call hook for extra options
                foreach ($this->hookObjects as $hookObject) {
                        $allowedItems = $hookObject->addAllowedItems($allowedItems);
                }
                // Removing link fields if configured
-               $allowedFields = array_diff(array('target', 'title', 'class', 'params'), \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->thisConfig['blindLinkFields'], TRUE), \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->P['params']['blindLinkFields'], TRUE));
+               $allowedFields = array_diff(array('target', 'title', 'class', 'params'), GeneralUtility::trimExplode(',', $this->thisConfig['blindLinkFields'], TRUE), GeneralUtility::trimExplode(',', $this->P['params']['blindLinkFields'], TRUE));
                // If $this->act is not allowed, default to first allowed
                if (!in_array($this->act, $allowedItems)) {
                        $this->act = reset($allowedItems);
@@ -720,43 +724,43 @@ class ElementBrowser {
                $menuDef = array();
                if (!$wiz) {
                        $menuDef['removeLink']['isActive'] = $this->act == 'removeLink';
-                       $menuDef['removeLink']['label'] = $GLOBALS['LANG']->getLL('removeLink', 1);
+                       $menuDef['removeLink']['label'] = $GLOBALS['LANG']->getLL('removeLink', TRUE);
                        $menuDef['removeLink']['url'] = '#';
                        $menuDef['removeLink']['addParams'] = 'onclick="self.parent.parent.renderPopup_unLink();return false;"';
                }
                if (in_array('page', $allowedItems)) {
                        $menuDef['page']['isActive'] = $this->act == 'page';
-                       $menuDef['page']['label'] = $GLOBALS['LANG']->getLL('page', 1);
+                       $menuDef['page']['label'] = $GLOBALS['LANG']->getLL('page', TRUE);
                        $menuDef['page']['url'] = '#';
                        $menuDef['page']['addParams'] = 'onclick="jumpToUrl(\'?act=page\');return false;"';
                }
                if (in_array('file', $allowedItems)) {
                        $menuDef['file']['isActive'] = $this->act == 'file';
-                       $menuDef['file']['label'] = $GLOBALS['LANG']->getLL('file', 1);
+                       $menuDef['file']['label'] = $GLOBALS['LANG']->getLL('file', TRUE);
                        $menuDef['file']['url'] = '#';
                        $menuDef['file']['addParams'] = 'onclick="jumpToUrl(\'?act=file\');return false;"';
                }
                if (in_array('folder', $allowedItems)) {
                        $menuDef['folder']['isActive'] = $this->act == 'folder';
-                       $menuDef['folder']['label'] = $GLOBALS['LANG']->getLL('folder', 1);
+                       $menuDef['folder']['label'] = $GLOBALS['LANG']->getLL('folder', TRUE);
                        $menuDef['folder']['url'] = '#';
                        $menuDef['folder']['addParams'] = 'onclick="jumpToUrl(\'?act=folder\');return false;"';
                }
                if (in_array('url', $allowedItems)) {
                        $menuDef['url']['isActive'] = $this->act == 'url';
-                       $menuDef['url']['label'] = $GLOBALS['LANG']->getLL('extUrl', 1);
+                       $menuDef['url']['label'] = $GLOBALS['LANG']->getLL('extUrl', TRUE);
                        $menuDef['url']['url'] = '#';
                        $menuDef['url']['addParams'] = 'onclick="jumpToUrl(\'?act=url\');return false;"';
                }
                if (in_array('mail', $allowedItems)) {
                        $menuDef['mail']['isActive'] = $this->act == 'mail';
-                       $menuDef['mail']['label'] = $GLOBALS['LANG']->getLL('email', 1);
+                       $menuDef['mail']['label'] = $GLOBALS['LANG']->getLL('email', TRUE);
                        $menuDef['mail']['url'] = '#';
                        $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(\'?act=mail\');return false;"';
                }
                if (is_array($this->thisConfig['userLinks.']) && in_array('spec', $allowedItems)) {
                        $menuDef['spec']['isActive'] = $this->act == 'spec';
-                       $menuDef['spec']['label'] = $GLOBALS['LANG']->getLL('special', 1);
+                       $menuDef['spec']['label'] = $GLOBALS['LANG']->getLL('special', TRUE);
                        $menuDef['spec']['url'] = '#';
                        $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(\'?act=spec\');return false;"';
                }
@@ -769,197 +773,197 @@ class ElementBrowser {
                $content .= $this->printCurrentUrl($this->curUrlInfo['info']) . '<br />';
                // Depending on the current action we will create the actual module content for selecting a link:
                switch ($this->act) {
-               case 'mail':
-                       $extUrl = '
+                       case 'mail':
+                               $extUrl = '
 
-                       <!--
-                               Enter mail address:
-                       -->
-                                       <form action="" name="lurlform" id="lurlform">
-                                               <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
-                                                       <tr>
-                                                               <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('emailAddress', 1) . ':</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', 1) . '" onclick="browse_links_setTarget(\'\');browse_links_setValue(\'mailto:\'+document.lurlform.lemail.value); return link_current();" /></td>
-                                                       </tr>
-                                               </table>
-                                       </form>';
-                       $content .= $extUrl;
-                       break;
-               case 'url':
-                       $extUrl = '
+                               <!--
+                                       Enter mail address:
+                               -->
+                                               <form action="" name="lurlform" id="lurlform">
+                                                       <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>
+                                                               </tr>
+                                                       </table>
+                                               </form>';
+                               $content .= $extUrl;
+                               break;
+                       case 'url':
+                               $extUrl = '
 
-                       <!--
-                               Enter External URL:
-                       -->
-                                       <form action="" name="lurlform" id="lurlform">
-                                               <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', 1) . '" onclick="browse_links_setValue(document.lurlform.lurl.value); return link_current();" /></td>
-                                                       </tr>
-                                               </table>
-                                       </form>';
-                       $content .= $extUrl;
-                       break;
-               case 'file':
-
-               case 'folder':
-                       $foldertree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('rteFolderTree');
-                       $foldertree->thisScript = $this->thisScript;
-                       $tree = $foldertree->getBrowsableTree();
-                       if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act'] != $this->act) {
-                               $cmpPath = '';
-                       } else {
-                               $cmpPath = $this->curUrlInfo['value'];
-                               if (!isset($this->expandFolder)) {
-                                       $this->expandFolder = $cmpPath;
+                               <!--
+                                       Enter External URL:
+                               -->
+                                               <form action="" name="lurlform" id="lurlform">
+                                                       <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>
+                                                               </tr>
+                                                       </table>
+                                               </form>';
+                               $content .= $extUrl;
+                               break;
+                       case 'file':
+
+                       case 'folder':
+                               $foldertree = GeneralUtility::makeInstance('rteFolderTree');
+                               $foldertree->thisScript = $this->thisScript;
+                               $tree = $foldertree->getBrowsableTree();
+                               if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act'] != $this->act) {
+                                       $cmpPath = '';
+                               } else {
+                                       $cmpPath = $this->curUrlInfo['value'];
+                                       if (!isset($this->expandFolder)) {
+                                               $this->expandFolder = $cmpPath;
+                                       }
                                }
-                       }
-                       // Create upload/create folder forms, if a path is given
-                       if ($this->expandFolder) {
-                               $selectedFolder = FALSE;
-                               $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
+                               // Create upload/create folder forms, if a path is given
+                               if ($this->expandFolder) {
+                                       $selectedFolder = FALSE;
+                                       try {
+                                               $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
+                                       } catch (\Exception $e) {
+                                       }
 
-                               if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
-                                       // It's a folder
-                                       $selectedFolder = $fileOrFolderObject;
-                               } elseif ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
-                                       // It's a file
-                                       // @todo: find the parent folder, right now done a bit ugly, because the file does not
-                                       // support finding the parent folder of a file on purpose
-                                       $folderIdentifier = dirname($fileOrFolderObject->getIdentifier());
-                                       $selectedFolder = $fileOrFolderObject->getStorage()->getFolder($folderIdentifier);
+                                       if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
+                                               // It's a folder
+                                               $selectedFolder = $fileOrFolderObject;
+                                       } elseif ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
+                                               // It's a file
+                                               // @todo: find the parent folder, right now done a bit ugly, because the file does not
+                                               // support finding the parent folder of a file on purpose
+                                               $folderIdentifier = dirname($fileOrFolderObject->getIdentifier());
+                                               $selectedFolder = $fileOrFolderObject->getStorage()->getFolder($folderIdentifier);
+                                       }
                                }
-                       }
-                       // Or get the user's default upload folder
-                       if (!$selectedFolder) {
-                               $selectedFolder = $GLOBALS['BE_USER']->getDefaultUploadFolder();
-                       }
-                       // Build the file upload and folder creation form
-                       $uploadForm = '';
-                       $createFolder = '';
-                       if ($selectedFolder && !$this->isReadOnlyFolder($selectedFolder)) {
-                               $uploadForm = ($this->act === 'file') ? $this->uploadForm($selectedFolder) : '';
-                               if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
+                               // Or get the user's default upload folder
+                               if (!$selectedFolder) {
+                                       $selectedFolder = $GLOBALS['BE_USER']->getDefaultUploadFolder();
+                               }
+                               // Build the file upload and folder creation form
+                               $uploadForm = '';
+                               $createFolder = '';
+                               if ($selectedFolder) {
+                                       $uploadForm = ($this->act === 'file') ? $this->uploadForm($selectedFolder) : '';
                                        $createFolder = $this->createFolder($selectedFolder);
                                }
-                       }
-                       // Insert the upload form on top, if so configured
-                       if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
-                               $content .= $uploadForm;
-                       }
+                               // Insert the upload form on top, if so configured
+                               if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
+                                       $content .= $uploadForm;
+                               }
 
-                       // Render the filelist if there is a folder selected
-                       if ($selectedFolder) {
-                               $files = $this->expandFolder($selectedFolder, $this->P['params']['allowedExtensions']);
-                       }
-                       $this->doc->JScode .= $this->doc->wrapScriptTags('
-                       Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
-               ');
-                       $content .= '
-                       <!--
-                               Wrapper table for folder tree / file/folder list:
-                       -->
-                                       <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">' . $files . '</td>
-                                               </tr>
-                                       </table>
-                                       <br />
-                                       ';
-                       // Adding create folder + upload forms if applicable
-                       if (!$GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
-                               $content .= $uploadForm;
-                       }
-                       $content .= $createFolder . '<br />';
-                       break;
-               case 'spec':
-                       if (is_array($this->thisConfig['userLinks.'])) {
-                               $subcats = array();
-                               $v = $this->thisConfig['userLinks.'];
-                               foreach ($v as $k2 => $value) {
-                                       $k2i = intval($k2);
-                                       if (substr($k2, -1) == '.' && is_array($v[$k2i . '.'])) {
-                                               // Title:
-                                               $title = trim($v[$k2i]);
-                                               if (!$title) {
-                                                       $title = $v[$k2i . '.']['url'];
-                                               } else {
-                                                       $title = $GLOBALS['LANG']->sL($title);
-                                               }
-                                               // Description:
-                                               $description = $v[$k2i . '.']['description'] ? $GLOBALS['LANG']->sL($v[($k2i . '.')]['description'], 1) . '<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:') {
-                                                       $onClickEvent .= 'cur_href=unescape(\'' . rawurlencode($v[($k2i . '.')]['url']) . '\');link_current();';
-                                               } else {
-                                                       $onClickEvent .= 'link_spec(unescape(\'' . $this->siteURL . rawurlencode($v[($k2i . '.')]['url']) . '\'));';
+                               // Render the filelist if there is a folder selected
+                               if ($selectedFolder) {
+                                       $files = $this->expandFolder($selectedFolder, $this->P['params']['allowedExtensions']);
+                               }
+                               $this->doc->JScode .= $this->doc->wrapScriptTags('
+                               Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
+                       ');
+                               $content .= '
+                               <!--
+                                       Wrapper table for folder tree / file/folder list:
+                               -->
+                                               <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">' . $files . '</td>
+                                                       </tr>
+                                               </table>
+                                               <br />
+                                               ';
+                               // Adding create folder + upload forms if applicable
+                               if (!$GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
+                                       $content .= $uploadForm;
+                               }
+                               $content .= $createFolder . '<br />';
+                               break;
+                       case 'spec':
+                               if (is_array($this->thisConfig['userLinks.'])) {
+                                       $subcats = array();
+                                       $v = $this->thisConfig['userLinks.'];
+                                       foreach ($v as $k2 => $value) {
+                                               $k2i = intval($k2);
+                                               if (substr($k2, -1) == '.' && is_array($v[$k2i . '.'])) {
+                                                       // Title:
+                                                       $title = trim($v[$k2i]);
+                                                       if (!$title) {
+                                                               $title = $v[$k2i . '.']['url'];
+                                                       } else {
+                                                               $title = $GLOBALS['LANG']->sL($title);
+                                                       }
+                                                       // Description:
+                                                       $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:') {
+                                                               $onClickEvent .= 'cur_href=unescape(\'' . rawurlencode($v[($k2i . '.')]['url']) . '\');link_current();';
+                                                       } else {
+                                                               $onClickEvent .= 'link_spec(unescape(\'' . $this->siteURL . rawurlencode($v[($k2i . '.')]['url']) . '\'));';
+                                                       }
+                                                       // Link:
+                                                       $A = array('<a href="#" onclick="' . htmlspecialchars($onClickEvent) . 'return false;">', '</a>');
+                                                       // 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>
+                                                                       </tr>';
                                                }
-                                               // Link:
-                                               $A = array('<a href="#" onclick="' . htmlspecialchars($onClickEvent) . 'return false;">', '</a>');
-                                               // 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' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_right.gif', 'width="5" height="9"') . ' class="c-blinkArrowR" alt="" />' : '') . '</strong><br />' . $description . $A[1] . '</td>
-                                                               </tr>';
                                        }
+                                       // Sort by keys:
+                                       ksort($subcats);
+                                       // Add menu to content:
+                                       $content .= '
+
+                               <!--
+                                       Special userdefined menu:
+                               -->
+                                                       <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>
+                                                               </tr>
+                                                               ' . implode('', $subcats) . '
+                                                       </table>
+                                                       ';
+                               }
+                               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();
+                               $cElements = $this->expandPage();
+                               // Outputting Temporary DB mount notice:
+                               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);
+                                       $dbmount = $flashMessage->render();
                                }
-                               // Sort by keys:
-                               ksort($subcats);
-                               // Add menu to content:
                                $content .= '
 
-                       <!--
-                               Special userdefined menu:
-                       -->
-                                               <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
+                               <!--
+                                       Wrapper table for page tree / record list:
+                               -->
+                                               <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
                                                        <tr>
-                                                               <td class="bgColor5" class="c-wCell" valign="top"><strong>' . $GLOBALS['LANG']->getLL('special', 1) . '</strong></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>
-                                                       ' . implode('', $subcats) . '
                                                </table>
                                                ';
-                       }
-                       break;
-               case 'page':
-                       $pagetree = \TYPO3\CMS\Core\Utility\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:
-                       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', 1) . '</a>';
-                               $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $link, '', \TYPO3\CMS\Core\Messaging\FlashMessage::INFO);
-                               $dbmount = $flashMessage->render();
-                       }
-                       $content .= '
-
-                       <!--
-                               Wrapper table for page tree / record list:
-                       -->
-                                       <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">' . $cElements . '</td>
-                                               </tr>
-                                       </table>
-                                       ';
-                       break;
-               default:
-                       // Call hook
-                       foreach ($this->hookObjects as $hookObject) {
-                               $content .= $hookObject->getTab($this->act);
-                       }
-                       break;
+                               break;
+                       default:
+                               // Call hook
+                               foreach ($this->hookObjects as $hookObject) {
+                                       $content .= $hookObject->getTab($this->act);
+                               }
                }
                if (in_array('params', $allowedFields, TRUE)) {
                        $content .= '
@@ -969,7 +973,7 @@ class ElementBrowser {
                                <form action="" name="lparamsform" id="lparamsform">
                                        <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkParams">
                                                <tr>
-                                                       <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('params', 1) . '</td>
+                                                       <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>
                                                </tr>
                                        </table>
@@ -984,7 +988,7 @@ class ElementBrowser {
                                <form action="" name="lclassform" id="lclassform">
                                        <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkClass">
                                                <tr>
-                                                       <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('class', 1) . '</td>
+                                                       <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>
                                                </tr>
                                        </table>
@@ -999,7 +1003,7 @@ class ElementBrowser {
                                <form action="" name="ltitleform" id="ltitleform">
                                        <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTitle">
                                                <tr>
-                                                       <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('title', 1) . '</td>
+                                                       <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>
                                                </tr>
                                        </table>
@@ -1012,7 +1016,7 @@ class ElementBrowser {
                                'conf' => &$conf
                        );
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['addFields_PageLink'] as $objRef) {
-                               $processor =& \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($objRef);
+                               $processor =& GeneralUtility::getUserObj($objRef);
                                $content .= $processor->addFields($_params, $this);
                        }
                }
@@ -1026,19 +1030,19 @@ class ElementBrowser {
                                <form action="" name="ltargetform" id="ltargetform">
                                        <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
                                                <tr>
-                                                       <td>' . $GLOBALS['LANG']->getLL('target', 1) . ':</td>
+                                                       <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>
                                                                <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', 1) . '</option>
-                                                                       <option value="_blank">' . $GLOBALS['LANG']->getLL('newWindow', 1) . '</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) {
                                $ltarget .= '
-                                                       <input type="submit" value="' . $GLOBALS['LANG']->getLL('update', 1) . '" 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) {
@@ -1054,10 +1058,10 @@ class ElementBrowser {
                        $ltarget .= '           </td>
                                                </tr>
                                                <tr>
-                                                       <td>' . $GLOBALS['LANG']->getLL('target_popUpWindow', 1) . ':</td>
+                                                       <td>' . $GLOBALS['LANG']->getLL('target_popUpWindow', TRUE) . ':</td>
                                                        <td colspan="3">
                                                                <select name="popup_width" onchange="' . htmlspecialchars($selectJS) . '">
-                                                                       <option value="0">' . $GLOBALS['LANG']->getLL('target_popUpWindow_width', 1) . '</option>
+                                                                       <option value="0">' . $GLOBALS['LANG']->getLL('target_popUpWindow_width', TRUE) . '</option>
                                                                        <option value="300">300</option>
                                                                        <option value="400">400</option>
                                                                        <option value="500">500</option>
@@ -1067,7 +1071,7 @@ class ElementBrowser {
                                                                </select>
                                                                x
                                                                <select name="popup_height" onchange="' . htmlspecialchars($selectJS) . '">
-                                                                       <option value="0">' . $GLOBALS['LANG']->getLL('target_popUpWindow_height', 1) . '</option>
+                                                                       <option value="0">' . $GLOBALS['LANG']->getLL('target_popUpWindow_height', TRUE) . '</option>
                                                                        <option value="200">200</option>
                                                                        <option value="300">300</option>
                                                                        <option value="400">400</option>
@@ -1102,7 +1106,7 @@ class ElementBrowser {
                $pArr = explode('|', $this->bparams);
                $tables = $pArr[3];
                // Making the browsable pagetree:
-               $pagetree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TBE_PageTree');
+               $pagetree = GeneralUtility::makeInstance('TBE_PageTree');
                $pagetree->thisScript = $this->thisScript;
                $pagetree->ext_pArrPages = !strcmp($tables, 'pages') ? 1 : 0;
                $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
@@ -1110,7 +1114,7 @@ class ElementBrowser {
 
                $withTree = TRUE;
                if (($tables !== '') && ($tables !== '*')) {
-                       $tablesArr = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $tables, TRUE);
+                       $tablesArr = GeneralUtility::trimExplode(',', $tables, TRUE);
                        $onlyRootLevel = TRUE;
                        foreach ($tablesArr as $currentTable) {
                                $tableTca = $GLOBALS['TCA'][$currentTable];
@@ -1178,7 +1182,7 @@ class ElementBrowser {
                $this->storages = $GLOBALS['BE_USER']->getFileStorages();
                if (isset($allowedFileExtensions)) {
                        // Create new filter object
-                       $filterObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Filter\\FileExtensionFilter');
+                       $filterObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Filter\\FileExtensionFilter');
                        $filterObject->setAllowedFileExtensions($allowedFileExtensions);
                        // Set file extension filters on all storages
                        /** @var $storage \TYPO3\CMS\Core\Resource\ResourceStorage */
@@ -1208,17 +1212,9 @@ class ElementBrowser {
                        // Build the file upload and folder creation form
                $uploadForm = '';
                $createFolder = '';
-               if ($this->selectedFolder && !$this->isReadOnlyFolder($this->selectedFolder)) {
-                       $uploadForm = ($this->act === 'file') ? $this->uploadForm($this->selectedFolder) : '';
-                       if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
-                               $createFolder =  $this->createFolder($this->selectedFolder);
-                       }
-               }
                if ($this->selectedFolder) {
                        $uploadForm = $this->uploadForm($this->selectedFolder);
                        $createFolder = $this->createFolder($this->selectedFolder);
-               } else {
-                       $uploadForm = $createFolder = '';
                }
                // Insert the upload form on top, if so configured
                if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
@@ -1230,19 +1226,23 @@ class ElementBrowser {
                        // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
                        $_MOD_MENU = array('displayThumbs' => '');
                        $_MCONF['name'] = 'file_list';
-                       $_MOD_SETTINGS = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData($_MOD_MENU, \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('SET'), $_MCONF['name']);
+                       $_MOD_SETTINGS = BackendUtility::getModuleData($_MOD_MENU, GeneralUtility::_GP('SET'), $_MCONF['name']);
                }
                $noThumbs = $noThumbs ? $noThumbs : !$_MOD_SETTINGS['displayThumbs'];
                // Create folder tree:
-               $foldertree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TBE_FolderTree');
+               $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->mode == 'filedrag') {
-                       $files = $this->TBE_dragNDrop($this->selectedFolder, $pArr[3]);
+               if ($this->selectedFolder) {
+                       if ($this->mode == 'filedrag') {
+                               $files = $this->TBE_dragNDrop($this->selectedFolder, $pArr[3]);
+                       } else {
+                               $files = $this->TBE_expandFolder($this->selectedFolder, $pArr[3], $noThumbs);
+                       }
                } else {
-                       $files = $this->TBE_expandFolder($this->selectedFolder, $pArr[3], $noThumbs);
+                       $files = '';
                }
                // Putting the parts together, side by side:
                $content .= '
@@ -1292,13 +1292,13 @@ class ElementBrowser {
                if ($this->expandFolder) {
                        $this->selectedFolder = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder);
                }
-               if ($this->selectedFolder && !$this->isReadOnlyFolder($this->selectedFolder)) {
+               if ($this->selectedFolder) {
                        $createFolder = $this->createFolder($this->selectedFolder);
                } else {
                        $createFolder = '';
                }
                // Create folder tree:
-               $foldertree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TBE_FolderTree');
+               $foldertree = GeneralUtility::makeInstance('TBE_FolderTree');
                $foldertree->thisScript = $this->thisScript;
                $foldertree->ext_noTempRecyclerDirs = $this->mode == 'filedrag';
                $tree = $foldertree->getBrowsableTree(FALSE);
@@ -1322,9 +1322,7 @@ class ElementBrowser {
                        </table>
                        ';
                // Adding create folder if applicable:
-               if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
-                       $content .= $createFolder;
-               }
+               $content .= $createFolder;
                // Add some space
                $content .= '<br /><br />';
                // Ending page, returning content:
@@ -1359,25 +1357,25 @@ class ElementBrowser {
                        $out .= $this->barheader($GLOBALS['LANG']->getLL('contentElements') . ':');
                        // Create header for listing, showing the page title/icon:
                        $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
-                       $mainPageRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('pages', $expPageId);
-                       $picon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $mainPageRec);
-                       $picon .= \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle('pages', $mainPageRec, TRUE);
+                       $mainPageRec = BackendUtility::getRecordWSOL('pages', $expPageId);
+                       $picon = IconUtility::getSpriteIconForRecord('pages', $mainPageRec);
+                       $picon .= BackendUtility::getRecordTitle('pages', $mainPageRec, TRUE);
                        $out .= $picon . '<br />';
                        // Look up tt_content elements from the expanded page:
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,header,hidden,starttime,endtime,fe_group,CType,colPos,bodytext', 'tt_content', 'pid=' . intval($expPageId) . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tt_content') . \TYPO3\CMS\Backend\Utility\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;
                        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                                $c++;
-                               $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('tt_content', $row);
+                               $icon = IconUtility::getSpriteIconForRecord('tt_content', $row);
                                if ($this->curUrlInfo['act'] == 'page' && $this->curUrlInfo['cElement'] == $row['uid']) {
-                                       $arrCol = '<img' . \TYPO3\CMS\Backend\Utility\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' . \TYPO3\CMS\Backend\Utility\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 . \TYPO3\CMS\Backend\Utility\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'])) {
                                        $split = preg_split('/(<a[^>]+name=[\'"]?([^"\'>[:space:]]+)[\'"]?[^>]*>)/i', $row['bodytext'], -1, PREG_SPLIT_DELIM_CAPTURE);
@@ -1385,7 +1383,7 @@ class ElementBrowser {
                                                if ($skey % 3 == 2) {
                                                        // Putting list element HTML together:
                                                        $sval = substr($sval, 0, 100);
-                                                       $out .= '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/line.gif', 'width="18" height="16"') . ' alt="" />' . '<img' . \TYPO3\CMS\Backend\Utility\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 />';
                                                }
                                        }
                                }
@@ -1408,42 +1406,42 @@ class ElementBrowser {
                        if (!strcmp(trim($tables), '*')) {
                                $tablesArr = array_keys($GLOBALS['TCA']);
                        } else {
-                               $tablesArr = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $tables, 1);
+                               $tablesArr = GeneralUtility::trimExplode(',', $tables, TRUE);
                        }
                        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.
                        $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
-                       $mainPageRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('pages', $this->expandPage);
+                       $mainPageRec = BackendUtility::getRecordWSOL('pages', $this->expandPage);
                        $ATag = '';
                        $ATag_e = '';
                        $ATag2 = '';
                        $picon = '';
                        if (is_array($mainPageRec)) {
-                               $picon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $mainPageRec);
+                               $picon = IconUtility::getSpriteIconForRecord('pages', $mainPageRec);
                                if (in_array('pages', $tablesArr)) {
-                                       $ATag = '<a href="#" onclick="return insertElement(\'pages\', \'' . $mainPageRec['uid'] . '\', \'db\', ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($mainPageRec['title']) . ', \'\', \'\', \'\',\'\',1);">';
-                                       $ATag2 = '<a href="#" onclick="return insertElement(\'pages\', \'' . $mainPageRec['uid'] . '\', \'db\', ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($mainPageRec['title']) . ', \'\', \'\', \'\',\'\',0);">';
+                                       $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_e = '</a>';
                                }
                        }
-                       $pBicon = $ATag2 ? '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' alt="" />' : '';
+                       $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));
                        $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 = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($id, $perms_clause);
+                       $pageinfo = BackendUtility::readPageAccess($id, $perms_clause);
                        $table = '';
                        // Generate the record list:
                        /** @var $dblist \TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList */
                        if (isset($this->recordList)) {
                                $dblist = $this->recordList;
                        } else {
-                               $dblist = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\RecordList\\ElementBrowserRecordList');
+                               $dblist = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\RecordList\\ElementBrowserRecordList');
                        }
                        $dblist->thisScript = $this->thisScript;
                        $dblist->backPath = $GLOBALS['BACK_PATH'];
@@ -1462,7 +1460,7 @@ class ElementBrowser {
                        if ($relatingTableName && $relatingFieldName) {
                                $dblist->setRelatingTableAndField($relatingTableName, $relatingFieldName);
                        }
-                       $dblist->start($id, \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('table'), $pointer, \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('search_field'), \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('search_levels'), \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('showLimit'));
+                       $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:
@@ -1501,7 +1499,7 @@ class ElementBrowser {
        /**
         * For RTE: This displays all files from folder. No thumbnails shown
         *
-        * @param string $folder The folder path to expand
+        * @param \TYPO3\CMS\Core\Resource\Folder $folder The folder path to expand
         * @param string $extensionList List of fileextensions to show
         * @return string HTML output
         * @todo Define visibility
@@ -1519,22 +1517,18 @@ class ElementBrowser {
                        }
                        // Create header element; The folder from which files are listed.
                        $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
-                       $folderIcon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForFile('folder');
+                       $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>';
                        if ($this->curUrlInfo['act'] == 'folder' && $currentIdentifier == $folder->getCombinedIdentifier()) {
-                               $out .= '<img' . \TYPO3\CMS\Backend\Utility\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:
                        if ($renderFolders) {
                                $items = $folder->getSubfolders();
                        } else {
-                               $filter = new \TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter();
-                               $filter->setAllowedFileExtensions($extensionList);
-                               $folder->getStorage()->setFileAndFolderNameFilters(array(array($filter, 'filterFileList')));
-
-                               $items = $folder->getFiles();
+                               $items = $this->getFilesInFolder($folder, $extensionList);
                        }
                        $c = 0;
                        $totalItems = count($items);
@@ -1542,25 +1536,25 @@ class ElementBrowser {
                                $c++;
                                if ($renderFolders) {
                                        $fileIdentifier = $fileOrFolderObject->getCombinedIdentifier();
-                                       $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForFile('folder');
+                                       $icon = IconUtility::getSpriteIconForFile('folder');
                                        $itemUid = 'file:' . $fileIdentifier;
                                } else {
                                        $fileIdentifier = $fileOrFolderObject->getUid();
                                        // File icon:
                                        $fileExtension = $fileOrFolderObject->getExtension();
                                        // Get size and icon:
-                                       $size = ' (' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($fileOrFolderObject->getSize()) . 'bytes)';
-                                       $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForFile($fileExtension, array('title' => $fileOrFolderObject->getName() . $size));
+                                       $size = ' (' . GeneralUtility::formatSize($fileOrFolderObject->getSize()) . 'bytes)';
+                                       $icon = IconUtility::getSpriteIconForFile($fileExtension, array('title' => $fileOrFolderObject->getName() . $size));
                                        $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' . \TYPO3\CMS\Backend\Utility\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 = '';
                                }
                                // Put it all together for the file element:
-                               $out .= '<img' . \TYPO3\CMS\Backend\Utility\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(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($fileOrFolderObject->getName(), $titleLen)) . '</a><br />';
                        }
                }
                return $out;
@@ -1575,16 +1569,13 @@ class ElementBrowser {
         * @return string HTML output
         * @todo Define visibility
         */
-       public function TBE_expandFolder(\TYPO3\CMS\Core\Resource\Folder $folder, $extensionList = '', $noThumbs = 0) {
-               $extensionList = $extensionList == '*' ? '' : $extensionList;
-               $content = '';
-               if ($folder->checkActionPermission('read')) {
-                       // Listing the files:
-                       $files = $folder->getFiles($extensionList);
-                       $content = $this->fileList($files, $folder, $noThumbs);
+       public function TBE_expandFolder(\TYPO3\CMS\Core\Resource\Folder $folder, $extensionList = '', $noThumbs = FALSE) {
+               if (!$folder->checkActionPermission('read')) {
+                       return '';
                }
-               // Return accumulated content for filelisting:
-               return $content;
+               $extensionList = $extensionList == '*' ? '' : $extensionList;
+               $files = $this->getFilesInFolder($folder, $extensionList);
+               return $this->fileList($files, $folder, $noThumbs);
        }
 
        /**
@@ -1609,7 +1600,7 @@ class ElementBrowser {
                        $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
                        // Create the header of current folder:
                        if ($folder) {
-                               $folderIcon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForFile('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>
                                </tr>';
@@ -1622,7 +1613,7 @@ class ElementBrowser {
                        }
                        // Init graphic object for reading file dimensions:
                        /** @var $imgObj \TYPO3\CMS\Core\Imaging\GraphicalFunctions */
-                       $imgObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Imaging\\GraphicalFunctions');
+                       $imgObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Imaging\\GraphicalFunctions');
                        $imgObj->init();
                        $imgObj->mayScaleUp = 0;
                        $imgObj->tempPath = PATH_site . $imgObj->tempPath;
@@ -1634,14 +1625,14 @@ class ElementBrowser {
                                        $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"';
+                                       $clickIcon = '<img src="' . $imageUrl . '" hspace="5" vspace="5" border="1" />';
                                } else {
                                        $clickIcon = '';
                                        $pDim = '';
                                }
                                // Create file icon:
-                               $size = ' (' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')';
-                               $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForFile($fileExtension, array('title' => $fileObject->getName() . $size));
+                               $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(
@@ -1669,8 +1660,8 @@ class ElementBrowser {
                                        $lines[] = '
                                                <tr class="file_list_normal">
                                                        <td nowrap="nowrap">' . $filenameAndIcon . '&nbsp;</td>
-                                                       <td>' . $ATag . '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList', 1) . '" alt="" />' . $ATag_e . '</td>
-                                                       <td nowrap="nowrap">' . ($ATag2 . '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/zoom2.gif', 'width="12" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('info', 1) . '" alt="" /> ' . $GLOBALS['LANG']->getLL('info', 1) . $ATag2_e) . '</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[] = '
@@ -1681,8 +1672,8 @@ class ElementBrowser {
                                        $lines[] = '
                                                <tr class="file_list_normal">
                                                        <td nowrap="nowrap">' . $filenameAndIcon . '&nbsp;</td>
-                                                       <td>' . $ATag . '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList', 1) . '" alt="" />' . $ATag_e . '</td>
-                                                       <td nowrap="nowrap">' . ($ATag2 . '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/zoom2.gif', 'width="12" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('info', 1) . '" alt="" /> ' . $GLOBALS['LANG']->getLL('info', 1) . $ATag2_e) . '</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>';
                                }
@@ -1729,7 +1720,7 @@ class ElementBrowser {
                        $aTag_e = '</a>';
                        // Add the foder icon
                        $folderIcon = $aTag_alt;
-                       $folderIcon .= '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' 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 />';
@@ -1742,7 +1733,7 @@ class ElementBrowser {
                                foreach ($folders as $folderPath) {
                                        $pathInfo = pathinfo($folderPath);
                                        // Create folder icon:
-                                       $icon = '<img src="clear.gif" width="16" height="16" alt="" /><img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif', 'width="16" height="16"') . ' title="' . htmlspecialchars(($pathInfo['basename'] . $size)) . '" class="absmiddle" alt="" />';
+                                       $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) . '\'));">';
@@ -1770,7 +1761,7 @@ class ElementBrowser {
                                                $lines[] = '
                                                        <tr class="bgColor4">
                                                                <td nowrap="nowrap">' . $foldernameAndIcon . '&nbsp;</td>
-                                                               <td>' . $aTag . '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList', 1) . '" alt="" />' . $aTag_e . ' </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>';
                                        }
@@ -1804,86 +1795,85 @@ class ElementBrowser {
         * @todo Define visibility
         */
        public function TBE_dragNDrop(\TYPO3\CMS\Core\Resource\Folder $folder, $extensionList = '') {
-               $extensionList = $extensionList == '*' ? '' : $extensionList;
+               if (!$folder) {
+                       return '';
+               }
                $out = '';
-               if ($folder) {
-                       if ($folder->getStorage()->isPublic()) {
-                               // Read files from directory:
-                               $files = $folder->getFiles($extensionList);
-                               if (is_array($files)) {
-                                       $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files') . ' (%s):', count($files)));
-                                       $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
-                                       $picon = '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />';
-                                       $picon .= htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(basename($folder->getName()), $titleLen));
-                                       $out .= $picon . '<br />';
-                                       // Init row-array:
-                                       $lines = array();
-                                       // Add "drag-n-drop" message:
+               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">' . $this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')) . '</td>
+                                                       <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>';
-                                       // Traverse files:
-                                       foreach ($files as $fileObject) {
-                                               $fileInfo = $fileObject->getStorage()->getFileInfo($fileObject);
-                                               // URL of image:
-                                               $iUrl = \TYPO3\CMS\Core\Utility\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 = ' (' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')';
-                                                       $filenameAndIcon = \TYPO3\CMS\Backend\Utility\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' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/icon_warning2.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('clickToRedrawFullSize', 1) . '" 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 .= '
-
-
-                       <!--
-                               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');
                        }
+                       // 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');
                }
                return $out;
        }
@@ -1902,7 +1892,7 @@ class ElementBrowser {
         */
        public function isWebFolder($folder) {
                $folder = rtrim($folder, '/') . '/';
-               return \TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($folder, PATH_site) ? TRUE : FALSE;
+               return GeneralUtility::isFirstPartOfStr($folder, PATH_site) ? TRUE : FALSE;
        }
 
        /**
@@ -1917,17 +1907,6 @@ class ElementBrowser {
        }
 
        /**
-        * Checks, if a path is within a read-only mountpoint of the backend user
-        *
-        * @param string $folder Absolute filepath
-        * @return boolean If the input path is found in the backend users filemounts and if the filemount is of type readonly, then return TRUE.
-        * @todo Define visibility
-        */
-       public function isReadOnlyFolder($folder) {
-               return $GLOBALS['FILEMOUNTS'][$this->fileProcessor->checkPathAgainstMounts(rtrim($folder, '/') . '/')]['type'] == 'readonly';
-       }
-
-       /**
         * Prints a 'header' where string is in a tablecell
         *
         * @param string $str The string to print in the header. The value is htmlspecialchars()'ed before output.
@@ -1950,7 +1929,7 @@ class ElementBrowser {
         * @todo Define visibility
         */
        public function getMsgBox($in_msg, $icon = 'icon_note') {
-               $msg = '<img' . \TYPO3\CMS\Backend\Utility\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 = '
 
                        <!--
@@ -1974,7 +1953,7 @@ class ElementBrowser {
         */
        public function printCurrentUrl($str) {
                // Output the folder or file identifier, when working with files
-               if ($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)) {
@@ -1989,7 +1968,7 @@ class ElementBrowser {
                                <!-- Print current URL -->
                                <table border="0" cellpadding="0" cellspacing="0" id="typo3-curUrl">
                                        <tr>
-                                               <td>' . $GLOBALS['LANG']->getLL('currentLink', 1) . ': ' . htmlspecialchars(rawurldecode($str)) . '</td>
+                                               <td>' . $GLOBALS['LANG']->getLL('currentLink', TRUE) . ': ' . htmlspecialchars(rawurldecode($str)) . '</td>
                                        </tr>
                                </table>';
                } else {
@@ -2052,12 +2031,12 @@ class ElementBrowser {
                                        if ($id) {
                                                // Checking if the id-parameter is an alias.
                                                if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) {
-                                                       list($idPartR) = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('pages', 'alias', $id);
+                                                       list($idPartR) = BackendUtility::getRecordsByField('pages', 'alias', $id);
                                                        $id = intval($idPartR['uid']);
                                                }
-                                               $pageRow = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('pages', $id);
+                                               $pageRow = BackendUtility::getRecordWSOL('pages', $id);
                                                $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
-                                               $info['value'] = ((((($GLOBALS['LANG']->getLL('page', 1) . ' \'') . 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(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($pageRow['title'], $titleLen))) . '\' (ID:') . $id) . ($uP['fragment'] ? ', #' . $uP['fragment'] : '')) . ')';
                                                $info['pageid'] = $id;
                                                $info['cElement'] = $uP['fragment'];
                                                $info['act'] = 'page';
@@ -2130,10 +2109,10 @@ class ElementBrowser {
                        <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', 1) . ':')) . '</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', 1) . ':</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">';
@@ -2148,9 +2127,9 @@ class ElementBrowser {
                $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', 1) . '</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', 1) . '" />
+                       <input type="submit" name="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_upload.php.submit', TRUE) . '" />
                ';
                $code .= '</td>
                                        </tr>
@@ -2171,6 +2150,9 @@ class ElementBrowser {
                if (!$folderObject->checkActionPermission('write')) {
                        return '';
                }
+               if (!($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB'))) {
+                       return '';
+               }
                // Don't show Folder-create form if it's denied
                if ($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.hideCreateFolder')) {
                        return '';
@@ -2188,7 +2170,7 @@ class ElementBrowser {
                                                <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', 1) . ':</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">';
@@ -2197,7 +2179,7 @@ class ElementBrowser {
                $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', 1) . '" />';
+               $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>
@@ -2214,19 +2196,19 @@ class ElementBrowser {
         */
        public function getBulkSelector($filesCount) {
                if ($filesCount) {
-                       $labelToggleSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.xlf:toggleSelection', 1);
-                       $labelImportSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.xlf:importSelection', 1);
+                       $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' . \TYPO3\CMS\Backend\Utility\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' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/clip_select.gif', 'width="12" height="12"') . ' title="' . $labelToggleSelection . '" alt="" /> ' . $labelToggleSelection . '</a>' . '</div>';
+                       $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 = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData($_MOD_MENU, \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('SET'), $_MCONF['name']);
+                               $_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 = \TYPO3\CMS\Backend\Utility\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', 1) . '</label>';
+                               $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);
@@ -2258,12 +2240,26 @@ class ElementBrowser {
                                }
                                unset($value);
                        }
-                       $result = $this->P['fieldChangeFuncHash'] === \TYPO3\CMS\Core\Utility\GeneralUtility::hmac(serialize($fieldChangeFunctions));
+                       $result = $this->P['fieldChangeFuncHash'] === GeneralUtility::hmac(serialize($fieldChangeFunctions));
                }
                return $result;
        }
 
-}
-
+       /**
+        * Get a list of Files in a folder filtered by extension
+        *
+        * @param \TYPO3\CMS\Core\Resource\Folder $folder
+        * @param string $extensionList
+        * @return \TYPO3\CMS\Core\Resource\File[]
+        */
+       protected function getFilesInFolder(\TYPO3\CMS\Core\Resource\Folder $folder, $extensionList) {
+               if ($extensionList !== '') {
+                       /** @var \TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter $filter */
+                       $filter = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Filter\\FileExtensionFilter');
+                       $filter->setAllowedFileExtensions($extensionList);
+                       $folder->setFileAndFolderNameFilters(array(array($filter, 'filterFileList')));
+               }
+               return $folder->getFiles();
+       }
 
-?>
+}