diff --git a/typo3/sysext/backend/Classes/Backend/ToolbarItems/ClearCacheToolbarItem.php b/typo3/sysext/backend/Classes/Backend/ToolbarItems/ClearCacheToolbarItem.php index 47429506c11ea4744ef232b45ea04b5623fcb540..5a420155fba6c2f3a733fbbef676f671d5e8c20c 100644 --- a/typo3/sysext/backend/Classes/Backend/ToolbarItems/ClearCacheToolbarItem.php +++ b/typo3/sysext/backend/Classes/Backend/ToolbarItems/ClearCacheToolbarItem.php @@ -21,6 +21,7 @@ use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Fluid\View\StandaloneView; /** * Render cache clearing toolbar item @@ -121,12 +122,16 @@ class ClearCacheToolbarItem implements ToolbarItemInterface */ public function getItem() { - $title = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:rm.clearCache_clearCache')); $icon = $this->iconFactory->getIcon('apps-toolbar-menu-cache', 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('ClearCacheToolbarItem.html'); + $view->assignMultiple([ + 'title' => 'LLL:EXT:lang/locallang_core.xlf:rm.clearCache_clearCache', + 'icon' => $icon + ] + ); + + return $view->render(); } /** @@ -136,32 +141,14 @@ class ClearCacheToolbarItem implements ToolbarItemInterface */ public function getDropDown() { - $result = []; - $result[] = '<h3 class="dropdown-headline">'; - $result[] = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:rm.clearCache_clearCache')); - $result[] = '</h3>'; - $result[] = '<hr>'; - $result[] = '<div class="dropdown-table">'; - foreach ($this->cacheActions as $cacheAction) { - $title = $cacheAction['description'] ?: $cacheAction['title']; - - $result[] = '<div class="dropdown-table-row">'; - - $result[] = '<div class="dropdown-table-column dropdown-table-column-top dropdown-table-icon">'; - $result[] = $cacheAction['icon']; - $result[] = '</div>'; - - $result[] = '<div class="dropdown-table-column dropdown-table-column-top dropdown-table-text">'; - $result[] = '<a href="' . htmlspecialchars($cacheAction['href']) . '">'; - $result[] = htmlspecialchars($cacheAction['title']); - $result[] = '<br><small class="text-muted">' . htmlspecialchars($title) . '</small>'; - $result[] = '</a>'; - $result[] = '</div>'; - - $result[] = '</div>'; - } - $result[] = '</div>'; - return implode(LF, $result); + $view = $this->getFluidTemplateObject('ClearCacheToolbarItemDropDown.html'); + $view->assignMultiple([ + 'title' => 'LLL:EXT:lang/locallang_core.xlf:rm.clearCache_clearCache', + 'cacheActions' => $this->cacheActions, + ] + ); + + return $view->render(); } /** @@ -223,4 +210,25 @@ class ClearCacheToolbarItem 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/Partials/ToolbarItems/ToolbarItem.html b/typo3/sysext/backend/Resources/Private/Partials/ToolbarItems/ToolbarItem.html new file mode 100644 index 0000000000000000000000000000000000000000..efc8745787ce593ee93c21f46e3641c12a44c254 --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/Partials/ToolbarItems/ToolbarItem.html @@ -0,0 +1,4 @@ +{namespace core = TYPO3\CMS\Core\ViewHelpers} + +<span class="toolbar-item-icon" title="{f:translate(key: title, htmlEscape: 'TRUE')}">{icon -> f:format.raw()}</span> +<span class="toolbar-item-title">{f:translate(key: title, htmlEscape: 'FALSE')}</span> \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/ClearCacheToolbarItem.html b/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/ClearCacheToolbarItem.html new file mode 100644 index 0000000000000000000000000000000000000000..48941d882c7b4b5c0b57b7de679efa696bbb22e7 --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/ClearCacheToolbarItem.html @@ -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/ClearCacheToolbarItemDropDown.html b/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/ClearCacheToolbarItemDropDown.html new file mode 100644 index 0000000000000000000000000000000000000000..84ec8abeb54c25d7795aefc3cab5d9276524d318 --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/ClearCacheToolbarItemDropDown.html @@ -0,0 +1,19 @@ +<h3 class="dropdown-headline"> + {f:translate(key: title, htmlEscape: 'FALSE')} +</h3> +<hr> +<div class="dropdown-table"> + <f:for each="{cacheActions}" as="cacheAction"> + <div class="dropdown-table-row"> + <div class="dropdown-table-column dropdown-table-column-top dropdown-table-icon"> + {cacheAction.icon -> f:format.raw()} + </div> + <div class="dropdown-table-column dropdown-table-column-top dropdown-table-text"> + <f:link.typolink parameter="{cacheAction.href}"> + {cacheAction.title} + <br><small class="text-muted">{f:if(condition: cacheAction.description,then: cacheAction.description,else: cacheAction.title)} </small> + </f:link.typolink> + </div> + </div> +</f:for> +</div>