[TASK] Use ModuleTemplate API for ext:lowlevel 50/43950/5
authorMichael Oehlhof <typo3@oehlhof.de>
Fri, 9 Oct 2015 19:50:14 +0000 (21:50 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Sun, 11 Oct 2015 21:15:54 +0000 (23:15 +0200)
Resolves: #69883
Releases: master
Change-Id: Ie8f65caab8961dd462b874c6c7445703aa32da08
Reviewed-on: http://review.typo3.org/43950
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Tested-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/lowlevel/Classes/View/ConfigurationView.php
typo3/sysext/lowlevel/Classes/View/DatabaseIntegrityView.php
typo3/sysext/lowlevel/Resources/Private/Templates/config.html [deleted file]
typo3/sysext/lowlevel/Resources/Private/Templates/dbint.html [deleted file]
typo3/sysext/lowlevel/Resources/Public/Css/styles.css [deleted file]

index 1f53d90..ce43ad8 100644 (file)
@@ -17,7 +17,8 @@ namespace TYPO3\CMS\Lowlevel\View;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Backend\Module\BaseScriptClass;
-use TYPO3\CMS\Backend\Template\DocumentTemplate;
+use TYPO3\CMS\Backend\Template\Components\ButtonBar;
+use TYPO3\CMS\Backend\Template\ModuleTemplate;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -43,6 +44,13 @@ class ConfigurationView extends BaseScriptClass
     protected $moduleName = 'system_config';
 
     /**
+     * ModuleTemplate Container
+     *
+     * @var ModuleTemplate
+     */
+    protected $moduleTemplate;
+
+    /**
      * Constructor
      */
     public function __construct()
@@ -59,11 +67,8 @@ class ConfigurationView extends BaseScriptClass
     public function init()
     {
         $this->menuConfig();
-        $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
-        $this->doc->setModuleTemplate('EXT:lowlevel/Resources/Private/Templates/config.html');
-        $this->doc->form = '<form action="" method="post">';
-        $this->doc->addStyleSheet('module', 'sysext/lowlevel/Resources/Public/Css/styles.css');
-        $this->doc->bodyTagId = 'ext-lowlevel-Modules-Configuration-index-php';
+        $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
+        $this->moduleTemplate->setForm('<form action="" method="post">');
     }
 
     /**
@@ -197,17 +202,18 @@ class ConfigurationView extends BaseScriptClass
         $tree = $arrayBrowser->tree($theVar, '', '');
         $this->view->assign('tree', $tree);
 
-        // Setting up the buttons and markers for docheader
-        $docHeaderButtons = $this->getButtons();
-        $markers = array(
-            'CSH' => $docHeaderButtons['csh'],
-            'FUNC_MENU' => $this->getFuncMenu(),
-            'CONTENT' => $this->view->render(),
-        );
-        // Build the <body> for the module
-        $this->content = $this->doc->moduleBody(array(), $docHeaderButtons, $markers);
-        // Renders the module page
-        $this->content = $this->doc->render('Configuration', $this->content);
+        // Setting up the shortcut button for docheader
+        $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
+        // Shortcut
+        if ($this->getBackendUser()->mayMakeShortcut()) {
+            $shortCutButton = $buttonBar->makeFullyRenderedButton()
+                ->setHtmlSource($this->moduleTemplate->makeShortcutIcon('', 'function', $this->moduleName));
+            $buttonBar->addButton($shortCutButton, ButtonBar::BUTTON_POSITION_RIGHT, 2);
+        }
+
+        $this->getModuleMenu();
+
+        $this->content = $this->view->render();
     }
 
 
@@ -225,7 +231,8 @@ class ConfigurationView extends BaseScriptClass
         $this->init();
         $this->main();
 
-        $response->getBody()->write($this->content);
+        $this->moduleTemplate->setContent($this->content);
+        $response->getBody()->write($this->moduleTemplate->renderContent());
         return $response;
     }
 
@@ -242,31 +249,33 @@ class ConfigurationView extends BaseScriptClass
     }
 
     /**
-     * Create the panel of buttons for submitting the form or otherwise perform operations.
-     *
-     * @return array All available buttons as an assoc. array
+     * Generates the action menu
      */
-    protected function getButtons()
+    protected function getModuleMenu()
     {
-        $buttons = array(
-            'csh' => '',
-            'shortcut' => ''
-        );
-        // Shortcut
-        if ($this->getBackendUser()->mayMakeShortcut()) {
-            $buttons['shortcut'] = $this->doc->makeShortcutIcon('', 'function', $this->moduleName);
-        }
-        return $buttons;
-    }
+        $menu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
+        $menu->setIdentifier('ConfigurationJumpMenu');
 
-    /**
-     * Create the function menu
-     *
-     * @return string HTML of the function menu
-     */
-    protected function getFuncMenu()
-    {
-        $funcMenu = BackendUtility::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
-        return $funcMenu;
+        foreach ($this->MOD_MENU['function'] as $controller => $title) {
+            $item = $menu
+                ->makeMenuItem()
+                ->setHref(
+                    BackendUtility::getModuleUrl(
+                        $this->moduleName,
+                        [
+                            'id' => $this->id,
+                            'SET' => [
+                                'function' => $controller
+                            ]
+                        ]
+                    )
+                )
+                ->setTitle($title);
+            if ($controller === (int)$this->MOD_SETTINGS['function']) {
+                $item->setActive(true);
+            }
+            $menu->addMenuItem($item);
+        }
+        $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
     }
 }
