[TASK] Use ModuleTemplate API for EXT:cshmanual 82/43782/5
authorMathias Schreiber <mathias.schreiber@wmdb.de>
Sun, 4 Oct 2015 14:53:11 +0000 (16:53 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 9 Oct 2015 20:13:53 +0000 (22:13 +0200)
Releases: master
Resolves: #70352
Change-Id: I45b883a6cb84fbd82918080709205cbfa75b7b04
Reviewed-on: http://review.typo3.org/43782
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Resources/Public/JavaScript/ContextHelp.js
typo3/sysext/cshmanual/Classes/Controller/HelpController.php
typo3/sysext/cshmanual/Classes/Service/JavaScriptService.php
typo3/sysext/cshmanual/Classes/ViewHelpers/FormatViewHelper.php
typo3/sysext/cshmanual/Resources/Private/Layouts/Default.html
typo3/sysext/cshmanual/Resources/Private/Templates/Help/All.html
typo3/sysext/cshmanual/Resources/Private/Templates/Help/Detail.html

index b9c0cdb..2c5d2d4 100644 (file)
@@ -34,7 +34,12 @@ define('TYPO3/CMS/Backend/ContextHelp', ['jquery', 'TYPO3/CMS/Backend/Popover',
         * Initialize context help trigger
         */
        ContextHelp.initialize = function() {
-               ContextHelp.helpModuleUrl = top.TYPO3.settings.ContextHelp.moduleUrl;
+               ContextHelp.helpModuleUrl = (typeof top.TYPO3.settings.ContextHelp !== 'undefined') ? top.TYPO3.settings.ContextHelp.moduleUrl : null;
+               if (ContextHelp.helpModuleUrl === null) {
+                       // @FIXME: if we are in the popup... remove the bookmark / shortcut button
+                       // @TODO: make it possible to use the bookmark button also in popup mode
+                       $('.icon-actions-system-shortcut-new').closest('.btn').hide();
+               }
                var title = '&nbsp;';
                if (typeof(top.TYPO3.LLL) !== 'undefined') {
                        title = top.TYPO3.LLL.core.csh_tooltip_loading;
index 4651e29..43baee6 100644 (file)
@@ -14,10 +14,16 @@ namespace TYPO3\CMS\Cshmanual\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Template\Components\ButtonBar;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Backend\View\BackendTemplateView;
+use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Cshmanual\Domain\Repository\TableManualRepository;
 use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
+use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
+use TYPO3\CMS\Lang\LanguageService;
 
 /**
  * Main help module controller
@@ -28,6 +34,10 @@ class HelpController extends ActionController
      * Section identifiers
      */
     const FULL = 0;
+
+    /**
+     * Show only Table of contents
+     */
     const TOC_ONLY = 1;
 
     /**
@@ -36,6 +46,13 @@ class HelpController extends ActionController
     protected $tableManualRepository;
 
     /**
+     * Default View Container
+     *
+     * @var BackendTemplateView
+     */
+    protected $defaultViewObjectName = BackendTemplateView::class;
+
+    /**
      * Initialize the controller
      *
      * @return void
@@ -48,11 +65,14 @@ class HelpController extends ActionController
     /**
      * Initialize the view
      *
-     * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view The view
+     * @param ViewInterface $view The view
      * @return void
      */
-    public function initializeView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
+    public function initializeView(ViewInterface $view)
     {
+        /** @var BackendTemplateView $view */
+        parent::initializeView($view);
+        $this->registerDocheaderButtons();
         $view->assign('copyright', BackendUtility::TYPO3_copyRightNotice());
     }
 
@@ -119,4 +139,59 @@ class HelpController extends ActionController
             'manuals' => $field === '*' ? $this->tableManualRepository->getTableManual($mainKey) : array($this->tableManualRepository->getSingleManual($mainKey, $field)),
         ));
     }
+
+    /**
+     * Registers the Icons into the docheader
+     *
+     * @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);
+        }
+        if (isset($getVars['action']) && $getVars['action'] !== 'index') {
+            $backButton = $buttonBar->makeLinkButton()
+                ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:back', true))
+                ->setIcon($this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-view-go-up', Icon::SIZE_SMALL))
+                ->setHref(BackendUtility::getModuleUrl($moduleName));
+            $buttonBar->addButton($backButton);
+        }
+    }
+
+    /**
+     * Returns the currently logged in BE user
+     *
+     * @return BackendUserAuthentication
+     */
+    protected function getBackendUser()
+    {
+        return $GLOBALS['BE_USER'];
+    }
+
+    /**
+     * Returns the LanguageService
+     *
+     * @return LanguageService
+     */
+    protected function getLanguageService()
+    {
+        return $GLOBALS['LANG'];
+    }
 }
index 9163b5b..19e4784 100644 (file)
@@ -13,6 +13,9 @@ namespace TYPO3\CMS\Cshmanual\Service;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Page\PageRenderer;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * JavaScript Service adding JS code to each backend page
@@ -28,9 +31,9 @@ class JavaScriptService
     public function addJavaScript($title, $documentTemplateObject)
     {
         if (TYPO3_MODE === 'BE' && is_object($GLOBALS['BE_USER'])) {
-            $pageRenderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class);
+            $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
             $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ContextHelp');
-            $pageRenderer->addInlineSetting('ContextHelp', 'moduleUrl', \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('help_CshmanualCshmanual', array(
+            $pageRenderer->addInlineSetting('ContextHelp', 'moduleUrl', BackendUtility::getModuleUrl('help_CshmanualCshmanual', array(
                 'tx_cshmanual_help_cshmanualcshmanual' => array(
                     'controller' => 'Help',
                     'action' => 'detail'
index dc91784..6c7aac7 100644 (file)
@@ -51,7 +51,7 @@ class FormatViewHelper extends AbstractViewHelper implements CompilableInterface
 
     /**
      * @param array $arguments
-     * @param callable $renderChildrenClosure
+     * @param \Closure $renderChildrenClosure
      * @param RenderingContextInterface $renderingContext
      *
      * @return string
index adef4b2..39e7457 100644 (file)
@@ -1,31 +1,6 @@
-<f:be.container>
-       <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="docheader" />
-                               </div>
-                               <div class="right">
-                                       <f:be.buttons.shortcut />
-                               </div>
-                       </div>
-               </div>
-               <div id="typo3-docbody">
-                       <div id="typo3-inner-docbody">
-                               <f:render section="content" />
+<f:render section="content" />
 
-                               <hr />
-                               <p>
-                                       <f:format.raw>{copyright}</f:format.raw>
-                               </p>
-                       </div>
-               </div>
-       </div>
-</f:be.container>
\ No newline at end of file
+<hr />
+<p>
+       <f:format.raw>{copyright}</f:format.raw>
+</p>
index c381970..976ddde 100644 (file)
@@ -1,12 +1,5 @@
-{namespace core=TYPO3\CMS\Core\ViewHelpers}
 <f:layout name="Default" />
 
-<f:section name="docheader">
-       <a href="{f:uri.action(action:'index')}">
-               <core:icon identifier="actions-view-go-up" />
-       </a>
-</f:section>
-
 <f:section name="content">
        <f:render partial="TableOfContents" arguments="{toc:all.toc,all:1}" />
 
index c35312e..314bdd7 100644 (file)
@@ -1,13 +1,6 @@
 {namespace csh=TYPO3\CMS\Cshmanual\ViewHelpers}
-{namespace core=TYPO3\CMS\Core\ViewHelpers}
 <f:layout name="Default" />
 
-<f:section name="docheader">
-       <a href="{f:uri.action(action:'index')}">
-               <core:icon identifier="actions-view-go-up" />
-       </a>
-</f:section>
-
 <f:section name="content">
        <f:for each="{manuals}" as="manual">
                <f:render partial="Manual" arguments="{manual:manual}" />