[TASK] Use ModuleTemplate API for EXT:indexed_search 09/43809/3
authorMathias Schreiber <mathias.schreiber@wmdb.de>
Mon, 5 Oct 2015 09:20:07 +0000 (11:20 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 8 Oct 2015 18:35:41 +0000 (20:35 +0200)
Releases: master
Resolves: #70364
Change-Id: Iffc192e479f9fb8a48bcd42d9e01ccbea2c40af4
Reviewed-on: http://review.typo3.org/43809
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/indexed_search/Classes/Controller/AdministrationController.php
typo3/sysext/indexed_search/Resources/Private/Layouts/Administration.html
typo3/sysext/indexed_search/Resources/Private/Templates/Administration/ExternalDocuments.html
typo3/sysext/indexed_search/Resources/Private/Templates/Administration/Index.html
typo3/sysext/indexed_search/Resources/Private/Templates/Administration/Pages.html
typo3/sysext/indexed_search/Resources/Private/Templates/Administration/Statistic.html
typo3/sysext/indexed_search/Resources/Private/Templates/Administration/StatisticDetails.html
typo3/sysext/indexed_search/Resources/Private/Templates/Administration/WordDetail.html

index e0403a8..017c10f 100644 (file)
@@ -14,10 +14,14 @@ namespace TYPO3\CMS\IndexedSearch\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\View\BackendTemplateView;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
+use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
+use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
 use TYPO3\CMS\Extbase\Mvc\Web\Request as WebRequest;
+use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
 use TYPO3\CMS\IndexedSearch\Domain\Repository\AdministrationRepository;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -62,6 +66,78 @@ class AdministrationController extends ActionController {
        protected $indexer;
 
        /**
+        * Backend Template Container
+        *
+        * @var BackendTemplateView
+        */
+       protected $defaultViewObjectName = BackendTemplateView::class;
+
+       /**
+        * BackendTemplateContainer
+        *
+        * @var BackendTemplateView
+        */
+       protected $view;
+
+       /**
+        * Set up the doc header properly here
+        *
+        * @param ViewInterface $view
+        */
+       protected function initializeView(ViewInterface $view) {
+               /** @var BackendTemplateView $view */
+               parent::initializeView($view);
+               $permissionClause = $this->getBackendUserAuthentication()->getPagePermsClause(1);
+               $pageRecord = BackendUtility::readPageAccess($this->pageUid, $permissionClause);
+               $view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation($pageRecord);
+               $this->generateMenu();
+       }
+
+       /**
+        * Generates the action menu
+        */
+       protected function generateMenu() {
+               $menuItems = [
+                       'index' => [
+                               'controller' => 'Administration',
+                               'action' => 'index',
+                               'label' => $this->getLanguageService()->sL('LLL:EXT:indexed_search/Resources/Private/Language/locallang.xml:administration.menu.general')
+                       ],
+                       'pages' => [
+                               'controller' => 'Administration',
+                               'action' => 'pages',
+                               'label' => $this->getLanguageService()->sL('LLL:EXT:indexed_search/Resources/Private/Language/locallang.xml:administration.menu.pages')
+                       ],
+                       'externalDocuments' => [
+                               'controller' => 'Administration',
+                               'action' => 'externalDocuments',
+                               'label' => $this->getLanguageService()->sL('LLL:EXT:indexed_search/Resources/Private/Language/locallang.xml:administration.menu.externalDocuments')
+                       ],
+                       'statistic' => [
+                               'controller' => 'Administration',
+                               'action' => 'statistic',
+                               'label' => $this->getLanguageService()->sL('LLL:EXT:indexed_search/Resources/Private/Language/locallang.xml:administration.menu.statistic')
+                       ]
+               ];
+               $uriBuilder = $this->objectManager->get(UriBuilder::class);
+               $uriBuilder->setRequest($this->request);
+
+               $menu = $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
+               $menu->setIdentifier('IndexedSearchModuleMenu');
+
+               foreach ($menuItems as $menuItemConfig) {
+                       $isActive = $this->request->getControllerActionName() === $menuItemConfig['action'];
+                       $menuItem = $menu->makeMenuItem()
+                               ->setTitle($menuItemConfig['label'])
+                               ->setHref($this->getHref($menuItemConfig['controller'], $menuItemConfig['action']))
+                               ->setActive($isActive);
+                       $menu->addMenuItem($menuItem);
+               }
+
+               $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
+       }
+
+       /**
         * Function will be called before every other action
         *
         * @return void
@@ -170,6 +246,16 @@ class AdministrationController extends ActionController {
         * @return void
         */
        public function statisticDetailsAction($pageHash = 0) {
+               // Set back button
+               $icon = $this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-view-go-up', Icon::SIZE_SMALL);
+               $backButton = $this->view->getModuleTemplate()->getDocHeaderComponent()
+                       ->getButtonBar()->makeLinkButton()
+                       ->setTitle($this->getLanguageService()->sL('LLL:EXT:indexed_search/Resources/Private/Language/locallang.xml:administration.back'))
+                       ->setIcon($icon)
+                       ->setHref($this->getHref('Administration', 'statistic'));
+               $this->view->getModuleTemplate()->getDocHeaderComponent()
+                       ->getButtonBar()->addButton($backButton);
+
                $pageHash = (int)$pageHash;
                $db = $this->getDatabaseConnection();
                $pageHashRow = $db->exec_SELECTgetSingleRow('*', 'index_phash', 'phash = ' . (int)$pageHash);
@@ -341,6 +427,21 @@ class AdministrationController extends ActionController {
        }
 
        /**
+        * Creates te URI for a backend action
+        *
+        * @param string $controller
+        * @param string $action
+        * @param array $parameters
+        *
+        * @return string
+        */
+       protected function getHref($controller, $action, $parameters = []) {
+               $uriBuilder = $this->objectManager->get(UriBuilder::class);
+               $uriBuilder->setRequest($this->request);
+               return $uriBuilder->reset()->uriFor($action, $parameters, $controller);
+       }
+
+       /**
         * @return DatabaseConnection
         */
        protected function getDatabaseConnection() {
index 17f31c8..80ab262 100644 (file)
@@ -1,24 +1,3 @@
-<f:be.container>
-       <div class="typo3-fullDoc">
-               <div id="typo3-docheader">
-                       <div class="typo3-docheader-functions">
-                               <f:be.menus.actionMenu>
-                                       <f:be.menus.actionMenuItem label="{f:translate(key: 'administration.menu.general')}" controller="Administration" action="index" />
-                                       <f:be.menus.actionMenuItem label="{f:translate(key: 'administration.menu.pages')}" controller="Administration" action="pages" />
-                                       <f:be.menus.actionMenuItem label="{f:translate(key: 'administration.menu.externalDocuments')}" controller="Administration" action="externalDocuments" />
-                                       <f:be.menus.actionMenuItem label="{f:translate(key: 'administration.menu.statistic')}" controller="Administration" action="statistic" />
-                               </f:be.menus.actionMenu>
-                       </div>
-                       <div class="typo3-docheader-buttons">
-                               <f:render section="Buttons" />
-                       </div>
-               </div>
-
-               <div id="typo3-docbody">
-                       <div id="typo3-inner-docbody">
-                               <h1>Indexing Engine Statistics</h1>
-                               <f:render section="Content" />
-                       </div>
-               </div>
-       </div>
-</f:be.container>
\ No newline at end of file
+<f:be.pageRenderer />
+<h1>Indexing Engine Statistics</h1>
+<f:render section="Content" />
index 1780bb2..733c8f6 100644 (file)
@@ -66,6 +66,4 @@
                        </tbody>
                </table>
        </f:if>
-</f:section>
-
-<f:section name="Buttons"></f:section>
\ No newline at end of file
+</f:section>
\ No newline at end of file
index 69f6567..81179a0 100644 (file)
@@ -69,6 +69,4 @@
                        </tbody>
                </table>
        </f:if>
-</f:section>
-
-<f:section name="Buttons"></f:section>
\ No newline at end of file
+</f:section>
\ No newline at end of file
index 4f05277..c385568 100644 (file)
                        <h2><f:translate key="administration.noPageSelected"/></h2>
                </f:else>
        </f:if>
-</f:section>
-
-<f:section name="Buttons"></f:section>
\ No newline at end of file
+</f:section>
\ No newline at end of file
index 547ddb0..add1c33 100644 (file)
 
                </f:form>
        </f:if>
-</f:section>
-
-<f:section name="Buttons">
-       <a href="{f:uri.action(action:'statistic')}" title="{f:translate(key:'administration.back')}">
-               <core:icon identifier="actions-view-go-back" />
-       </a>
-</f:section>
+</f:section>
\ No newline at end of file
index 8dbd525..2cc6449 100644 (file)
@@ -46,6 +46,4 @@
        <f:link.action action="statisticDetails" arguments="{pageHash:phash}">
                <f:translate key="administration.linkBack"/>
        </f:link.action>
-</f:section>
-
-<f:section name="Buttons"></f:section>
\ No newline at end of file
+</f:section>
\ No newline at end of file