index b4f3a70..68c2a23 100644 (file)
@@ -17,7 +17,8 @@ namespace TYPO3\CMS\Lowlevel\View;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Backend\Module\BaseScriptClass;
-use TYPO3\CMS\Backend\Template\DocumentTemplate;
+use TYPO3\CMS\Backend\Template\Components\ButtonBar;
+use TYPO3\CMS\Backend\Template\ModuleTemplate;
 use TYPO3\CMS\Core\Database\QueryView;
 use TYPO3\CMS\Core\Database\ReferenceIndex;
 use TYPO3\CMS\Core\Imaging\Icon;
@@ -60,6 +61,13 @@ class DatabaseIntegrityView extends BaseScriptClass
     protected $iconFactory;
 
     /**
+     * ModuleTemplate Container
+     *
+     * @var ModuleTemplate
+     */
+    protected $moduleTemplate;
+
+    /**
      * Constructor
      */
     public function __construct()
@@ -77,11 +85,10 @@ class DatabaseIntegrityView extends BaseScriptClass
      */
     public function init()
     {
-        $this->MCONF['name'] = 'system_dbint';
+        $this->MCONF['name'] = $this->moduleName;
         $this->menuConfig();
-        $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
-        $this->doc->setModuleTemplate('EXT:lowlevel/Resources/Private/Templates/dbint.html');
-        $this->doc->form = '<form action="" method="post" name="' . $this->formName . '">';
+        $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
+        $this->moduleTemplate->setForm('<form action="" method="post" name="' . $this->formName . '">');
     }
 
     /**
@@ -205,17 +212,15 @@ class DatabaseIntegrityView extends BaseScriptClass
         $this->view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($this->templatePath . $templateFilename));
         $this->content = $this->view->render();
 
-        // Setting up the buttons and markers for docheader
-        $docHeaderButtons = $this->getButtons();
-        $markers = array(
-            'CSH' => $docHeaderButtons['csh'],
-            'FUNC_MENU' => $this->getFuncMenu(),
-            'CONTENT' => $this->content
-        );
-        // Build the <body> for the module
-        $this->content = $this->doc->moduleBody(array(), $docHeaderButtons, $markers);
-        // Renders the module page
-        $this->content = $this->doc->render($this->getLanguageService()->getLL('title'), $this->content);
+        // Setting up the shortcut button for docheader
+        $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
+        // Shortcut
+        $shortCutButton = $buttonBar->makeShortcutButton()
+            ->setModuleName($this->moduleName)
+            ->setGetVariables(['function','search','search_query_makeQuery']);
+        $buttonBar->addButton($shortCutButton, ButtonBar::BUTTON_POSITION_RIGHT, 2);
+
+        $this->getModuleMenu();
     }
 
     /**
@@ -244,36 +249,40 @@ class DatabaseIntegrityView extends BaseScriptClass
         $this->init();
         $this->main();
 
-        $response->getBody()->write($this->content);
+        $this->moduleTemplate->setContent($this->content);
+        $response->getBody()->write($this->moduleTemplate->renderContent());
         return $response;
     }
 
     /**
-     * Create the panel of buttons for submitting the form or otherwise perform operations.
-     *
-     * @return array All available buttons as an assoc. array
+     * Generates the action menu
      */
