[TASK] Use ModuleTemplate API for File module navigation frame 81/44581/4
authorFrans Saris <franssaris@gmail.com>
Fri, 6 Nov 2015 14:41:19 +0000 (15:41 +0100)
committerMarkus Klein <markus.klein@typo3.org>
Fri, 6 Nov 2015 20:57:58 +0000 (21:57 +0100)
Resolves: #71372
Releases: master
Change-Id: I6ebeef3f76623adb4d4936dc874826f335f959d5
Reviewed-on: https://review.typo3.org/44581
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Build/Resources/Public/Less/TYPO3/_element_tree.less
typo3/sysext/backend/Classes/Controller/FileSystemNavigationFrameController.php
typo3/sysext/backend/Resources/Private/Templates/alt_file_navframe.html [deleted file]
typo3/sysext/t3skin/Resources/Public/Css/backend.css

index 7a89614..03db1cd 100644 (file)
        .list-tree-control > .fa:before {
                background-color: #f5f5f5;
        }
-       [id=typo3-inner-docbody] {
+       .module-body {
                padding-left: 10px;
                padding-right: 10px;
        }
        }
 }
 
-#typo3-pagetree #typo3-docheader div.buttonsright,
-#ext-backend-Modules-FileSystemNavigationFrame-index-php #typo3-docheader div.buttonsright {
+#typo3-pagetree #typo3-docheader div.buttonsright {
        margin-right: 3px;
 }
 
@@ -283,8 +282,7 @@ body#typo3-alt-db-navframe-php div.c-notice {
 // AJAX Page Tree
 //
 
-body#typo3-pagetree,
-body#ext-backend-Modules-FileSystemNavigationFrame-index-php {
+body#typo3-pagetree {
        margin: 0;
        padding: 0;
 }
@@ -414,12 +412,9 @@ ul.tree div.treeLinkItem span.dragIcon {
 
 body#typo3-pagetree,
 body#ext-backend-Modules-FileSystemNavigationFrame-index-php {
-       background: #ebebeb;
+       background: @navigation-bg;
 }
 
-#ext-backend-Modules-FileSystemNavigationFrame-index-php #typo3-docbody,
-#ext-backend-Modules-FileSystemNavigationFrame-index-php #typo3-docheader-row1,
-#ext-backend-Modules-FileSystemNavigationFrame-index-php #typo3-docheader-row2,
 .typo3-pagetree-indicatorBar-item,
 #typo3-pagetree-topPanelItems,
 #typo3-pagetree-topPanel .typo3-pagetree-topPanel-item,
@@ -430,7 +425,7 @@ body#ext-backend-Modules-FileSystemNavigationFrame-index-php {
        background-repeat: repeat-y;
 }
 
-#ext-backend-Modules-FileSystemNavigationFrame-index-php #typo3-docbody,
+#ext-backend-Modules-FileSystemNavigationFrame-index-php .module-body,
 #typo3-pagetree-treeContainer {
        background-color: @navigation-bg;
 }
index 2ac7cf1..fcee072 100644 (file)
@@ -16,12 +16,13 @@ namespace TYPO3\CMS\Backend\Controller;
 
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
+use TYPO3\CMS\Backend\Template\Components\ButtonBar;
+use TYPO3\CMS\Backend\Template\ModuleTemplate;
 use TYPO3\CMS\Backend\Tree\View\ElementBrowserFolderTreeView;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Filelist\FileListFolderTree;
-use TYPO3\CMS\Backend\Template\DocumentTemplate;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Recordlist\Tree\View\DummyLinkParameterProvider;
 
