Commit 133d167c authored by Christian Kuhn's avatar Christian Kuhn Committed by Andreas Fernandez
Browse files

Revert "[TASK] Port toolbar dropdowns to Fluid"

This reverts commit 13d0fcc0.

Moving these tiny html snippets to fluid
gives no real benefit.

Change-Id: I0f186028bd9bdb5b22ac5a3a325ca844a9d40beb
Reverts: #67537
Reviewed-on: http://review.typo3.org/40521


Reviewed-by: Benni Mack's avatarBenjamin Mack <benni@typo3.org>
Tested-by: Benni Mack's avatarBenjamin Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
parent 6d64d1d7
......@@ -23,47 +23,27 @@ use TYPO3\CMS\Fluid\View\StandaloneView;
*/
abstract class AbstractToolbarItem {
/**
* @var string Extension context
*/
protected $extension = 'backend';
/**
* @var string Template file for the dropdown menu
*/
protected $templateFile = '';
/**
* @var StandaloneView
*/
protected $standaloneView = NULL;
/**
* Constructor
*
* @throws \InvalidArgumentException
*/
public function __construct() {
if (empty($this->templateFile)) {
throw new \InvalidArgumentException('The template file for class "' . get_class($this) . '" is not set.', 1434530382);
}
$extPath = ExtensionManagementUtility::extPath($this->extension);
$extPath = ExtensionManagementUtility::extPath('backend');
/* @var $view StandaloneView */
$this->standaloneView = GeneralUtility::makeInstance(StandaloneView::class);
$this->standaloneView->setTemplatePathAndFilename($extPath . 'Resources/Private/Templates/ToolbarMenu/' . $this->templateFile);
$this->standaloneView->setPartialRootPaths(array(
$extPath . 'Resources/Private/Partials/ToolbarMenu/'
));
$this->standaloneView->setTemplatePathAndFilename($extPath . 'Resources/Private/Templates/ToolbarMenu/' . static::TOOLBAR_MENU_TEMPLATE);
}
/**
* @param string $extension Set the extension context (required for shorthand locallang.xlf references)
* @return StandaloneView
*/
protected function getStandaloneView() {
$request = $this->standaloneView->getRequest();
$request->setControllerExtensionName($this->extension);
protected function getStandaloneView($extension = NULL) {
if (!empty($extension)) {
$request = $this->standaloneView->getRequest();
$request->setControllerExtensionName($extension);
}
return $this->standaloneView;
}
}
......@@ -25,12 +25,7 @@ use TYPO3\CMS\Backend\Toolbar\ClearCacheActionsHookInterface;
*
* @author Ingo Renner <ingo@typo3.org>
*/
class ClearCacheToolbarItem extends AbstractToolbarItem implements ToolbarItemInterface {
/**
* @var string Template file for the dropdown menu
*/
protected $templateFile = 'ClearCache.html';
class ClearCacheToolbarItem implements ToolbarItemInterface {
/**
* @var array
......@@ -48,8 +43,6 @@ class ClearCacheToolbarItem extends AbstractToolbarItem implements ToolbarItemIn
* @throws \UnexpectedValueException
*/
public function __construct() {
parent::__construct();
$backendUser = $this->getBackendUser();
$languageService = $this->getLanguageService();
......@@ -143,20 +136,18 @@ class ClearCacheToolbarItem extends AbstractToolbarItem implements ToolbarItemIn
* @return string Drop down HTML
*/
public function getDropDown() {
$items = array();
$result = array();
$result[] = '<ul class="dropdown-list">';
foreach ($this->cacheActions as $cacheAction) {
$title = $cacheAction['description'] ?: $cacheAction['title'];
$items[] = array(
'title' => $title,
'label' => $cacheAction['title'],
'href' => $cacheAction['href'],
'icon' => $cacheAction['icon']
);
$result[] = '<li>';
$result[] = '<a class="dropdown-list-link" href="' . htmlspecialchars($cacheAction['href']) . '" title="' . htmlspecialchars($title) . '">';
$result[] = $cacheAction['icon'] . ' ' . htmlspecialchars($cacheAction['title']);
$result[] = '</a>';
$result[] = '</li>';
}
$standaloneView = $this->getStandaloneView();
$standaloneView->assign('items', $items);
return $standaloneView->render();
$result[] = '</ul>';
return implode(LF, $result);
}
/**
......
......@@ -22,12 +22,7 @@ use TYPO3\CMS\Backend\Domain\Model\Module\BackendModule;
/**
* Help toolbar item
*/
class HelpToolbarItem extends AbstractToolbarItem implements ToolbarItemInterface {
/**
* @var string Template file for the dropdown menu
*/
protected $templateFile = 'Help.html';
class HelpToolbarItem implements ToolbarItemInterface {
/**
* @var \SplObjectStorage<BackendModule>
......@@ -38,8 +33,6 @@ class HelpToolbarItem extends AbstractToolbarItem implements ToolbarItemInterfac
* Constructor
*/
public function __construct() {
parent::__construct();
/** @var BackendModuleRepository $backendModuleRepository */
$backendModuleRepository = GeneralUtility::makeInstance(BackendModuleRepository::class);
/** @var \TYPO3\CMS\Backend\Domain\Model\Module\BackendModule $userModuleMenu */
......@@ -75,25 +68,26 @@ class HelpToolbarItem extends AbstractToolbarItem implements ToolbarItemInterfac
*/
public function getDropDown() {
$dropdown = array();
$dropdown[] = '<ul class="dropdown-list">';
foreach ($this->helpModuleMenu->getChildren() as $module) {
/** @var BackendModule $module */
$dropdown[] = array(
'id' => $module->getName(),
'navigation' => array(
'componentId' => $module->getNavigationComponentId(),
'frameScript' => $module->getNavigationFrameScript(),
'frameScriptParameters' => $module->getNavigationFrameScriptParameters(),
),
'href' => $module->getLink(),
'description' => $module->getDescription(),
'icon' => $module->getIcon(),
'label' => $module->getTitle()
);
$moduleIcon = $module->getIcon();
$dropdown[] ='<li'
. ' id="' . htmlspecialchars($module->getName()) . '"'
. ' class="typo3-module-menu-item submodule mod-' . htmlspecialchars($module->getName()) . '" '
. ' data-modulename="' . htmlspecialchars($module->getName()) . '"'
. ' data-navigationcomponentid="' . htmlspecialchars($module->getNavigationComponentId()) . '"'
. ' data-navigationframescript="' . htmlspecialchars($module->getNavigationFrameScript()) . '"'
. ' data-navigationframescriptparameters="' . htmlspecialchars($module->getNavigationFrameScriptParameters()) . '"'
. '>';
$dropdown[] = '<a title="' . htmlspecialchars($module->getDescription()) . '" href="' . htmlspecialchars($module->getLink()) . '" class="dropdown-list-link modlink">';
$dropdown[] = '<span class="submodule-icon typo3-app-icon"><span><span>' . $moduleIcon . '</span></span></span>';
$dropdown[] = '<span class="submodule-label">' . htmlspecialchars($module->getTitle()) . '</span>';
$dropdown[] = '</a>';
$dropdown[] = '</li>';
}
$standaloneView = $this->getStandaloneView();
$standaloneView->assign('dropdown', $dropdown);
return $standaloneView->render();
$dropdown[] = '</ul>';
return implode(LF, $dropdown);
}
/**
......
......@@ -28,28 +28,13 @@ use TYPO3\CMS\Core\Utility\PathUtility;
*
* @author Ingo Renner <ingo@typo3.org>
*/
class ShortcutToolbarItem extends AbstractToolbarItem implements ToolbarItemInterface {
class ShortcutToolbarItem implements ToolbarItemInterface {
/**
* @const int Number of super global group
* @const integer Number of super global group
*/
const SUPERGLOBAL_GROUP = -100;
/**
* @const string Type of shortcut groups
*/
const TYPE_GROUP = 'group';
/**
* @const string Type of shortcut items
*/
const TYPE_ITEM = 'item';
/**
* @var string Template file for the dropdown menu
*/
protected $templateFile = 'Shortcut.html';
/**
* @var string
*/
......@@ -91,8 +76,6 @@ class ShortcutToolbarItem extends AbstractToolbarItem implements ToolbarItemInte
$loadModules->load($GLOBALS['TBE_MODULES']);
}
parent::__construct();
// By default, 5 groups are set
$this->shortcutGroups = array(
1 => '1',
......@@ -143,70 +126,65 @@ class ShortcutToolbarItem extends AbstractToolbarItem implements ToolbarItemInte
$editIcon = '<a href="#" class="dropdown-list-link-edit shortcut-edit">' . IconUtility::getSpriteIcon('actions-document-open', array('title' => $shortcutEdit)) . '</a>';
$deleteIcon = '<a href="#" class="dropdown-list-link-delete shortcut-delete">' . IconUtility::getSpriteIcon('actions-edit-delete', array('title' => $shortcutDelete)) . '</a>';
$shortcutMenu = array();
$shortcutMenu[] = '<ul class="dropdown-list">';
// Render shortcuts with no group (group id = 0) first
$noGroupShortcuts = $this->getShortcutsByGroup(0);
foreach ($noGroupShortcuts as $shortcut) {
$shortcutMenu[] = array(
'uid' => (int)$shortcut['raw']['uid'],
'groupid' => static::SUPERGLOBAL_GROUP,
'type' => static::TYPE_ITEM,
'action' => $shortcut['action'],
'icon' => $shortcut['icon'],
'label' => $shortcut['label']
);
$shortcutMenu[] = '
<li class="shortcut" data-shortcutid="' . (int)$shortcut['raw']['uid'] . '">
<a class="dropdown-list-link dropdown-link-list-add-editdelete" href="#" onclick="' . htmlspecialchars($shortcut['action']) . ' return false;">' .
$shortcut['icon'] . ' ' .
htmlspecialchars($shortcut['label']) .
'</a>
' . $editIcon . $deleteIcon . '
</li>';
}
// Now render groups and the contained shortcuts
$groups = $this->getGroupsFromShortcuts();
krsort($groups, SORT_NUMERIC);
foreach ($groups as $groupId => $groupLabel) {
$groupId = (int)$groupId;
if ($groupId === 0) {
continue;
}
$shortcutMenu[] = array(
'uid' => $groupId,
'type' => static::TYPE_GROUP,
'label' => $groupLabel
);
$shortcuts = $this->getShortcutsByGroup($groupId);
$i = 0;
foreach ($shortcuts as $shortcut) {
$i++;
$shortcutMenu[] = array(
'uid' => (int)$shortcut['raw']['uid'],
'groupid' => (int)$groupId,
'type' => static::TYPE_ITEM,
'action' => $shortcut['action'],
'icon' => $shortcut['icon'],
'label' => $shortcut['label']
);
if ($groupId != 0) {
$shortcutGroup = '';
if (count($shortcutMenu) > 1) {
$shortcutGroup .= '<li class="divider"></li>';
}
$shortcutGroup .= '
<li class="dropdown-header" id="shortcut-group-' . (int)$groupId . '">
' . $groupLabel . '
</li>';
$shortcuts = $this->getShortcutsByGroup($groupId);
$i = 0;
foreach ($shortcuts as $shortcut) {
$i++;
$shortcutGroup .= '
<li class="shortcut" data-shortcutid="' . (int)$shortcut['raw']['uid'] . '" data-shortcutgroup="' . (int)$groupId . '">
<a class="dropdown-list-link dropdown-link-list-add-editdelete" href="#" onclick="' . htmlspecialchars($shortcut['action']) . ' return false;">' .
$shortcut['icon'] . ' ' .
htmlspecialchars($shortcut['label']) .
'</a>
' . $editIcon . $deleteIcon . '
</li>';
}
$shortcutMenu[] = $shortcutGroup;
}
}
$shortcutMenu[] = '</ul>';
$standaloneView = $this->getStandaloneView();
$standaloneView->assignMultiple(array(
'hasEntries' => !empty($shortcutMenu),
'shortcutMenu' => $shortcutMenu,
'editIcon' => $editIcon,
'deleteIcon' => $deleteIcon,
));
if (empty($shortcutMenu)) {
if (count($shortcutMenu) == 2) {
// No shortcuts added yet, show a small help message how to add shortcuts
$title = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.bookmarks', TRUE);
$icon = IconUtility::getSpriteIcon('actions-system-shortcut-new', array(
'title' => $title
));
$label = str_replace('%icon%', $icon, $languageService->sL('LLL:EXT:lang/locallang_misc.xlf:bookmarkDescription'));
$standaloneView->assign('introduction', $label);
$compiledShortcutMenu = '<p>' . $label . '</p>';
} else {
$compiledShortcutMenu = implode(LF, $shortcutMenu);
}
return $standaloneView->render();
return $compiledShortcutMenu;
}
/**
......
......@@ -29,9 +29,9 @@ use TYPO3\CMS\Core\Utility\StringUtility;
class SystemInformationToolbarItem extends AbstractToolbarItem implements ToolbarItemInterface {
/**
* @var string Template file for the dropdown menu
* Template file for the dropdown menu
*/
protected $templateFile = 'SystemInformation.html';
const TOOLBAR_MENU_TEMPLATE = 'SystemInformation.html';
/**
* Number displayed as badge on the dropdown trigger
......@@ -280,15 +280,14 @@ class SystemInformationToolbarItem extends AbstractToolbarItem implements Toolba
return '';
}
$standaloneView = $this->getStandaloneView();
$standaloneView->assignMultiple(array(
$this->getStandaloneView('backend')->assignMultiple(array(
'installToolUrl' => BackendUtility::getModuleUrl('system_InstallInstall'),
'messages' => $this->systemMessages,
'count' => $this->totalCount,
'severityBadgeClass' => $this->severityBadgeClass,
'systemInformation' => $this->systemInformation
));
return $standaloneView->render();
return $this->getStandaloneView()->render();
}
/**
......
......@@ -24,12 +24,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
/**
* User toolbar item
*/
class UserToolbarItem extends AbstractToolbarItem implements ToolbarItemInterface {
/**
* @var string Template file for the dropdown menu
*/
protected $templateFile = 'User.html';
class UserToolbarItem implements ToolbarItemInterface {
/**
* Item is always enabled
......@@ -80,6 +75,7 @@ class UserToolbarItem extends AbstractToolbarItem implements ToolbarItemInterfac
$languageService = $this->getLanguageService();
$dropdown = array();
$dropdown[] = '<ul class="dropdown-list">';
/** @var BackendModuleRepository $backendModuleRepository */
$backendModuleRepository = GeneralUtility::makeInstance(BackendModuleRepository::class);
......@@ -88,33 +84,34 @@ class UserToolbarItem extends AbstractToolbarItem implements ToolbarItemInterfac
if ($userModuleMenu != FALSE && $userModuleMenu->getChildren()->count() > 0) {
foreach ($userModuleMenu->getChildren() as $module) {
/** @var BackendModule $module */
$dropdown[] = array(
'id' => $module->getName(),
'navigation' => array(
'componentId' => $module->getNavigationComponentId(),
'frameScript' => $module->getNavigationFrameScript(),
'frameScriptParameters' => $module->getNavigationFrameScriptParameters(),
),
'href' => $module->getLink(),
'description' => $module->getDescription(),
'icon' => $module->getIcon(),
'label' => $module->getTitle()
);
$dropdown[] ='<li'
. ' id="' . htmlspecialchars($module->getName()) . '"'
. ' class="typo3-module-menu-item submodule mod-' . htmlspecialchars($module->getName()) . '" '
. ' data-modulename="' . htmlspecialchars($module->getName()) . '"'
. ' data-navigationcomponentid="' . htmlspecialchars($module->getNavigationComponentId()) . '"'
. ' data-navigationframescript="' . htmlspecialchars($module->getNavigationFrameScript()) . '"'
. ' data-navigationframescriptparameters="' . htmlspecialchars($module->getNavigationFrameScriptParameters()) . '"'
. '>';
$dropdown[] = '<a title="' . htmlspecialchars($module->getDescription()) . '" href="' . htmlspecialchars($module->getLink()) . '" class="dropdown-list-link modlink">';
$dropdown[] = '<span class="submodule-icon typo3-app-icon"><span><span>' . $module->getIcon() . '</span></span></span>';
$dropdown[] = '<span class="submodule-label">' . htmlspecialchars($module->getTitle()) . '</span>';
$dropdown[] = '</a>';
$dropdown[] = '</li>';
}
$dropdown[] = '<li class="divider"></li>';
}
// Logout button
$logoutButton = array(
'label' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:' . ($backendUser->user['ses_backuserid'] ? 'buttons.exit' : 'buttons.logout')),
'href' => htmlspecialchars(BackendUtility::getModuleUrl('logout')),
);
$standaloneView = $this->getStandaloneView();
$standaloneView->assignMultiple(array(
'dropdown' => $dropdown,
'logoutButton' => $logoutButton
));
return $standaloneView->render();
$buttonLabel = 'LLL:EXT:lang/locallang_core.xlf:' . ($backendUser->user['ses_backuserid'] ? 'buttons.exit' : 'buttons.logout');
$dropdown[] = '<li class="reset-dropdown">';
$dropdown[] = '<a href="' . htmlspecialchars(BackendUtility::getModuleUrl('logout')) . '" class="btn btn-danger pull-right" target="_top"><i class="fa fa-power-off"></i> ';
$dropdown[] = $languageService->sL($buttonLabel, TRUE);
$dropdown[] = '</a>';
$dropdown[] = '</li>';
$dropdown[] = '</ul>';
return implode(LF, $dropdown);
}
/**
......
<ul class="dropdown-list">
<f:for each="{items}" as="item">
<li>
<a class="dropdown-list-link" href="{item.href}" title="{item.title}">
<f:format.raw>{item.icon}</f:format.raw> {item.label}
</a>
</li>
</f:for>
</ul>
\ No newline at end of file
<ul class="dropdown-list">
<f:for each="{dropdown}" as="item">
<li class="typo3-module-menu-item submodule mod-{item.id}" id="{item.id}" data-modulename="{item.id}" data-navigationcomponentid="{item.navigation.componentId}" data-navigationframescript="{item.navigation.frameScript}" data-navigationframescriptparameters="{item.navigation.frameScriptParameters}">
<a class="dropdown-list-link modlink" href="{item.href}" title="{item.description}">
<span class="submodule-icon typo3-app-icon"><span><span><f:format.raw>{item.icon}</f:format.raw></span></span></span>
<span class="submodule-label">{item.label}</span>
</a>
</li>
</f:for>
</ul>
\ No newline at end of file
<f:if condition="{hasEntries}">
<f:then>
<ul class="dropdown-list">
<f:for each="{shortcutMenu}" as="shortcut" iteration="iteration">
<f:if condition="{shortcut.type} == 'group'">
<f:if condition="{iteration.isFirst}">
<f:then></f:then>
<f:else><li class="divider"></li></f:else>
</f:if>
<li class="dropdown-header" id="shortcut-group-{shortcut.uid}">
{shortcut.label}
</li>
</f:if>
<f:if condition="{shortcut.type} == 'item'">
<li class="shortcut" data-shortcutid="{shortcut.uid}">
<a class="dropdown-list-link dropdown-link-list-add-editdelete" href="#" onclick="{shortcut.action} return false;">
<f:format.raw>{shortcut.icon}</f:format.raw> {shortcut.label}
</a>
<f:format.raw>{editIcon}</f:format.raw>
<f:format.raw>{deleteIcon}</f:format.raw>
</li>
</f:if>
</f:for>
</ul>
</f:then>
<f:else>
<f:format.raw>{introduction}</f:format.raw>
</f:else>
</f:if>
\ No newline at end of file
<ul class="dropdown-list">
<f:for each="{dropdown}" as="item">
<li class="typo3-module-menu-item submodule mod-{item.id}" id="{item.id}" data-modulename="{item.id}" data-navigationcomponentid="{item.navigation.componentId}" data-navigationframescript="{item.navigation.frameScript}" data-navigationframescriptparameters="{item.navigation.frameScriptParameters}">
<a class="dropdown-list-link modlink" href="{item.href}" title="{item.description}">
<span class="submodule-icon typo3-app-icon"><span><span><f:format.raw>{item.icon}</f:format.raw></span></span></span>
<span class="submodule-label">{item.label}</span>
</a>
</li>
</f:for>
<li class="divider"></li>
<li class="reset-dropdown">
<a href="{logoutButton.href}" class="btn btn-danger pull-right" target="_top">
<i class="fa fa-power-off"></i> {logoutButton.label}
</a>
</li>
</ul>
\ No newline at end of file
......@@ -15,27 +15,16 @@ namespace TYPO3\CMS\Opendocs\Backend\ToolbarItems;
*/
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\Backend\ToolbarItems\AbstractToolbarItem;
use TYPO3\CMS\Backend\Utility\IconUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* A list of all open documents
* Alist of all open documents
*
* @author Benjamin Mack <benni@typo3.org>
* @author Ingo Renner <ingo@typo3.org>
*/
class OpendocsToolbarItem extends AbstractToolbarItem implements ToolbarItemInterface {
/**
* @var string Extension context
*/
protected $extension = 'opendocs';
/**
* @var string Template file for the dropdown menu
*/
protected $templateFile = 'Opendocs.html';
class OpendocsToolbarItem implements ToolbarItemInterface {
/**
* @var array
......@@ -51,8 +40,7 @@ class OpendocsToolbarItem extends AbstractToolbarItem implements ToolbarItemInte
* Constructor
*/
public function __construct() {
parent::__construct();
$this->getLanguageService()->includeLLFile('EXT:opendocs/Resources/Private/Language/locallang.xlf');
$this->loadDocsFromUserSession();
$pageRenderer = $this->getPageRenderer();
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Opendocs/Toolbar/OpendocsMenu');
......@@ -101,40 +89,34 @@ class OpendocsToolbarItem extends AbstractToolbarItem implements ToolbarItemInte
* @return string HTML
*/
public function getDropDown() {
$languageService = $this->getLanguageService();
$openDocuments = $this->openDocs;
$recentDocuments = $this->recentDocs;
$entries = array(
'open' => array(),
'recent' => array()
);
if (!empty($openDocuments)) {
$entries = array();
if (count($openDocuments)) {
$entries[] = '<li class="dropdown-header">' . $languageService->getLL('open_docs', TRUE) . '</li>';
$i = 0;
foreach ($openDocuments as $md5sum => $openDocument) {
$i++;
$entry = $this->renderMenuEntry($openDocument, $md5sum, FALSE, $i === 1);
if (!empty($entry)) {