[TASK] Use ModuleTemplate API for ext:recycler 03/43803/8
authorMichael Oehlhof <typo3@oehlhof.de>
Sun, 4 Oct 2015 22:04:46 +0000 (00:04 +0200)
committerBenjamin Kott <info@bk2k.info>
Mon, 5 Oct 2015 21:21:20 +0000 (23:21 +0200)
Resolves: #70367
Releases: master
Change-Id: I5861cd2de035e2b730aca2f40adf74ff913a7d95
Reviewed-on: http://review.typo3.org/43803
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Benjamin Kott <info@bk2k.info>
Tested-by: Benjamin Kott <info@bk2k.info>
Build/Resources/Public/Less/Component/module.less
typo3/sysext/backend/Classes/Template/ModuleTemplate.php
typo3/sysext/recycler/Classes/Controller/RecyclerModuleController.php
typo3/sysext/recycler/Resources/Private/Layouts/Default.html
typo3/sysext/recycler/Resources/Private/Templates/RecyclerModule/Index.html
typo3/sysext/recycler/Resources/Public/JavaScript/Recycler.js
typo3/sysext/t3skin/Resources/Public/Css/backend.css

index dd59ac1..01e9b51 100644 (file)
@@ -35,9 +35,6 @@
        height: 100%;
        width: 100%;
        background-color: @module-bg;
-       form {
-               margin: 0;
-       }
 }
 
 
index ca8d251..3356875 100644 (file)
@@ -250,8 +250,10 @@ class ModuleTemplate {
         */
        protected function setupPage() {
                // Yes, hardcoded on purpose
+               $this->pageRenderer->setXmlPrologAndDocType('<!DOCTYPE html>');
                $this->pageRenderer->setCharSet('utf-8');
                $this->pageRenderer->setLanguage('default');
+               $this->pageRenderer->addMetaTag('<meta name="viewport" content="width=device-width, initial-scale=1">');
        }
 
        /**
index 0dd6abb..770c1a4 100644 (file)
@@ -14,13 +14,18 @@ namespace TYPO3\CMS\Recycler\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Template\Components\ButtonBar;
+use TYPO3\CMS\Backend\View\BackendTemplateView;
+use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
+use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
 
 /**
  * Module 'Recycler' for the 'recycler' extension.
  */
-class RecyclerModuleController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
+class RecyclerModuleController extends ActionController {
 
        /**
         * @var string
@@ -58,6 +63,18 @@ class RecyclerModuleController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionC
        protected $id;
 
        /**
+        * @var BackendTemplateView
+        */
+       protected $view;
+
+       /**
+        * BackendTemplateView Container
+        *
+        * @var BackendTemplateView
+        */
+       protected $defaultViewObjectName = BackendTemplateView::class;
+
+       /**
         * Initializes the Module
         *
         * @return void
@@ -88,6 +105,18 @@ class RecyclerModuleController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionC
        }
 
        /**
+        * Initialize the view
+        *
+        * @param ViewInterface $view The view
+        * @return void
+        */
+       public function initializeView(ViewInterface $view) {
+               /** @var BackendTemplateView $view */
+               parent::initializeView($view);
+               $this->registerDocheaderButtons();
+       }
+
+       /**
         * Renders the content of the module.
         *
         * @return void
@@ -95,14 +124,49 @@ class RecyclerModuleController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionC
        public function indexAction() {
                // Integrate dynamic JavaScript such as configuration or lables:
                $jsConfiguration = $this->getJavaScriptConfiguration();
-               $this->getPageRenderer()->addInlineSettingArray('Recycler', $jsConfiguration);
-               $this->getPageRenderer()->addInlineLanguageLabelFile('EXT:recycler/Resources/Private/Language/locallang.xlf');
+               $this->view->getModuleTemplate()->getPageRenderer()->addInlineSettingArray('Recycler', $jsConfiguration);
+               $this->view->getModuleTemplate()->getPageRenderer()->addInlineLanguageLabelFile('EXT:recycler/Resources/Private/Language/locallang.xlf');
+               $this->view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation($this->pageRecord);
 
                $this->view->assign('title', $this->getLanguageService()->getLL('title'));
                $this->view->assign('allowDelete', $this->allowDelete);
        }
 
        /**
+        * Registers the Icons into the docheader
+        *
+        * @return void
+        * @throws \InvalidArgumentException
+        */
+       protected function registerDocheaderButtons() {
+               /** @var ButtonBar $buttonBar */
+               $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
+               $currentRequest = $this->request;
+               $moduleName = $currentRequest->getPluginName();
+               $getVars = $this->request->getArguments();
+
+               $mayMakeShortcut = $this->getBackendUser()->mayMakeShortcut();
+
+               if ($mayMakeShortcut) {
+                       $extensionName = $currentRequest->getControllerExtensionName();
+                       if (count($getVars) === 0) {
+                               $modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName);
+                               $getVars = array('id', 'M', $modulePrefix);
+                       }
+                       $getList = implode(',', $getVars);
+                       $shortcutButton = $buttonBar->makeFullyRenderedButton()
+                               ->setHtmlSource($this->view->getModuleTemplate()->makeShortcutIcon($getList, '', $moduleName));
+                       $buttonBar->addButton($shortcutButton, ButtonBar::BUTTON_POSITION_RIGHT);
+               }
+               $reloadButton = $buttonBar->makeLinkButton()
+                       ->setHref('#')
+                       ->setDataAttributes(['action' => 'reload'])
+                       ->setTitle($this->getLanguageService()->sL('LLL:EXT:recycler/Resources/Private/Language/locallang.xlf:button.reload', TRUE))
+                       ->setIcon($this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-refresh', Icon::SIZE_SMALL));
+               $buttonBar->addButton($reloadButton, ButtonBar::BUTTON_POSITION_LEFT);
+       }
+
+       /**
         * Determines whether the current user is admin.
         *
         * @return bool Whether the current user is admin
@@ -173,13 +237,4 @@ class RecyclerModuleController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionC
        protected function getLanguageService() {
                return $GLOBALS['LANG'];
        }
-
-       /**
-        * Returns current PageRenderer
-        *
-        * @return PageRenderer
-        */
-       protected function getPageRenderer() {
-               return GeneralUtility::makeInstance(PageRenderer::class);
-       }
 }
index f50c287..cb36197 100644 (file)
@@ -1,36 +1,4 @@
-<f:be.container
-       includeRequireJsModules="{
-               0:'TYPO3/CMS/Recycler/Recycler'
-       }"
->
-       <div class="typo3-fullDoc">
-               <div id="typo3-docheader">
-                       <div class="typo3-docheader-functions">
-                               <div class="left">
-                                       <f:be.buttons.csh />
-                               </div>
-                               <div class="right">
-                               </div>
-                       </div>
-
-                       <div class="typo3-docheader-buttons">
-                               <div class="left">
-                                       <f:render section="iconButtons" />
-                               </div>
-                               <div class="right">
-                                       <f:be.buttons.shortcut />
-                               </div>
-                       </div>
-               </div>
-
-               <div id="typo3-docbody">
-                       <div id="typo3-inner-docbody">
-                               <h1><f:translate key="title" /></h1>
-
-                               <f:flashMessages />
-
-                               <f:render section="content" />
-                       </div>
-               </div>
-       </div>
-</f:be.container>
\ No newline at end of file
+<f:be.pageRenderer includeRequireJsModules="{0:'TYPO3/CMS/Recycler/Recycler'}" />
+<h1><f:translate key="title" /></h1>
+<f:flashMessages />
+<f:render section="content" />
index d665711..3875552 100644 (file)
@@ -1,28 +1,30 @@
 {namespace core=TYPO3\CMS\Core\ViewHelpers}
 <f:layout name="Default" />
 
