[TASK] Cleanup CSH calls
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Controller / FileSystemNavigationFrameController.php
index 0687b74..6c0c9dd 100644 (file)
@@ -2,24 +2,37 @@
 namespace TYPO3\CMS\Backend\Controller;
 
 /**
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
  * Main script class for rendering of the folder tree
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage core
  */
 class FileSystemNavigationFrameController {
 
        // Internal, dynamic:
        // Content accumulates in this variable.
        /**
-        * @todo Define visibility
+        * @var string
         */
        public $content;
 
        /**
         * @var \TYPO3\CMS\Filelist\FileListFolderTree $foldertree the folder tree object
-        * @todo Define visibility
         */
        public $foldertree;
 
@@ -27,43 +40,72 @@ class FileSystemNavigationFrameController {
         * document template object
         *
         * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
-        * @todo Define visibility
         */
        public $doc;
 
        /**
-        * @todo Define visibility
+        * @var string
         */
        public $backPath;
 
        // Internal, static: GPvar:
        /**
-        * @todo Define visibility
+        * @var string
         */
        public $currentSubScript;
 
        /**
-        * @todo Define visibility
+        * @var bool
         */
        public $cMR;
 
        /**
+        * @var array
+        */
+       protected $scopeData;
+
+       /**
+        * Constructor
+        */
+       public function __construct() {
+               $GLOBALS['SOBE'] = $this;
+               $GLOBALS['BACK_PATH'] = '';
+               $this->init();
+       }
+
+       /**
         * Initialiation of the script class
         *
-        * @return      void
-        * @todo Define visibility
+        * @return void
         */
-       public function init() {
+       protected function init() {
                // Setting backPath
                $this->backPath = $GLOBALS['BACK_PATH'];
                // Setting GPvars:
-               $this->currentSubScript = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('currentSubScript');
-               $this->cMR = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('cMR');
+               $this->currentSubScript = GeneralUtility::_GP('currentSubScript');
+               $this->cMR = GeneralUtility::_GP('cMR');
+
+               $scopeData = (string)GeneralUtility::_GP('scopeData');
+               $scopeHash = (string)GeneralUtility::_GP('scopeHash');
+
+               if (!empty($scopeData) && GeneralUtility::hmac($scopeData) === $scopeHash) {
+                       $this->scopeData = unserialize($scopeData);
+               }
+
                // Create folder tree object:
-               /** @var $foldertree \TYPO3\CMS\Filelist\FileListFolderTree */
-               $this->foldertree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Filelist\\FileListFolderTree');
+               if (!empty($this->scopeData)) {
+                       $this->foldertree = GeneralUtility::makeInstance($this->scopeData['class']);
+                       $this->foldertree->thisScript = $this->scopeData['script'];
+                       $this->foldertree->ext_noTempRecyclerDirs = $this->scopeData['ext_noTempRecyclerDirs'];
+                       $GLOBALS['SOBE']->browser = new \stdClass();
+                       $GLOBALS['SOBE']->browser->mode = $this->scopeData['browser']['mode'];
+                       $GLOBALS['SOBE']->browser->act = $this->scopeData['browser']['act'];
+               } else {
+                       $this->foldertree = GeneralUtility::makeInstance(\TYPO3\CMS\Filelist\FileListFolderTree::class);
+                       $this->foldertree->thisScript = 'alt_file_navframe.php';
+               }
+
                $this->foldertree->ext_IconMode = $GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.disableIconLinkToContextmenu');
-               $this->foldertree->thisScript = 'alt_file_navframe.php';
        }
 
        /**
@@ -76,9 +118,9 @@ class FileSystemNavigationFrameController {
                // Setting highlight mode:
                $this->doHighlight = !$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableTitleHighlight');
                // Create template object:
-               $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
+               $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
                $this->doc->backPath = $GLOBALS['BACK_PATH'];
-               $this->doc->setModuleTemplate('templates/alt_file_navframe.html');
+               $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/alt_file_navframe.html');
                $this->doc->showFlashMessages = FALSE;
                // Adding javascript code for AJAX (prototype), drag&drop and the filetree as well as the click menu code
                $this->doc->getDragDropCode('folders');
@@ -86,54 +128,6 @@ class FileSystemNavigationFrameController {
                // Setting JavaScript for menu.
                $this->doc->JScode .= $this->doc->wrapScriptTags(($this->currentSubScript ? 'top.currentSubScript=unescape("' . rawurlencode($this->currentSubScript) . '");' : '') . '
 
-               function initFlashUploader(path) {
-                       path = decodeURIComponent(path);
-                       var flashUploadOptions = {
-                               uploadURL: top.TS.PATH_typo3 + "ajax.php",
-                               uploadFileSizeLimit: "' . \TYPO3\CMS\Core\Utility\GeneralUtility::getMaxUploadFileSize() . '",
-                               uploadFileTypes: {
-                                       allow:  "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['allow'] . '",
-                                       deny: "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['deny'] . '"
-                               },
-                               uploadFilePostName: "upload_1",
-                               uploadPostParams: {
-                                       "file[upload][1][target]": path,
-                                       "file[upload][1][data]": 1,
-                                       "file[upload][1][charset]": "utf-8",
-                                       "ajaxID": "TYPO3\\CMS\\Backend\\Controller\\File\\FileController::process"
-                               }
-                       };
-
-                               // get the flashUploaderWindow instance from the parent frame
-                       var flashUploader = top.TYPO3.FileUploadWindow.getInstance(flashUploadOptions);
-                               // add an additional function inside the container to show the checkbox option
-                       var infoComponent = new top.Ext.Panel({
-                               autoEl: { tag: "div" },
-                               height: "auto",
-                               bodyBorder: false,
-                               border: false,
-                               hideBorders: true,
-                               cls: "t3-upload-window-infopanel",
-                               id: "t3-upload-window-infopanel-addition",
-                               html: \'<label for="overrideExistingFilesCheckbox"><input id="overrideExistingFilesCheckbox" type="checkbox" onclick="setFlashPostOptionOverwriteExistingFiles(this);" />\' + top.String.format(top.TYPO3.LLL.fileUpload.infoComponentOverrideFiles) + \'</label>\'
-                       });
-                       flashUploader.add(infoComponent);
-
-                               // do a reload of this frame once all uploads are done
-                       flashUploader.on("totalcomplete", function() {
-                               jumpTo (top.rawurlencode(path), "", "", "");
-                       });
-
-                               // this is the callback function that delivers the additional post parameter to the flash application
-                       top.setFlashPostOptionOverwriteExistingFiles = function(checkbox) {
-                               var uploader = top.TYPO3.getInstance("FileUploadWindow");
-                               if (uploader.isVisible()) {
-                                       uploader.swf.addPostParam("overwriteExistingFiles", (checkbox.checked == true ? 1 : 0));
-                               }
-                       };
-               }
-
-
                // setting prefs for foldertree
                Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
 
@@ -149,7 +143,7 @@ class FileSystemNavigationFrameController {
                        top.TYPO3.Backend.ContentContainer.setUrl(theUrl);
 
                        ' . ($this->doHighlight ? 'Tree.highlightActiveItem("file", highlightID + "_" + bank);' : '') . '
-                       ' . (!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ') . '
+                       if (linkObj) { linkObj.blur(); }
                        return false;
                }
                ' . ($this->cMR ? ' jumpTo(top.fsMod.recentIds[\'file\'],\'\');' : ''));
@@ -159,7 +153,6 @@ class FileSystemNavigationFrameController {
         * Main function, rendering the folder tree
         *
         * @return void
-        * @todo Define visibility
         */
        public function main() {
                // Produce browse-tree:
@@ -169,11 +162,11 @@ class FileSystemNavigationFrameController {
                // Adding javascript for drag & drop activation and highlighting
                $this->content .= $this->doc->wrapScriptTags('
                        ' . ($this->doHighlight ? 'Tree.highlightActiveItem("", top.fsMod.navFrameHighlightedID["file"]);' : '') . '
-                       ' . (!$this->doc->isCMlayers() ? 'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();'));
+                       Tree.registerDragDropHandlers();');
                // Setting up the buttons and markers for docheader
                $docHeaderButtons = $this->getButtons();
                $markers = array(
-                       'IMG_RESET' => '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/close_gray.gif', ' width="16" height="16"') . ' id="treeFilterReset" alt="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter') . '" ' . 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter') . '" />',
+                       'IMG_RESET' => '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/close_gray.gif', ' width="16" height="16"') . ' id="treeFilterReset" alt="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.resetFilter') . '" ' . 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.resetFilter') . '" />',
                        'CONTENT' => $this->content
                );
                $subparts = array();
@@ -190,7 +183,6 @@ class FileSystemNavigationFrameController {
         * Outputting the accumulated content to screen
         *
         * @return void
-        * @todo Define visibility
         */
        public function printContent() {
                echo $this->content;
@@ -207,9 +199,9 @@ class FileSystemNavigationFrameController {
                        'refresh' => ''
                );
                // Refresh
-               $buttons['refresh'] = '<a href="' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-system-refresh') . '</a>';
+               $buttons['refresh'] = '<a href="' . htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI')) . '">' . IconUtility::getSpriteIcon('actions-system-refresh') . '</a>';
                // CSH
-               $buttons['csh'] = str_replace('typo3-csh-inline', 'typo3-csh-inline show-right', \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_csh_corebe', 'filetree', $GLOBALS['BACK_PATH']));
+               $buttons['csh'] = str_replace('typo3-csh-inline', 'typo3-csh-inline show-right', \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_csh_corebe', 'filetree'));
                return $buttons;
        }
 
@@ -223,7 +215,7 @@ class FileSystemNavigationFrameController {
         * Called by typo3/ajax.php
         *
         * @param array $params Additional parameters (not used here)
-        * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj The TYPO3AJAX object of this request
+        * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj The AjaxRequestHandler object of this request
         * @return void
         */
        public function ajaxExpandCollapse($params, $ajaxObj) {
@@ -237,6 +229,3 @@ class FileSystemNavigationFrameController {
        }
 
 }
-
-
-?>
\ No newline at end of file