Commit 6cd27b49 authored by Benjamin Kott's avatar Benjamin Kott Committed by Wouter Wolters
Browse files

[!!!][TASK] Replace sprite icons with IconFactory in ContextMenu

Resolves: #69561
Releases: master
Change-Id: Id63095ab5cdc1043b1bb327760d4cf6f66ec00c6
Reviewed-on: http://review.typo3.org/43071


Reviewed-by: default avatarDaniel Goerz <ervaude@gmail.com>
Tested-by: default avatarDaniel Goerz <ervaude@gmail.com>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
parent c24cfbff
......@@ -161,6 +161,12 @@ module.exports = function(grunt) {
'<%= paths.sysext %>backend/Resources/Public/Icons/avatar-default.svg': '<%= paths.icons %>Avatar/avatar-default.svg'
}
},
// Miscellaneous Icons
icons_miscellaneous: {
files: {
'<%= paths.backend %>Public/Icons/Miscellaneous/miscellaneous-placeholder.svg': '<%= paths.icons %>Miscellaneous/miscellaneous-placeholder.svg'
}
},
// Module Icons
icons_module: {
files: {
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
</svg>
......@@ -15,6 +15,13 @@ namespace TYPO3\CMS\Backend\ContextMenu;
*/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Backend\ContextMenu\ContextMenuAction;
use TYPO3\CMS\Backend\ContextMenu\ContextMenuActionCollection;
use TYPO3\CMS\Backend\Tree\TreeNode;
/**
* Abstract Context Menu Data Provider
......@@ -57,10 +64,10 @@ abstract class AbstractContextMenuDataProvider {
/**
* Returns the actions of the node
*
* @param \TYPO3\CMS\Backend\Tree\TreeNode $node
* @return \TYPO3\CMS\Backend\ContextMenu\ContextMenuActionCollection
* @param TreeNode $node
* @return ContextMenuActionCollection
*/
abstract public function getActionsForNode(\TYPO3\CMS\Backend\Tree\TreeNode $node);
abstract public function getActionsForNode(TreeNode $node);
/**
* Returns the configuration of the specified context menu type
......@@ -80,11 +87,11 @@ abstract class AbstractContextMenuDataProvider {
* isLeafNode:1
* isLeafNode:1 && isInCutMode:1
*
* @param \TYPO3\CMS\Backend\Tree\TreeNode $node
* @param TreeNode $node
* @param string $displayCondition
* @return bool
*/
protected function evaluateDisplayCondition(\TYPO3\CMS\Backend\Tree\TreeNode $node, $displayCondition) {
protected function evaluateDisplayCondition(TreeNode $node, $displayCondition) {
if ($displayCondition === '') {
return TRUE;
}
......@@ -143,13 +150,15 @@ abstract class AbstractContextMenuDataProvider {
* Returns the next context menu level
*
* @param array $actions
* @param \TYPO3\CMS\Backend\Tree\TreeNode $node
* @param TreeNode $node
* @param int $level
* @return \TYPO3\CMS\Backend\ContextMenu\ContextMenuActionCollection
* @return ContextMenuActionCollection
*/
protected function getNextContextMenuLevel(array $actions, \TYPO3\CMS\Backend\Tree\TreeNode $node, $level = 0) {
/** @var $actionCollection \TYPO3\CMS\Backend\ContextMenu\ContextMenuActionCollection */
$actionCollection = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\ContextMenu\ContextMenuActionCollection::class);
protected function getNextContextMenuLevel(array $actions, TreeNode $node, $level = 0) {
/** @var $actionCollection ContextMenuActionCollection */
$actionCollection = GeneralUtility::makeInstance(ContextMenuActionCollection::class);
/** @var $iconFactory IconFactory */
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
if ($level > 5) {
return $actionCollection;
}
......@@ -164,8 +173,8 @@ abstract class AbstractContextMenuDataProvider {
if (!in_array($type, array('DIVIDER', 'SUBMENU', 'ITEM'))) {
continue;
}
/** @var $action \TYPO3\CMS\Backend\ContextMenu\ContextMenuAction */
$action = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\ContextMenu\ContextMenuAction::class);
/** @var $action ContextMenuAction */
$action = GeneralUtility::makeInstance(ContextMenuAction::class);
$action->setId($index);
if ($type === 'DIVIDER') {
$action->setType('divider');
......@@ -189,11 +198,10 @@ abstract class AbstractContextMenuDataProvider {
}
}
$action->setLabel($label);
if (isset($actionConfiguration['icon']) && trim($actionConfiguration['icon']) !== '') {
$action->setIcon($actionConfiguration['icon']);
} elseif (isset($actionConfiguration['spriteIcon'])) {
$action->setClass(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconClasses($actionConfiguration['spriteIcon']));
if (!isset($actionConfiguration['iconName'])) {
$actionConfiguration['iconName'] = 'miscellaneous-placeholder';
}
$action->setIcon((string)$iconFactory->getIcon($actionConfiguration['iconName'], Icon::SIZE_SMALL));
}
$actionCollection->offsetSet($level . (int)$index, $action);
$actionCollection->ksort();
......
......@@ -44,6 +44,7 @@ class ContextMenuAction {
* Class
*
* @var string
* @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
*/
protected $class = '';
......@@ -134,8 +135,10 @@ class ContextMenuAction {
* Returns the class
*
* @return string
* @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
*/
public function getClass() {
GeneralUtility::logDeprecatedFunction();
return $this->class;
}
......@@ -143,8 +146,10 @@ class ContextMenuAction {
* Sets the class
*
* @param string $class
* @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
*/
public function setClass($class) {
GeneralUtility::logDeprecatedFunction();
$this->class = $class;
}
......@@ -245,7 +250,6 @@ class ContextMenuAction {
'label' => $this->getLabel(),
'id' => $this->getId(),
'icon' => $this->getIcon(),
'class' => $this->getClass(),
'callbackAction' => $this->getCallbackAction(),
'type' => $this->getType(),
'customAttributes' => $this->getCustomAttributes()
......
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"/>
\ No newline at end of file
......@@ -135,8 +135,7 @@ TYPO3.Components.PageTree.ContextMenu = Ext.extend(Ext.menu.Menu, {
text: contextMenuConfiguration[singleAction]['label'],
cls: 'contextMenu-subMenu',
menu: subMenu,
icon: contextMenuConfiguration[singleAction]['icon'],
iconCls: contextMenuConfiguration[singleAction]['class']
icon: contextMenuConfiguration[singleAction]['icon']
};
}
} else if (contextMenuConfiguration[singleAction]['type'] === 'divider') {
......@@ -151,15 +150,12 @@ TYPO3.Components.PageTree.ContextMenu = Ext.extend(Ext.menu.Menu, {
var component = {
'text': contextMenuConfiguration[singleAction]['label'],
'icon': contextMenuConfiguration[singleAction]['icon'],
'iconCls': contextMenuConfiguration[singleAction]['class'],
'callbackAction': contextMenuConfiguration[singleAction]['callbackAction'],
'customAttributes': contextMenuConfiguration[singleAction]['customAttributes']
};
component.itemTpl = Ext.menu.Item.prototype.itemTpl = new Ext.XTemplate(
'<a id="{id}" class="{cls}" hidefocus="true" unselectable="on" href="{href}">',
'<span class="{hrefTarget}">',
'<span class="x-menu-item-icon" unselectable="on"><span class="{iconCls}"></span></span>',
'</span>',
'<span class="x-menu-item-icon" unselectable="on">{icon}</span>',
'<span class="x-menu-item-text">{text}</span>',
'</a>'
);
......
......@@ -394,6 +394,24 @@ class IconRegistry implements \TYPO3\CMS\Core\SingletonInterface {
'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-page-open.svg',
)
),
'actions-pagetree-collapse' => array(
'provider' => FontawesomeIconProvider::class,
'options' => array(
'name' => 'caret-right',
)
),
'actions-pagetree-expand' => array(
'provider' => FontawesomeIconProvider::class,
'options' => array(
'name' => 'caret-down',
)
),
'actions-pagetree-mountroot' => array(
'provider' => FontawesomeIconProvider::class,
'options' => array(
'name' => 'anchor',
)
),
'actions-selection-delete' => array(
'provider' => FontawesomeIconProvider::class,
'options' => array(
......@@ -553,6 +571,14 @@ class IconRegistry implements \TYPO3\CMS\Core\SingletonInterface {
)
),
// Miscellaneous icons
'miscellaneous-placeholder' => array(
'provider' => SvgIconProvider::class,
'options' => array(
'source' => 'EXT:backend/Resources/Public/Icons/Miscellaneous/miscellaneous-placeholder.svg',
)
),
// Status
'status-status-current' => array(
'provider' => FontawesomeIconProvider::class,
......
......@@ -565,7 +565,7 @@ return array(
100 {
name = history
label = LLL:EXT:lang/locallang_misc.xlf:CM_history
spriteIcon = actions-document-history-open
iconName = actions-document-history-open
displayCondition = canShowHistory != 0
callbackAction = openHistoryPopUp
}
......@@ -580,7 +580,7 @@ return array(
100 {
name = view
label = LLL:EXT:lang/locallang_core.xlf:cm.view
spriteIcon = actions-document-view
iconName = actions-document-view
displayCondition = canBeViewed != 0
callbackAction = viewPage
}
......@@ -589,7 +589,7 @@ return array(
200 {
name = new
label = LLL:EXT:lang/locallang_core.xlf:cm.new
spriteIcon = actions-page-new
iconName = actions-page-new
displayCondition = canCreateNewPages != 0
callbackAction = newPageWizard
}
......@@ -600,7 +600,7 @@ return array(
400 {
name = history
label = LLL:EXT:lang/locallang_misc.xlf:CM_history
spriteIcon = actions-document-history-open
iconName = actions-document-history-open
displayCondition = canShowHistory != 0
callbackAction = openHistoryPopUp
}
......@@ -615,7 +615,7 @@ return array(
100 {
name = view
label = LLL:EXT:lang/locallang_core.xlf:cm.view
spriteIcon = actions-document-view
iconName = actions-document-view
displayCondition = canBeViewed != 0
callbackAction = viewPage
}
......@@ -626,7 +626,7 @@ return array(
300 {
name = disable
label = LLL:EXT:lang/locallang_common.xlf:disable
spriteIcon = actions-edit-hide
iconName = actions-edit-hide
displayCondition = getRecord|hidden = 0 && canBeDisabledAndEnabled != 0
callbackAction = disablePage
}
......@@ -635,7 +635,7 @@ return array(
400 {
name = enable
label = LLL:EXT:lang/locallang_common.xlf:enable
spriteIcon = actions-edit-unhide
iconName = actions-edit-unhide
displayCondition = getRecord|hidden = 1 && canBeDisabledAndEnabled != 0
callbackAction = enablePage
}
......@@ -644,7 +644,7 @@ return array(
500 {
name = edit
label = LLL:EXT:lang/locallang_core.xlf:cm.edit
spriteIcon = actions-page-open
iconName = actions-page-open
displayCondition = canBeEdited != 0
callbackAction = editPageProperties
}
......@@ -653,7 +653,7 @@ return array(
600 {
name = info
label = LLL:EXT:lang/locallang_core.xlf:cm.info
spriteIcon = actions-document-info
iconName = actions-document-info
displayCondition = canShowInfo != 0
callbackAction = openInfoPopUp
}
......@@ -662,7 +662,7 @@ return array(
700 {
name = history
label = LLL:EXT:lang/locallang_misc.xlf:CM_history
spriteIcon = actions-document-history-open
iconName = actions-document-history-open
displayCondition = canShowHistory != 0
callbackAction = openHistoryPopUp
}
......@@ -677,7 +677,7 @@ return array(
100 {
name = new
label = LLL:EXT:lang/locallang_core.xlf:cm.new
spriteIcon = actions-page-new
iconName = actions-page-new
displayCondition = canCreateNewPages != 0
callbackAction = newPageWizard
}
......@@ -688,7 +688,7 @@ return array(
300 {
name = cut
label = LLL:EXT:lang/locallang_core.xlf:cm.cut
spriteIcon = actions-edit-cut
iconName = actions-edit-cut
displayCondition = isInCutMode = 0 && canBeCut != 0 && isMountPoint != 1
callbackAction = enableCutMode
}
......@@ -697,7 +697,7 @@ return array(
400 {
name = cut
label = LLL:EXT:lang/locallang_core.xlf:cm.cut
spriteIcon = actions-edit-cut-release
iconName = actions-edit-cut-release
displayCondition = isInCutMode = 1 && canBeCut != 0
callbackAction = disableCutMode
}
......@@ -706,7 +706,7 @@ return array(
500 {
name = copy
label = LLL:EXT:lang/locallang_core.xlf:cm.copy
spriteIcon = actions-edit-copy
iconName = actions-edit-copy
displayCondition = isInCopyMode = 0 && canBeCopied != 0
callbackAction = enableCopyMode
}
......@@ -715,7 +715,7 @@ return array(
600 {
name = copy
label = LLL:EXT:lang/locallang_core.xlf:cm.copy
spriteIcon = actions-edit-copy-release
iconName = actions-edit-copy-release
displayCondition = isInCopyMode = 1 && canBeCopied != 0
callbackAction = disableCopyMode
}
......@@ -724,7 +724,7 @@ return array(
700 {
name = pasteInto
label = LLL:EXT:lang/locallang_core.xlf:cm.pasteinto
spriteIcon = actions-document-paste-into
iconName = actions-document-paste-into
displayCondition = getContextInfo|inCopyMode = 1 || getContextInfo|inCutMode = 1 && canBePastedInto != 0
callbackAction = pasteIntoNode
}
......@@ -733,7 +733,7 @@ return array(
800 {
name = pasteAfter
label = LLL:EXT:lang/locallang_core.xlf:cm.pasteafter
spriteIcon = actions-document-paste-after
iconName = actions-document-paste-after
displayCondition = getContextInfo|inCopyMode = 1 || getContextInfo|inCutMode = 1 && canBePastedAfter != 0
callbackAction = pasteAfterNode
}
......@@ -744,7 +744,7 @@ return array(
1000 {
name = delete
label = LLL:EXT:lang/locallang_core.xlf:cm.delete
spriteIcon = actions-edit-delete
iconName = actions-edit-delete
displayCondition = canBeRemoved != 0 && isMountPoint != 1
callbackAction = removeNode
}
......@@ -758,7 +758,7 @@ return array(
100 {
name = mountAsTreeroot
label = LLL:EXT:lang/locallang_core.xlf:cm.tempMountPoint
spriteIcon = actions-system-extension-documentation
iconName = actions-pagetree-mountroot
displayCondition = canBeTemporaryMountPoint != 0 && isMountPoint = 0
callbackAction = mountAsTreeRoot
}
......@@ -769,7 +769,7 @@ return array(
300 {
name = expandBranch
label = LLL:EXT:lang/locallang_core.xlf:cm.expandBranch
spriteIcon = actions-pagetree-expand
iconName = actions-pagetree-expand
displayCondition =
callbackAction = expandBranch
}
......@@ -778,7 +778,7 @@ return array(
400 {
name = collapseBranch
label = LLL:EXT:lang/locallang_core.xlf:cm.collapseBranch
spriteIcon = actions-pagetree-collapse
iconName = actions-pagetree-collapse
displayCondition =
callbackAction = collapseBranch
}
......
=======================================================================
Breaking: #69561 - Replace sprite icons with IconFactory in ContextMenu
=======================================================================
Description
===========
SpriteIcon and standalone image support have been replaced with IconFactory in
the context menu. All menu icons need now to be registered through the IconRegistry.
Impact
======
The UserTsConfig options for items ``icon`` and ``spriteIcon`` have no effect anymore,
and will deliver a blank placeholder image if ``iconName`` is not set.
Affected Installations
======================
All installations that add or modify items in the ContextMenu.
Migration
=========
Register the icon through the ``IconRegistry`` and set the ``iconName`` in the
item configuration.
.. code-block:: php
// Register Icon
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
$iconRegistry->registerIcon(
'contextmenu-example',
\TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
array(
'source' => 'EXT:example/Resources/Public/Icons/contextmenu-example.svg'
))
);
.. code-block:: typoscript
options.contextMenu.table {
virtual_root.items {
9999 = ITEM
9999 {
name = contextmenuExample
label = LLL:EXT:example/Resources/Private/Language/locallang.xlf:contextmenu-example
iconName = contextmenu-example
callbackAction = exampleCallback
}
}
}
==========================================================================
Deprecation: #69561 - Replace sprite icons with IconFactory in ContextMenu
==========================================================================
Description
===========
The ``\TYPO3\CMS\Backend\ContextMenu\ContextMenuAction::$class`` member variable is not
used anymore inside Core, therefore it has been deprecated and will be removed with CMS 8.
Affected Installations
======================
Any installation using third party code, which accesses ``ContextMenuAction::$class``.
Migration
=========
Remove any reference to ``ContextMenuAction::$class``.
......@@ -21,7 +21,7 @@ if (TYPO3_MODE === 'BE') {
9100 {
name = exportT3d
label = LLL:EXT:impexp/Resources/Private/Language/locallang.xlf:export
spriteIcon = actions-document-export-t3d
iconName = actions-document-export-t3d
callbackAction = exportT3d
}
......@@ -29,7 +29,7 @@ if (TYPO3_MODE === 'BE') {
9200 {
name = importT3d
label = LLL:EXT:impexp/Resources/Private/Language/locallang.xlf:import
spriteIcon = actions-document-import-t3d
iconName = actions-document-import-t3d
callbackAction = importT3d
}
';
......
......@@ -1576,12 +1576,24 @@ td.x-date-mp-sep {
.x-menu {
border-color:#898989;
background-color: #ffffff;
background-image:url(images/menu/menu.gif);
}
ul.x-menu-list {
padding: 0;
margin-bottom: 0;
margin-top: 0;
position: relative;
}
.x-menu-list-item {
margin: 0;
padding: 1px 0;
}
.x-menu-list-item:first-child {
margin-top: 3px;
}
.x-menu-list-item:last-child {
margin-bottom: 3px;
}
.x-menu-nosep {
......@@ -1593,30 +1605,32 @@ ul.x-menu-list {
}
.x-menu-sep {
background-color:#e0e0e0;
border-bottom-color:#fff;
background-color: #e0e0e0;
border: none;
margin: 2px 0;
}
a.x-menu-item {
color:#222;
padding-left: 30px;
}
.x-menu-item-icon {
top: 4px;
a.x-menu-item:focus {
outline: none;
}
.x-menu-item-icon .t3-icon {
width: 20px;
height: 20px;
.ext-strict .x-menu-item-icon,
.x-menu-item-icon {
left: 7px;
top: 3px;
}
.x-menu-item-active {
background-color: #e9e9e9;
border-color:#c8c8c8;
background-color: rgba(0,0,0,0.05);
border: none;
}
.x-menu-item-active a.x-menu-item {
border-color:#c8c8c8;
border: none;
margin: 0;
}
.x-menu-check-item .x-menu-item-icon{
......
Supports Markdown
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