@@ -30,6 +31,7 @@ use TYPO3\CMS\Recordlist\Tree\View\DummyLinkParameterProvider;
  */
 class FileSystemNavigationFrameController
 {
+
     /**
      * Content accumulates in this variable.
      *
@@ -43,13 +45,6 @@ class FileSystemNavigationFrameController
     public $foldertree;
 
     /**
-     * document template object
-     *
-     * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
-     */
-    public $doc;
-
-    /**
      * @var string
      */
     public $currentSubScript;
@@ -70,6 +65,13 @@ class FileSystemNavigationFrameController
     public $doHighlight;
 
     /**
+     * ModuleTemplate Container
+     *
+     * @var ModuleTemplate
+     */
+    protected $moduleTemplate;
+
+    /**
      * Constructor
      */
     public function __construct()
@@ -99,6 +101,8 @@ class FileSystemNavigationFrameController
      */
     protected function init()
     {
+        $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
+
         // Setting GPvars:
         $this->currentSubScript = GeneralUtility::_GP('currentSubScript');
         $this->cMR = GeneralUtility::_GP('cMR');
@@ -117,7 +121,8 @@ class FileSystemNavigationFrameController
             $this->foldertree->ext_noTempRecyclerDirs = $this->scopeData['ext_noTempRecyclerDirs'];
             if ($this->foldertree instanceof ElementBrowserFolderTreeView) {
                 // create a fake provider to pass link data along properly
-                $linkParamProvider = GeneralUtility::makeInstance(DummyLinkParameterProvider::class,
+                $linkParamProvider = GeneralUtility::makeInstance(
+                    DummyLinkParameterProvider::class,
                     $this->scopeData['browser'],
                     $this->scopeData['script']
                 );
@@ -144,11 +149,9 @@ class FileSystemNavigationFrameController
     {
         // Setting highlight mode:
         $this->doHighlight = !$this->getBackendUser()->getTSConfigVal('options.pageTree.disableTitleHighlight');
-        // Create template object:
-        $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
-        $this->doc->bodyTagId = 'ext-backend-Modules-FileSystemNavigationFrame-index-php';
-        $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/alt_file_navframe.html');
-        $this->doc->showFlashMessages = false;
+
+        $this->moduleTemplate->setBodyTag('<body id="ext-backend-Modules-FileSystemNavigationFrame-index-php">');
+
         // Adding javascript code for drag&drop and the filetree as well as the click menu code
         $dragDropCode = '
                        Tree.ajaxID = "sc_alt_file_navframe_expandtoggle";
@@ -160,12 +163,17 @@ class FileSystemNavigationFrameController
                        Tree.highlightActiveItem("", top.fsMod.navFrameHighlightedID["file"]);
                        ';
         }
+
         // Adding javascript for drag & drop activation and highlighting
-        $this->doc->getDragDropCode('folders', $dragDropCode);
-        $this->doc->getContextMenuCode();
+        $pageRenderer = $this->moduleTemplate->getPageRenderer();
+        $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu');
+        $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LegacyTree', 'function() {
+            DragDrop.table = "folders";
+            ' . $dragDropCode . '
+        }');
 
         // Setting JavaScript for menu.
-        $this->doc->JScode .= $this->doc->wrapScriptTags(($this->currentSubScript ? 'top.currentSubScript=unescape("' . rawurlencode($this->currentSubScript) . '");' : '') . '
+        $inlineJs = ($this->currentSubScript ? 'top.currentSubScript=unescape("' . rawurlencode($this->currentSubScript) . '");' : '') . '
                // Function, loading the list frame from navigation tree:
                function jumpTo(id, linkObj, highlightID, bank) {
                        var theUrl = top.currentSubScript;
@@ -181,7 +189,12 @@ class FileSystemNavigationFrameController
                        if (linkObj) { linkObj.blur(); }
                        return false;
                }
-               ' . ($this->cMR ? ' jumpTo(top.fsMod.recentIds[\'file\'],\'\');' : ''));
+               ' . ($this->cMR ? ' jumpTo(top.fsMod.recentIds[\'file\'],\'\');' : '');
+
+        $this->moduleTemplate->getPageRenderer()->addJsInlineCode(
+            'FileSystemNavigationFrame',
+            $inlineJs
+        );
     }
 
     /**
@@ -194,18 +207,12 @@ class FileSystemNavigationFrameController
         // Produce browse-tree:
         $tree = $this->foldertree->getBrowsableTree();
         // Outputting page tree:
-        $this->content .= $tree;
-        // Setting up the buttons and markers for docheader
-        $docHeaderButtons = $this->getButtons();
-        $markers = array(
-            'CONTENT' => $this->content
-        );
-        $subparts = array();
+        $this->moduleTemplate->setContent($tree);
+        // Setting up the buttons
+        $this->getButtons();
         // Build the <body> for the module
-        $this->content = $this->doc->startPage('TYPO3 Folder Tree');
-        $this->content .= $this->doc->moduleBody(array(), $docHeaderButtons, $markers, $subparts);
-        $this->content .= $this->doc->endPage();
-        $this->content = $this->doc->insertStylesAndJS($this->content);
+        $this->moduleTemplate->setTitle('TYPO3 Folder Tree');
+        $this->content = $this->moduleTemplate->renderContent();
     }
 
     /**
@@ -221,28 +228,33 @@ class FileSystemNavigationFrameController
     }
 
     /**
-     * Create the panel of buttons for submitting the form or otherwise perform operations.
-     *
-     * @return array All available buttons as an assoc. array
+     * Register docHeader buttons
      */
     protected function getButtons()
     {
-        $buttons = array(
-            'csh' => '',
-            'refresh' => ''
-        );
-        $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
+        /** @var ButtonBar $buttonBar */
+        $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
+
+        /** @var IconFactory $iconFactory */
+        $iconFactory = $this->moduleTemplate->getIconFactory();
+
         // Refresh
-        $buttons['refresh'] = '<a href="' . htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI')) . '">' . $iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)->render() . '</a>';
+        $refreshButton = $buttonBar->makeLinkButton()
+            ->setHref(GeneralUtility::getIndpEnv('REQUEST_URI'))
+            ->setTitle($this->getLanguageService()->makeEntities(
+                $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.reload', true)
+            ))->setIcon($iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL));
+        $buttonBar->addButton($refreshButton, ButtonBar::BUTTON_POSITION_RIGHT);
+
         // CSH
-        $buttons['csh'] = str_replace('typo3-csh-inline', 'typo3-csh-inline show-right', BackendUtility::cshItem('xMOD_csh_corebe', 'filetree'));
-        return $buttons;
+        $cshButton = $buttonBar->makeHelpButton()
+            ->setModuleName('xMOD_csh_corebe')
+            ->setFieldName('filetree');
+        $buttonBar->addButton($cshButton);
     }
 
     /**********************************
-     *
      * AJAX Calls
-     *
      **********************************/
     /**
      * Makes the AJAX call to expand or collapse the foldertree.
@@ -272,4 +284,14 @@ class FileSystemNavigationFrameController
     {
         return $GLOBALS['BE_USER'];
     }
+
+    /**
+     * Returns an instance of LanguageService
+     *
+     * @return \TYPO3\CMS\Lang\LanguageService
+     */
+    protected function getLanguageService()
+    {
+        return $GLOBALS['LANG'];
+    }
 }
diff --git a/typo3/sysext/backend/Resources/Private/Templates/alt_file_navframe.html b/typo3/sysext/backend/Resources/Private/Templates/alt_file_navframe.html
deleted file mode 100644 (file)
index a2bc3b6..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<!-- ###FULLDOC### begin -->
-<div class="typo3-fullDoc">
-       <div id="typo3-docheader">
-               <div class="typo3-docheader-functions">
-               </div>
-               <div class="typo3-docheader-buttons">
-                       <div class="left">###BUTTONLIST_LEFT###</div>
-                       <div class="right">###BUTTONLIST_RIGHT###</div>
-               </div>
-       </div>
-
-       <div id="typo3-docbody">
-               <div id="typo3-inner-docbody">
-                       ###CONTENT###
-               </div>
-       </div>
-</div>
-<!-- ###FULLDOC### end -->
-
-<!-- Grouping the icons on top -->
-
-<!-- ###BUTTON_GROUP_WRAP### -->
-       <div class="buttongroup">###BUTTONS###</div>
-<!-- ###BUTTON_GROUP_WRAP### -->
-
-<!-- ###BUTTON_GROUPS_LEFT### -->
-<!-- ###BUTTON_GROUP4### --> <!-- ###BUTTON_GROUP4### -->
-<!-- ###BUTTON_GROUPS_LEFT### -->
-
-<!-- ###BUTTON_GROUPS_RIGHT### -->
-<!-- ###BUTTON_GROUP1### -->###REFRESH######CSH###<!-- ###BUTTON_GROUP1### -->
-<!-- ###BUTTON_GROUPS_RIGHT### -->
index 678fb0d..99509d0 100644 (file)
@@ -11313,7 +11313,7 @@ div.t3-form-field-container:first-child .t3-form-field-label-flex {
 [id=ext-backend-Modules-FileSystemNavigationFrame-index-php] .list-tree-control > .fa:before {
   background-color: #f5f5f5;
 }
-[id=ext-backend-Modules-FileSystemNavigationFrame-index-php] [id=typo3-inner-docbody] {
+[id=ext-backend-Modules-FileSystemNavigationFrame-index-php] .module-body {
   padding-left: 10px;
   padding-right: 10px;
 }
@@ -11370,8 +11370,7 @@ div.t3-form-field-container:first-child .t3-form-field-label-flex {
 .treeline-icon-clear:after {
   display: none;
 }
-#typo3-pagetree #typo3-docheader div.buttonsright,
-#ext-backend-Modules-FileSystemNavigationFrame-index-php #typo3-docheader div.buttonsright {
+#typo3-pagetree #typo3-docheader div.buttonsright {
   margin-right: 3px;
 }
 body#typo3-alt-db-navframe-php div.c-notice {
@@ -11381,8 +11380,7 @@ body#typo3-alt-db-navframe-php div.c-notice {
   padding: 5px 5px 5px 5px;
   width: 95%;
 }
-body#typo3-pagetree,
-body#ext-backend-Modules-FileSystemNavigationFrame-index-php {
+body#typo3-pagetree {
   margin: 0;
   padding: 0;
 }
@@ -11473,11 +11471,8 @@ ul.tree div.treeLinkItem span.dragIcon {
 }
 body#typo3-pagetree,
 body#ext-backend-Modules-FileSystemNavigationFrame-index-php {
-  background: #ebebeb;
+  background: #f5f5f5;
 }
-#ext-backend-Modules-FileSystemNavigationFrame-index-php #typo3-docbody,
-#ext-backend-Modules-FileSystemNavigationFrame-index-php #typo3-docheader-row1,
-#ext-backend-Modules-FileSystemNavigationFrame-index-php #typo3-docheader-row2,
 .typo3-pagetree-indicatorBar-item,
 #typo3-pagetree-topPanelItems,
 #typo3-pagetree-topPanel .typo3-pagetree-topPanel-item,
@@ -11487,7 +11482,7 @@ body#ext-backend-Modules-FileSystemNavigationFrame-index-php {
   background-position: right;
   background-repeat: repeat-y;
 }
-#ext-backend-Modules-FileSystemNavigationFrame-index-php #typo3-docbody,
+#ext-backend-Modules-FileSystemNavigationFrame-index-php .module-body,
 #typo3-pagetree-treeContainer {
   background-color: #f5f5f5;
 }