[BUGFIX] BE-Module "Access": Fixed "weird" styling and behavior 66/44066/10
authorMichael Oehlhof <typo3@oehlhof.de>
Wed, 14 Oct 2015 20:54:00 +0000 (22:54 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Thu, 15 Oct 2015 21:08:25 +0000 (23:08 +0200)
During implementation of the ModuleTemplate API for ext:beuser,
the changes for the access module were only half done.

Resolves: #70724
Releases: master
Change-Id: Id6557576f9e78a30706e88e3ed170eae0d42cb78
Reviewed-on: http://review.typo3.org/44066
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Tested-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/backend/Classes/Tree/View/AbstractTreeView.php
typo3/sysext/beuser/Classes/Controller/PermissionController.php

index 89d2083..9a3839f 100644 (file)
@@ -659,7 +659,7 @@ abstract class AbstractTreeView
     /**
      * Get icon for the row.
      *
-     * @param array $row Item row.
+     * @param array|int $row Item row or uid
      * @return string Image tag.
      */
     public function getIcon($row)
index 0e2709f..0414d83 100644 (file)
@@ -14,8 +14,11 @@ namespace TYPO3\CMS\Beuser\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Template\Components\ButtonBar;
 use TYPO3\CMS\Backend\Tree\View\PageTreeView;
+use TYPO3\CMS\Backend\View\BackendTemplateView;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
+use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
@@ -66,6 +69,20 @@ class PermissionController extends ActionController
     protected $pageInfo = array();
 
     /**
+     * Backend Template Container
+     *
+     * @var string
+     */
+    protected $defaultViewObjectName = BackendTemplateView::class;
+
+    /**
+     * BackendTemplateContainer
+     *
+     * @var BackendTemplateView
+     */
+    protected $view;
+
+    /**
      * Initialize action
      *
      * @return void
@@ -99,6 +116,8 @@ class PermissionController extends ActionController
      */
     protected function initializeView(ViewInterface $view)
     {
+        /** @var BackendTemplateView $view */
+        parent::initializeView($view);
         $view->assign(
             'previewUrl',
             BackendUtility::viewonclick(
@@ -106,6 +125,54 @@ class PermissionController extends ActionController
                 BackendUtility::BEgetRootLine($this->pageInfo['uid'])
             )
         );
+        $this->view->getModuleTemplate()->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Beuser/Permissions');
+        $this->view->getModuleTemplate()->addJavaScriptCode(
+            'jumpToUrl',
+            '
+            function jumpToUrl(URL) {
+                window.location.href = URL;
+                return false;
+            }
+            '
+        );
+        $this->registerDocheaderButtons();
+    }
+
+    /**
+     * 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();
+
+        $extensionName = $currentRequest->getControllerExtensionName();
+        if (empty($getVars)) {
+            $modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName);
+            $getVars = array('id', 'M', $modulePrefix);
+        }
+        $shortcutButton = $buttonBar->makeShortcutButton()
+            ->setModuleName($moduleName)
+            ->setGetVariables($getVars);
+        $buttonBar->addButton($shortcutButton);
+
+        if ($this->id > 0) {
+            $iconFactory = $this->view->getModuleTemplate()->getIconFactory();
+            $viewButton = $buttonBar->makeLinkButton()
+                ->setOnClick(htmlspecialchars(BackendUtility::viewOnClick($this->pageInfo['uid'], '',
+                    BackendUtility::BEgetRootLine($this->pageInfo['uid']))))
+                ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', true))
+                ->setIcon($iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL))
+                ->setHref('#');
+
+            $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 3);
+        }
     }
 
     /**
@@ -314,4 +381,14 @@ class PermissionController extends ActionController
         }
         return $options;
     }
+
+    /**
+     * Returns LanguageService
+     *
+     * @return \TYPO3\CMS\Lang\LanguageService
+     */
+    protected function getLanguageService()
+    {
+        return $GLOBALS['LANG'];
+    }
 }