Skip to content
Snippets Groups Projects
Commit b0d663a3 authored by Marc Willmann's avatar Marc Willmann Committed by Anja Leichsenring
Browse files

[TASK] Fluidification of ClearCacheToolbarItem

Resolves: #78436
Releases: master
Change-Id: I31e1d290f58ac01749091a05002025ee4598a49c
Reviewed-on: https://review.typo3.org/50377


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarGianluigi Martino <gmartino27@gmail.com>
Tested-by: default avatarGianluigi Martino <gmartino27@gmail.com>
Reviewed-by: default avatarDaniel Lorenz <info@extco.de>
Tested-by: default avatarDaniel Lorenz <info@extco.de>
Reviewed-by: default avatarMichael Oehlhof <typo3@oehlhof.de>
Tested-by: default avatarMichael Oehlhof <typo3@oehlhof.de>
Reviewed-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
parent 4c938aca
Branches
Tags
No related merge requests found
......@@ -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;
}
}
{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
<f:render partial="ToolbarItem" arguments="{title: title, icon: icon}"/>
\ No newline at end of file
<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>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment