[TASK] Fluidification of HelpToolbarItem 04/50404/3
authorMarc Willmann <mw@f7.de>
Thu, 27 Oct 2016 12:14:53 +0000 (14:14 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 27 Oct 2016 14:05:39 +0000 (16:05 +0200)
Resolves: #78466
Releases: master
Change-Id: I7ec8ed209f057733f0607f68b9645df7f634a4bb
Reviewed-on: https://review.typo3.org/50404
Reviewed-by: Kevin Appelt <kevin.appelt@icloud.com>
Tested-by: Kevin Appelt <kevin.appelt@icloud.com>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Daniel Lorenz <info@extco.de>
Tested-by: Daniel Lorenz <info@extco.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/backend/Classes/Backend/ToolbarItems/HelpToolbarItem.php
typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/HelpToolbarItem.html [new file with mode: 0644]
typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/HelpToolbarItemDropDown.html [new file with mode: 0644]

index cbbfc86..244d637 100644 (file)
@@ -14,12 +14,12 @@ namespace TYPO3\CMS\Backend\Backend\ToolbarItems;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Backend\Domain\Model\Module\BackendModule;
 use TYPO3\CMS\Backend\Domain\Repository\Module\BackendModuleRepository;
 use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Fluid\View\StandaloneView;
 
 /**
  * Help toolbar item
@@ -69,12 +69,16 @@ class HelpToolbarItem implements ToolbarItemInterface
      */
     public function getItem()
     {
-        $title = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.help'));
         $icon = $this->iconFactory->getIcon('apps-toolbar-menu-help', Icon::SIZE_SMALL)->render('inline');
-        return '
-            <span class="toolbar-item-icon" title="' . $title . '">' . $icon . '</span>
-            <span class="toolbar-item-title">' . $title . '</span>
-            ';
+
+        $view = $this->getFluidTemplateObject('HelpToolbarItem.html');
+        $view->assignMultiple([
+                'title' => 'LLL:EXT:lang/locallang_core.xlf:toolbarItems.help',
+                'icon' => $icon
+            ]
+        );
+
+        return $view->render();
     }
 
     /**
@@ -84,30 +88,14 @@ class HelpToolbarItem implements ToolbarItemInterface
      */
     public function getDropDown()
     {
-        $dropdown = [];
-        $dropdown[] = '<h3 class="dropdown-headline">' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.help')) . '</h3>';
-        $dropdown[] = '<hr>';
-        $dropdown[] = '<div class="dropdown-table">';
-        foreach ($this->helpModuleMenu->getChildren() as $module) {
-            /** @var BackendModule $module */
-            $dropdown[] = '<div'
-                . ' class="dropdown-table-row"'
-                . ' id="' . htmlspecialchars($module->getName()) . '"'
-                . ' data-modulename="' . htmlspecialchars($module->getName()) . '"'
-                . ' data-navigationcomponentid="' . htmlspecialchars($module->getNavigationComponentId()) . '"'
-                . ' data-navigationframescript="' . htmlspecialchars($module->getNavigationFrameScript()) . '"'
-                . ' data-navigationframescriptparameters="' . htmlspecialchars($module->getNavigationFrameScriptParameters()) . '"'
-                . '>';
-            $dropdown[] = '<div class="dropdown-table-column dropdown-table-icon">' . $module->getIcon() . '</div>';
-            $dropdown[] = '<div class="dropdown-table-column dropdown-table-title">';
-            $dropdown[] = '<a title="' . htmlspecialchars($module->getDescription()) . '" href="' . htmlspecialchars($module->getLink()) . '" class="modlink">';
-            $dropdown[] = htmlspecialchars($module->getTitle());
-            $dropdown[] = '</a>';
-            $dropdown[] = '</div>';
-            $dropdown[] = '</div>';
-        }
-        $dropdown[] = '</div>';
-        return implode(LF, $dropdown);
+        $view = $this->getFluidTemplateObject('HelpToolbarItemDropDown.html');
+        $view->assignMultiple([
+                'title' =>  'LLL:EXT:lang/locallang_core.xlf:rm.clearCache_clearCache',
+                'modules' => $this->helpModuleMenu->getChildren()
+            ]
+        );
+
+        return $view->render();
     }
 
     /**
@@ -149,4 +137,25 @@ class HelpToolbarItem implements ToolbarItemInterface
     {
         return $GLOBALS['LANG'];
     }
+
+    /**
+     * Returns a new standalone view, shorthand function
+     *
+     * @param string $filename Which templateFile should be used.
+     *
+     * @return StandaloneView
+     */
+    protected function getFluidTemplateObject(string $filename):StandaloneView
+    {
+        /** @var StandaloneView $view */
+        $view = GeneralUtility::makeInstance(StandaloneView::class);
+        $view->setLayoutRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Layouts')]);
+        $view->setPartialRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Partials/ToolbarItems')]);
+        $view->setTemplateRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates/ToolbarItems')]);
+
+        $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates/ToolbarItems/' . $filename));
+
+        $view->getRequest()->setControllerExtensionName('Backend');
+        return $view;
+    }
 }
diff --git a/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/HelpToolbarItem.html b/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/HelpToolbarItem.html
new file mode 100644 (file)
index 0000000..48941d8
--- /dev/null
@@ -0,0 +1 @@
+<f:render partial="ToolbarItem" arguments="{title: title, icon: icon}"/>
\ No newline at end of file
diff --git a/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/HelpToolbarItemDropDown.html b/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/HelpToolbarItemDropDown.html
new file mode 100644 (file)
index 0000000..2ba22f1
--- /dev/null
@@ -0,0 +1,23 @@
+<h3 class="dropdown-headline">
+    {f:translate(key: 'LLL:EXT:lang/locallang_core.xlf:toolbarItems.help', htmlEscape: 'FALSE')}
+</h3>
+<hr>
+<div class="dropdown-table">
+    <f:for each="{modules}" as="module">
+        <div class="dropdown-table-row"
+             id="{module.name -> f:format.htmlspecialchars()}"
+             data-modulename="{module.name -> f:format.htmlspecialchars()}"
+             data-navigationcomponentid="{module.navigationFrameScript -> f:format.htmlspecialchars()}"
+             data-navigationframescript="{module.navigationFrameScript -> f:format.htmlspecialchars()}"
+             data-navigationframescriptparameters="{module.navigationFrameScriptParameters -> f:format.htmlspecialchars()}">
+            <div class="dropdown-table-column dropdown-table-icon">
+                {module.icon -> f:format.raw()}
+            </div>
+            <div class="dropdown-table-column dropdown-table-title">
+                <f:link.typolink parameter="{module.link}" title="{module.description -> f:format.htmlspecialchars()}" class="modlink">
+                    {module.title}
+                </f:link.typolink>
+            </div>
+        </div>
+    </f:for>
+</div>