-<f:section name="iconButtons">
-       <a data-action="reload" title="{f:translate(key:'button.reload')}"><core:icon identifier="actions-refresh" /></a>
-</f:section>
-
 <f:section name="content">
        <div id="recycler-index" class="tx_recycler_recycler">
-               <form id="recycler-form" class="form-inline">
-                       <div class="input-group">
-                               <input type="text" name="search-text" class="form-control">
-                               <span class="input-group-btn">
-                                       <button type="submit" class="btn btn-default disabled"><core:icon identifier="actions-search" /></button>
-                               </span>
+               <form id="recycler-form" class="form-inline form-inline-spaced">
+                       <div class="form-group">
+                               <div class="input-group">
+                                       <input type="text" name="search-text" class="form-control">
+                                       <span class="input-group-btn">
+                                               <button type="submit" class="btn btn-default disabled"><core:icon identifier="actions-search" /></button>
+                                       </span>
+                               </div>
+                       </div>
+                       <div class="form-group">
+                               <select name="depth" class="form-control">
+                                       <option value="0"><f:translate key="LLL:EXT:lang/locallang_core.xlf:labels.depth_0" /></option>
+                                       <option value="1"><f:translate key="LLL:EXT:lang/locallang_core.xlf:labels.depth_1" /></option>
+                                       <option value="2"><f:translate key="LLL:EXT:lang/locallang_core.xlf:labels.depth_2" /></option>
+                                       <option value="3"><f:translate key="LLL:EXT:lang/locallang_core.xlf:labels.depth_3" /></option>
+                                       <option value="4"><f:translate key="LLL:EXT:lang/locallang_core.xlf:labels.depth_4" /></option>
+                                       <option value="999"><f:translate key="LLL:EXT:lang/locallang_core.xlf:labels.depth_infi" /></option>
+                               </select>
+                       </div>
+                       <div class="form-group">
+                               <select name="pages" class="form-control"></select>
                        </div>
-                       <select name="depth" class="form-control">
-                               <option value="0"><f:translate key="LLL:EXT:lang/locallang_core.xlf:labels.depth_0" /></option>
-                               <option value="1"><f:translate key="LLL:EXT:lang/locallang_core.xlf:labels.depth_1" /></option>
-                               <option value="2"><f:translate key="LLL:EXT:lang/locallang_core.xlf:labels.depth_2" /></option>
-                               <option value="3"><f:translate key="LLL:EXT:lang/locallang_core.xlf:labels.depth_3" /></option>
-                               <option value="4"><f:translate key="LLL:EXT:lang/locallang_core.xlf:labels.depth_4" /></option>
-                               <option value="999"><f:translate key="LLL:EXT:lang/locallang_core.xlf:labels.depth_infi" /></option>
-                       </select>
-                       <select name="pages" class="form-control"></select>
                </form>
                <table class="table table-hover" id="itemsInRecycler">
                        <thead>
index 7734edd..6bf9433 100644 (file)
@@ -187,7 +187,7 @@ define(['jquery', 'nprogress', 'TYPO3/CMS/Backend/jquery.clearable'], function($
         * Initialize the recycler module
         */
        Recycler.initialize = function() {
-               NProgress.configure({parent: '#typo3-docheader', showSpinner: false});
+               NProgress.configure({parent: 'body', showSpinner: false});
 
                Recycler.getElements();
                Recycler.registerEvents();
index 8ba8faf..cd3e29f 100644 (file)
@@ -7859,9 +7859,6 @@ button.close {
   width: 100%;
   background-color: #ffffff;
 }
-.module form {
-  margin: 0;
-}
 .module-docheader {
   position: fixed;
   width: 100%;