[TASK] Use ModuleTemplate API for ext:reports 60/43860/5
authorRuud Silvrants <ruudsilvrants@gmail.com>
Tue, 6 Oct 2015 13:29:37 +0000 (15:29 +0200)
committerFrank Nägler <frank.naegler@typo3.org>
Fri, 9 Oct 2015 13:14:14 +0000 (15:14 +0200)
Change-Id: I913da0f863cef4ee672a8bee3e8bfe6ee2128479
Releases: master
Resolves: #70361
Reviewed-on: http://review.typo3.org/43860
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
typo3/sysext/compatibility6/Migrations/Code/ClassAliasMap.php
typo3/sysext/compatibility6/Migrations/Code/LegacyClassesForIde.php
typo3/sysext/reports/Classes/Controller/ReportController.php
typo3/sysext/reports/Classes/ViewHelpers/ActionMenuItemViewHelper.php [deleted file]
typo3/sysext/reports/Resources/Private/Layouts/Default.html
typo3/sysext/reports/Resources/Private/Partials/Menu.html [deleted file]
typo3/sysext/reports/Resources/Private/Templates/Report/Detail.html
typo3/sysext/reports/Resources/Private/Templates/Report/Index.html

index 04783b5..afeb235 100644 (file)
@@ -1083,7 +1083,6 @@ return array(
     'tx_reports_StatusProvider' => \TYPO3\CMS\Reports\StatusProviderInterface::class,
     'tx_reports_tasks_SystemStatusUpdateTask' => \TYPO3\CMS\Reports\Task\SystemStatusUpdateTask::class,
     'tx_reports_tasks_SystemStatusUpdateTaskNotificationEmailField' => \TYPO3\CMS\Reports\Task\SystemStatusUpdateTaskNotificationEmailField::class,
-    'Tx_Reports_ViewHelpers_ActionMenuItemViewHelper' => \TYPO3\CMS\Reports\ViewHelpers\ActionMenuItemViewHelper::class,
     'Tx_Reports_ViewHelpers_IconViewHelper' => \TYPO3\CMS\Reports\ViewHelpers\IconViewHelper::class,
     'tx_rsaauth_abstract_backend' => \TYPO3\CMS\Rsaauth\Backend\AbstractBackend::class,
     'tx_rsaauth_backendfactory' => \TYPO3\CMS\Rsaauth\Backend\BackendFactory::class,
index 240f29c..50b6757 100644 (file)
@@ -7536,13 +7536,6 @@ class tx_reports_tasks_SystemStatusUpdateTaskNotificationEmailField extends \TYP
 /**
  * @deprecated since 6.0, removed since 7.0
  */
-class Tx_Reports_ViewHelpers_ActionMenuItemViewHelper extends \TYPO3\CMS\Reports\ViewHelpers\ActionMenuItemViewHelper
-{
-}
-
-/**
- * @deprecated since 6.0, removed since 7.0
- */
 class Tx_Reports_ViewHelpers_IconViewHelper extends \TYPO3\CMS\Reports\ViewHelpers\IconViewHelper
 {
 }
index 0a8e6aa..261df26 100644 (file)
@@ -13,12 +13,33 @@ namespace TYPO3\CMS\Reports\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\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
+use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
+use TYPO3\CMS\Lang\LanguageService;
+use TYPO3\CMS\Reports\ReportInterface;
 
 /**
  * Reports controller
  */
-class ReportController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
+class ReportController extends ActionController
 {
+
+    /**
+     * @var BackendTemplateView
+     */
+    protected $view;
+
+    /**
+     * BackendTemplateView Container
+     *
+     * @var BackendTemplateView
+     */
+    protected $defaultViewObjectName = BackendTemplateView::class;
+
     /**
      * Redirect to the saved report
      *
@@ -26,11 +47,15 @@ class ReportController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
      */
     public function initializeAction()
     {
-        $vars = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('tx_reports_system_reportstxreportsm1');
+        $vars = GeneralUtility::_GET('tx_reports_system_reportstxreportsm1');
         if (!isset($vars['redirect']) && $vars['action'] !== 'index' && !isset($vars['extension']) && is_array($GLOBALS['BE_USER']->uc['reports']['selection'])) {
             $previousSelection = $GLOBALS['BE_USER']->uc['reports']['selection'];
             if (!empty($previousSelection['extension']) && !empty($previousSelection['report'])) {
-                $this->redirect('detail', 'Report', null, array('extension' => $previousSelection['extension'], 'report' => $previousSelection['report'], 'redirect' => 1));
+                $this->redirect('detail', 'Report', null, array(
+                    'extension' => $previousSelection['extension'],
+                    'report' => $previousSelection['report'],
+                    'redirect' => 1,
+                ));
             } else {
                 $this->redirect('index');
             }
@@ -38,16 +63,31 @@ class ReportController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
     }
 
     /**
+     * Initialize the view
+     *
+     * @param ViewInterface $view The view
+     *
+     * @return void
+     */
+    protected function initializeView(ViewInterface $view)
+    {
+        /** @var BackendTemplateView $view */
+        parent::initializeView($view);
+        $view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation([]);
+        $this->generateMenu();
+        $this->generateButtons();
+    }
+
+    /**
      * Overview
      *
      * @return void
      */
     public function indexAction()
     {
-        $this->view->assignMultiple(array(
-            'reports' => $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'],
-            'menu' => $this->getMenu()
-        ));
+        $this->view->assign(
+            'reports', $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']
+        );
         $this->saveState();
     }
 
@@ -56,6 +96,7 @@ class ReportController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
      *
      * @param string $extension Extension
      * @param string $report Report
+     *
      * @return void
      */
     public function detailAction($extension, $report)
@@ -77,8 +118,8 @@ class ReportController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
             $this->redirect('index');
         }
 
-        $reportInstance = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($reportClass, $this);
-        if ($reportInstance instanceof \TYPO3\CMS\Reports\ReportInterface) {
+        $reportInstance = GeneralUtility::makeInstance($reportClass, $this);
+        if ($reportInstance instanceof ReportInterface) {
             $content = $reportInstance->getReport();
             $this->saveState($extension, $report);
         } else {
@@ -88,28 +129,62 @@ class ReportController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
             'content' => $content,
             'error' => $error,
             'report' => $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'][$extension][$report],
-            'menu' => $this->getMenu()
         ));
     }
 
     /**
-     * Generate the menu
-     *
-     * @return array Menu items
+     * Generates the menu
      */
-    protected function getMenu()
+    protected function generateMenu()
     {
-        $reportsMenuItems = array();
+        $lang = $this->getLanguageService();
+        $lang->includeLLFile('EXT:reports/Resources/Private/Language/locallang.xlf');
+        $menu = $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
+        $menu->setIdentifier('WebFuncJumpMenu');
+        $menuItem = $menu
+            ->makeMenuItem()
+            ->setHref(
+                $this->uriBuilder->reset()->uriFor('index', null, 'Report')
+            )
+            ->setTitle($lang->getLL('reports_overview'));
+        $menu->addMenuItem($menuItem);
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'] as $extKey => $reports) {
             foreach ($reports as $reportName => $report) {
-                $reportsMenuItems[] = array(
-                    'title' => $GLOBALS['LANG']->sL($report['title']),
-                    'extension' => $extKey,
-                    'report' => $reportName
-                );
+                $menuItem = $menu
+                    ->makeMenuItem()
+                    ->setHref($this->uriBuilder->reset()->uriFor('detail',
+                        array('extension' => $extKey, 'report' => $reportName), 'Report'))
+                    ->setTitle($this->getLanguageService()->sL($report['title']));
+                if ($this->arguments->hasArgument('extension') && $this->arguments->hasArgument('report')) {
+                    if ($this->arguments->getArgument('extension')->getValue() === $extKey && $this->arguments->getArgument('report')->getValue() === $reportName) {
+                        $menuItem->setActive(true);
+                    }
+                }
+                $menu->addMenuItem($menuItem);
+            }
+        }
+        $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
+    }
+
+    /**
+     * Gets all buttons for the docheader
+     */
+    protected function generateButtons()
+    {
+        $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
+        $moduleName = $this->request->getPluginName();
+        $getVars = $this->request->hasArgument('getVars') ? $this->request->getArgument('getVars') : [];
+        $setVars = $this->request->hasArgument('setVars') ? $this->request->getArgument('setVars') : [];
+        if ($this->getBackendUser()->mayMakeShortcut()) {
+            if (count($getVars) === 0) {
+                $modulePrefix = strtolower('tx_' . $this->request->getControllerExtensionName() . '_' . $moduleName);
+                $getVars = array('id', 'M', $modulePrefix);
             }
+            $shortcutButton = $buttonBar->makeFullyRenderedButton()
+                ->setHtmlSource($this->view->getModuleTemplate()->makeShortcutIcon(implode(',',
+                    $getVars), implode(',', $setVars), $moduleName));
+            $buttonBar->addButton($shortcutButton, ButtonBar::BUTTON_POSITION_RIGHT, 99);
         }
-        return $reportsMenuItems;
     }
 
     /**
@@ -117,11 +192,31 @@ class ReportController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
      *
      * @param string $extension Extension name
      * @param string $report Report name
+     *
      * @return void
      */
     protected function saveState($extension = '', $report = '')
     {
-        $GLOBALS['BE_USER']->uc['reports']['selection'] = array('extension' => $extension, 'report' => $report);
+        $GLOBALS['BE_USER']->uc['reports']['selection'] = array(
+            'extension' => $extension,
+            'report' => $report,
+        );
         $GLOBALS['BE_USER']->writeUC();
     }