-    protected function getButtons()
+    protected function getModuleMenu()
     {
-        $buttons = array(
-            'csh' => '',
-            'shortcut' => ''
-        );
-        // Shortcut
-        if ($this->getBackendUser()->mayMakeShortcut()) {
-            $buttons['shortcut'] = $this->doc->makeShortcutIcon('', 'function,search,search_query_makeQuery', $this->moduleName);
-        }
-        return $buttons;
-    }
+        $menu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
+        $menu->setIdentifier('DatabaseJumpMenu');
 
-    /**
-     * Create the function menu
-     *
-     * @return string HTML of the function menu
-     */
-    protected function getFuncMenu()
-    {
-        return BackendUtility::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
+        foreach ($this->MOD_MENU['function'] as $controller => $title) {
+            $item = $menu
+                ->makeMenuItem()
+                ->setHref(
+                    BackendUtility::getModuleUrl(
+                        $this->moduleName,
+                        [
+                            'id' => $this->id,
+                            'SET' => [
+                                'function' => $controller
+                            ]
+                        ]
+                    )
+                )
+                ->setTitle($title);
+            if ($controller === (int)$this->MOD_SETTINGS['function']) {
+                $item->setActive(true);
+            }
+            $menu->addMenuItem($item);
+        }
+        $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
     }
 
     /**
diff --git a/typo3/sysext/lowlevel/Resources/Private/Templates/config.html b/typo3/sysext/lowlevel/Resources/Private/Templates/config.html
deleted file mode 100644 (file)
index 84aaed7..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<!-- ###FULLDOC### begin -->
-<div class="typo3-fullDoc">
-       <div id="typo3-docheader">
-               <div class="typo3-docheader-functions">
-                       <div class="left">###FUNC_MENU###</div>
-                       <div class="right"></div>
-               </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_GROUP1### --><!-- ###BUTTON_GROUP1### -->
-<!-- ###BUTTON_GROUPS_LEFT### -->
-
-<!-- ###BUTTON_GROUPS_RIGHT### -->
-<!-- ###BUTTON_GROUP1### -->###SHORTCUT###<!-- ###BUTTON_GROUP1### -->
-<!-- ###BUTTON_GROUPS_RIGHT### -->
diff --git a/typo3/sysext/lowlevel/Resources/Private/Templates/dbint.html b/typo3/sysext/lowlevel/Resources/Private/Templates/dbint.html
deleted file mode 100644 (file)
index 84aaed7..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<!-- ###FULLDOC### begin -->
-<div class="typo3-fullDoc">
-       <div id="typo3-docheader">
-               <div class="typo3-docheader-functions">
-                       <div class="left">###FUNC_MENU###</div>
-                       <div class="right"></div>
-               </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_GROUP1### --><!-- ###BUTTON_GROUP1### -->
-<!-- ###BUTTON_GROUPS_LEFT### -->
-
-<!-- ###BUTTON_GROUPS_RIGHT### -->
-<!-- ###BUTTON_GROUP1### -->###SHORTCUT###<!-- ###BUTTON_GROUP1### -->
-<!-- ###BUTTON_GROUPS_RIGHT### -->
diff --git a/typo3/sysext/lowlevel/Resources/Public/Css/styles.css b/typo3/sysext/lowlevel/Resources/Public/Css/styles.css
deleted file mode 100644 (file)
index 18d65c2..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#lowlevel-config {
-       margin-bottom: 20px;
-}
-.record {
-       font-weight: bold;
-       white-space: nowrap;
-}
-
-.record img {
-       border: none;
-       padding: 0 3px;
-       vertical-align: top;
-}
-
-.record-noicon {
-       padding-left: 16px;
-       color: grey;
-       white-space: nowrap;
-}