+
+    /**
+     * @return BackendUserAuthentication
+     */
+    protected function getBackendUser()
+    {
+        return $GLOBALS['BE_USER'];
+    }
+
+    /**
+     * @return LanguageService
+     */
+    protected function getLanguageService()
+    {
+        return $GLOBALS['LANG'];
+    }
 }
diff --git a/typo3/sysext/reports/Classes/ViewHelpers/ActionMenuItemViewHelper.php b/typo3/sysext/reports/Classes/ViewHelpers/ActionMenuItemViewHelper.php
deleted file mode 100644 (file)
index 232c529..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-namespace TYPO3\CMS\Reports\ViewHelpers;
-
-/*
- * 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!
- */
-
-/**
- * Render an item of the menu
- *
- * @internal
- */
-class ActionMenuItemViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper
-{
-    /**
-     * @var string
-     */
-    protected $tagName = 'option';
-
-    /**
-     * Renders an ActionMenu option tag
-     *
-     * @param string $label label of the option tag
-     * @param string $controller controller to be associated with this ActionMenuItem
-     * @param string $action the action to be associated with this ActionMenuItem
-     * @param array $arguments additional controller arguments to be passed to the action when this ActionMenuItem is selected
-     * @return string the rendered option tag
-     * @see \TYPO3\CMS\Fluid\ViewHelpers\Be\Menus\ActionMenuViewHelper
-     */
-    public function render($label, $controller, $action, array $arguments = array())
-    {
-        $uriBuilder = $this->controllerContext->getUriBuilder();
-        $uri = $uriBuilder->reset()->uriFor($action, $arguments, $controller);
-        $this->tag->addAttribute('value', $uri);
-        $currentRequest = $this->controllerContext->getRequest();
-        $currentController = $currentRequest->getControllerName();
-        $currentAction = $currentRequest->getControllerActionName();
-        $currentArguments = $currentRequest->getArguments();
-        unset($currentArguments['action']);
-        unset($currentArguments['controller']);
-        unset($currentArguments['redirect']);
-
-        if ($action === $currentAction && $controller === $currentController && $currentArguments === $arguments) {
-            $this->tag->addAttribute('selected', 'selected');
-        }
-        $this->tag->setContent($label);
-        return $this->tag->render();
-    }
-}
index 61d0adb..8d5af18 100644 (file)
@@ -1,26 +1 @@
-<f:be.container>
-       <div class="typo3-fullDoc" id="ext-reports-mod-index-php">
-               <div id="typo3-docheader">
-                       <div class="typo3-docheader-functions">
-                               <div class="left">
-                                       <f:render section="iconButtons" />
-                               </div>
-                               <div class="right">
-                               </div>
-                       </div>
-                       <div class="typo3-docheader-buttons">
-                               <div class="left">
-                               </div>
-                               <div class="right">
-                                       <f:be.buttons.shortcut />
-                               </div>
-                       </div>
-               </div>
-               <div id="typo3-docbody">
-                       <div id="typo3-inner-docbody">
-                               <f:flashMessages />
-                               <f:render section="content" />
-                       </div>
-               </div>
-       </div>
-</f:be.container>
\ No newline at end of file
+<f:render section="content" />
\ No newline at end of file
diff --git a/typo3/sysext/reports/Resources/Private/Partials/Menu.html b/typo3/sysext/reports/Resources/Private/Partials/Menu.html
deleted file mode 100644 (file)
index d66b995..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-{namespace r=TYPO3\CMS\Reports\ViewHelpers}
-
-<f:be.menus.actionMenu>
-       <f:be.menus.actionMenuItem label="{f:translate(key:'reports_overview')}" controller="Report" action="index" />
-       <f:for each="{menu}" as="item">
-               <r:actionMenuItem label="{item.title}" controller="Report" action="detail" arguments="{extension:item.extension,report:item.report}" />
-       </f:for>
-</f:be.menus.actionMenu>
\ No newline at end of file
index 968dfe1..d995a62 100644 (file)
@@ -2,10 +2,6 @@
 
 <f:layout name="Default" />
 
-<f:section name="iconButtons">
-       <f:render partial="Menu" arguments="{menu:menu}" />
-</f:section>
-
 <f:section name="content">
        <h1><f:translate key="title" /></h1>
 
index 8d6551c..c3f2569 100644 (file)
@@ -2,10 +2,6 @@
 
 <f:layout name="Default" />
 
-<f:section name="iconButtons">
-       <f:render partial="Menu" arguments="{menu:menu}" />
-</f:section>
-
 <f:section name="content">
        <h1><f:translate key="title" /></h1>