Commit 354af3bb authored by Benjamin Kott's avatar Benjamin Kott Committed by Benjamin Kott
Browse files

[TASK] Add icon deprecation and unified refresh icon

Add a possibility to log calls to deprecated icon identifiers, replace
"actions-system-refresh" with "actions-refresh" and deprecate it.

Resolves: #69705
Releases: master
Change-Id: I9e103be37f41ede35fa6de90d285209bd2cbfa00
Reviewed-on: http://review.typo3.org/43220


Reviewed-by: Nicole Cordes's avatarNicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes's avatarNicole Cordes <typo3@cordes.co>
Reviewed-by: Stephan Großberndt's avatarStephan Großberndt <stephan@grossberndt.de>
Tested-by: Stephan Großberndt's avatarStephan Großberndt <stephan@grossberndt.de>
Reviewed-by: default avatarMorton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: default avatarMorton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Benjamin Kott's avatarBenjamin Kott <info@bk2k.info>
Tested-by: Benjamin Kott's avatarBenjamin Kott <info@bk2k.info>
parent f1d429e9
......@@ -144,6 +144,7 @@ module.exports = function(grunt) {
'<%= paths.backend %>Public/Icons/Action/actions-page-new.svg': '<%= paths.icons %>Action/actions-page-new.svg',
'<%= paths.backend %>Public/Icons/Action/actions-page-move.svg': '<%= paths.icons %>Action/actions-page-move.svg',
'<%= paths.backend %>Public/Icons/Action/actions-page-open.svg': '<%= paths.icons %>Action/actions-page-open.svg',
'<%= paths.backend %>Public/Icons/Action/actions-refresh.svg': '<%= paths.icons %>Action/actions-refresh.svg',
'<%= paths.backend %>Public/Icons/Action/actions-search.svg': '<%= paths.icons %>Action/actions-search.svg',
'<%= paths.backend %>Public/Icons/Action/actions-system-cache-clear-impact-high.svg': '<%= paths.icons %>Action/actions-system-cache-clear-impact-high.svg',
'<%= paths.backend %>Public/Icons/Action/actions-system-cache-clear-impact-low.svg': '<%= paths.icons %>Action/actions-system-cache-clear-impact-low.svg',
......
<?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" 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">
<g id="actions-refresh">
<path d="M14,8c0-3.31-2.69-6-6-6C6.88,2,5.84,2.31,4.94,2.84l0.61,0.97C6.27,3.39,7.1,3.13,8,3.13c2.68,0,4.87,2.18,4.87,4.87H11
l2.5,4L16,8H14z"/>
<path d="M8,12.87c-2.68,0-4.87-2.18-4.87-4.87H5L2.5,4L0,8h2c0,3.31,2.69,6,6,6c1.09,0,2.1-0.29,2.98-0.8l-0.61-0.97
C9.67,12.63,8.87,12.87,8,12.87z"/>
</g>
</svg>
......@@ -226,7 +226,7 @@ class FileSystemNavigationFrameController implements ControllerInterface {
);
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
// Refresh
$buttons['refresh'] = '<a href="' . htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI')) . '">' . $iconFactory->getIcon('actions-system-refresh', Icon::SIZE_SMALL) . '</a>';
$buttons['refresh'] = '<a href="' . htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI')) . '">' . $iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL) . '</a>';
// CSH
$buttons['csh'] = str_replace('typo3-csh-inline', 'typo3-csh-inline show-right', BackendUtility::cshItem('xMOD_csh_corebe', 'filetree'));
return $buttons;
......
......@@ -236,7 +236,7 @@ class PageTreeNavigationController {
. $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL)
. '</a>';
// Refresh
$buttons['refresh'] = '<a href="' . htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI')) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.refresh', TRUE) . '">' . $iconFactory->getIcon('actions-system-refresh', Icon::SIZE_SMALL)->render() . '</a>';
$buttons['refresh'] = '<a href="' . htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI')) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.refresh', TRUE) . '">' . $iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)->render() . '</a>';
// CSH
$buttons['csh'] = str_replace('typo3-csh-inline', 'typo3-csh-inline show-right', BackendUtility::cshItem('xMOD_csh_corebe', 'pagetree'));
return $buttons;
......
......@@ -229,7 +229,7 @@ class TableController extends AbstractWizardController implements \TYPO3\CMS\Cor
. '</button>';
// Reload
$buttons['reload'] = '<button class="c-inputButton" name="_refresh" value="1" title="' . $this->getLanguageService()->getLL('forms_refresh', TRUE) . '">'
. $this->iconFactory->getIcon('actions-system-refresh', Icon::SIZE_SMALL)
. $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)
. '</button>';
}
return $buttons;
......
......@@ -195,7 +195,6 @@ class ExtdirectTreeDataProvider extends \TYPO3\CMS\Backend\Tree\AbstractExtJsTre
'temporaryMountPoint' => Commands::getMountPointPath()
),
'Sprites' => array(
'Refresh' => IconUtility::getSpriteIconClasses('actions-system-refresh'),
'InputClear' => IconUtility::getSpriteIconClasses('actions-input-clear'),
'TrashCan' => IconUtility::getSpriteIconClasses('actions-edit-delete'),
'TrashCanRestore' => IconUtility::getSpriteIconClasses('actions-edit-restore'),
......@@ -204,6 +203,7 @@ class ExtdirectTreeDataProvider extends \TYPO3\CMS\Backend\Tree\AbstractExtJsTre
'Icons' => array(
'NewNode' => (string)$this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL),
'Filter' => (string)$this->iconFactory->getIcon('actions-filter', Icon::SIZE_SMALL),
'Refresh' => (string)$this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)
)
);
return $configuration;
......
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M14 8c0-3.31-2.69-6-6-6-1.12 0-2.16.31-3.06.84l.61.97c.72-.42 1.55-.68 2.45-.68 2.68 0 4.87 2.18 4.87 4.87H11l2.5 4L16 8h-2zM8 12.87c-2.68 0-4.87-2.18-4.87-4.87H5L2.5 4 0 8h2c0 3.31 2.69 6 6 6 1.09 0 2.1-.29 2.98-.8l-.61-.97c-.7.4-1.5.64-2.37.64z"/></svg>
\ No newline at end of file
......@@ -450,7 +450,7 @@ TYPO3.Components.PageTree.TopPanel = Ext.extend(Ext.Panel, {
var topPanelButton = new Ext.Button({
id: this.id + '-button-refresh',
cls: this.id + '-button',
iconCls: TYPO3.Components.PageTree.Sprites.Refresh,
text: TYPO3.Components.PageTree.Icons.Refresh,
tooltip: TYPO3.Components.PageTree.LLL.buttonRefresh,
listeners: {
......
......@@ -274,7 +274,7 @@ class FormsController extends \TYPO3\CMS\Backend\Controller\Wizard\AbstractWizar
// Save & Close
$buttons['save_close'] = '<button class="c-inputButton" name="saveandclosedok" value="1" title=' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc', TRUE) . '>' . $this->iconFactory->getIcon('actions-document-save-close', Icon::SIZE_SMALL) . '</button>';
// Reload
$buttons['reload'] = '<button class="c-inputButton" name="_refresh" value="1" title="' . $this->getLanguageService()->getLL('forms_refresh', TRUE) . '">' . $this->iconFactory->getIcon('actions-system-refresh', Icon::SIZE_SMALL) . '</button>';
$buttons['reload'] = '<button class="c-inputButton" name="_refresh" value="1" title="' . $this->getLanguageService()->getLL('forms_refresh', TRUE) . '">' . $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL) . '</button>';
}
return $buttons;
}
......
......@@ -44,6 +44,13 @@ class IconFactory {
* @return Icon
*/
public function getIcon($identifier, $size = Icon::SIZE_DEFAULT, $overlayIdentifier = NULL, IconState $state = NULL) {
if ($this->iconRegistry->isDeprecated($identifier)) {
$deprecationSettings = $this->iconRegistry->getDeprecationSettings($identifier);
GeneralUtility::deprecationLog(sprintf($deprecationSettings['message'], $identifier));
if (!empty($deprecationSettings['replacement'])) {
$identifier = $deprecationSettings['replacement'];
}
}
if (!$this->iconRegistry->isRegistered($identifier)) {
$identifier = $this->iconRegistry->getDefaultIconIdentifier();
}
......
......@@ -18,6 +18,7 @@ use TYPO3\CMS\Core\Exception;
use TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider;
use TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider;
use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Class IconRegistry, which makes it possible to register custom icons
......@@ -472,6 +473,12 @@ class IconRegistry implements \TYPO3\CMS\Core\SingletonInterface {
'name' => 'anchor',
)
),
'actions-refresh' => array(
'provider' => SvgIconProvider::class,
'options' => array(
'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-refresh.svg',
)
),
'actions-selection-delete' => array(
'provider' => FontawesomeIconProvider::class,
'options' => array(
......@@ -586,12 +593,6 @@ class IconRegistry implements \TYPO3\CMS\Core\SingletonInterface {
'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-system-tree-search-open.svg',
)
),
'actions-system-refresh' => array(
'provider' => FontawesomeIconProvider::class,
'options' => array(
'name' => 'refresh',
)
),
'actions-version-swap-version' => array(
'provider' => FontawesomeIconProvider::class,
'options' => array(
......@@ -868,6 +869,28 @@ class IconRegistry implements \TYPO3\CMS\Core\SingletonInterface {
)
);
/**
* Array of deprecated icons, add deprecated icons to this array and remove it from registry
* - Index of this array contains the deprecated icon
* - Value of each entry must contain the deprecation message and can contain an identifier which replaces the old identifier
*
* Example:
* array(
* 'deprecated-icon-identifier' => array(
* 'message' => '%s is deprecated since TYPO3 CMS 7, this icon will be removed in TYPO3 CMS 8',
* 'replacement' => 'alternative-icon-identifier' // must be registered
* )
* )
*
* @var array
*/
protected $deprecatedIcons = array(
'actions-system-refresh' => array(
'replacement' => 'actions-refresh',
'message' => '%s is deprecated since TYPO3 CMS 7, this icon will be removed in TYPO3 CMS 8'
)
);
/**
* @var string
*/
......@@ -879,7 +902,16 @@ class IconRegistry implements \TYPO3\CMS\Core\SingletonInterface {
* @return bool
*/
public function isRegistered($identifier) {
return !empty($this->icons[$identifier]);
return isset($this->icons[$identifier]);
}
/**
* @param string $identifier
*
* @return bool
*/
public function isDeprecated($identifier) {
return isset($this->deprecatedIcons[$identifier]);
}
/**
......@@ -919,9 +951,29 @@ class IconRegistry implements \TYPO3\CMS\Core\SingletonInterface {
if (!$this->isRegistered($identifier)) {
throw new Exception('Icon with identifier "' . $identifier . '" is not registered"', 1437425804);
}
if ($this->isDeprecated($identifier)) {
$deprecationSettings = $this->getDeprecationSettings($identifier);
GeneralUtility::deprecationLog(sprintf($deprecationSettings['message'], $identifier));
if (!empty($deprecationSettings['replacement'])) {
$identifier = $deprecationSettings['replacement'];
}
}
return $this->icons[$identifier];
}
/**
* @param string $identifier
*
* @return array
* @throws Exception
*/
public function getDeprecationSettings($identifier) {
if (!$this->isDeprecated($identifier)) {
throw new Exception('Icon with identifier "' . $identifier . '" is not deprecated"', 1437425804);
}
return $this->deprecatedIcons[$identifier];
}
/**
* @return array
* @internal
......@@ -929,4 +981,5 @@ class IconRegistry implements \TYPO3\CMS\Core\SingletonInterface {
public function getAllRegisteredIconIdentifiers() {
return array_keys($this->icons);
}
}
==============================================
Deprecation: #69705 - Add unified refresh icon
==============================================
Description
===========
Icon ``actions-system-refresh`` has been deprecated in ``TYPO3\CMS\Core\Imaging\IconRegistry`` and will be removed with TYPO3 CMS 8.
All requests for ``actions-system-refresh`` will now show ``actions-refresh``.
Impact
======
Using IconUtility or IconFactory to fetch the icon ``actions-system-refresh`` logs a message to the deprecation log.
Affected Installations
======================
Installations with third party extensions that use the icon ``actions-system-refresh``.
Migration
=========
Use the icon ``actions-refresh`` instead.
......@@ -59,6 +59,7 @@ class IconFactoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
$this->subject = new IconFactory($this->iconRegistryMock->reveal());
$this->iconRegistryMock->isRegistered(Argument::any())->willReturn(TRUE);
$this->iconRegistryMock->isDeprecated(Argument::any())->willReturn(FALSE);
$this->iconRegistryMock->getIconConfigurationByIdentifier(Argument::any())->willReturn([
'provider' => FontawesomeIconProvider::class,
'options' => array(
......@@ -184,4 +185,43 @@ class IconFactoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
$this->subject->getIcon($this->registeredIconIdentifier, 'foo')->render();
}
/**
* @test
* @param $deprecationSettings
* @param $expected
* @dataProvider getIconReturnsReplacementIconWhenDeprecatedDataProvider
*/
public function getIconReturnsReplacementIconWhenDeprecated($deprecationSettings, $expected) {
$this->iconRegistryMock->isDeprecated($this->registeredIconIdentifier)->willReturn(TRUE);
$this->iconRegistryMock->getDeprecationSettings($this->registeredIconIdentifier)->willReturn($deprecationSettings);
$this->assertContains(
$expected,
$this->subject->getIcon($this->registeredIconIdentifier, Icon::SIZE_SMALL)->render()
);
}
/**
* Data provider for getIconReturnsReplacementIconWhenDeprecated
*
* @return array
*/
public function getIconReturnsReplacementIconWhenDeprecatedDataProvider() {
return array(
'Deprecated icon returns replacement' => [
[
'message' => '%s is deprecated since TYPO3 CMS 7, this icon will be removed in TYPO3 CMS 8',
'replacement' => 'alternative-icon-identifier' // must be registered
],
'<span class="icon icon-size-small icon-state-default icon-alternative-icon-identifier">'
],
'Deprecated icon returns default icon' => [
[
'message' => '%s is deprecated since TYPO3 CMS 7, this icon will be removed in TYPO3 CMS 8'
],
'<span class="icon icon-size-small icon-state-default icon-actions-document-close">'
],
);
}
}
......@@ -284,7 +284,7 @@ class FileList extends AbstractRecordList {
}
}
$buttons['refresh'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.reload', TRUE) . '">' . $this->iconFactory->getIcon('actions-system-refresh', Icon::SIZE_SMALL) . '</a>';
$buttons['refresh'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.reload', TRUE) . '">' . $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL) . '</a>';
return array($buttons, $otherMarkers);
}
......
......@@ -103,7 +103,7 @@
</f:if>
<li>
<a href="{f:widget.uri(arguments:{currentPage: pagination.current})}" title="{f:translate(key:'widget.pagination.refresh')}">
<core:icon identifier="actions-system-refresh" />
<core:icon identifier="actions-refresh" />
</a>
</li>
</ul>
......
......@@ -311,7 +311,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
// Reload
$buttons['reload'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="'
. $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.reload', TRUE) . '">'
. $this->iconFactory->getIcon('actions-system-refresh', Icon::SIZE_SMALL) . '</a>';
. $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL) . '</a>';
// Shortcut
if ($backendUser->mayMakeShortcut()) {
$buttons['shortcut'] = $this->getDocumentTemplate()->makeShortcutIcon(
......@@ -1138,7 +1138,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
. '&pointer=\'+calculatePointer(document.getElementById(\'jumpPage-' . $renderPart
. '\').value); document.dblistForm.submit(); return true;" title="'
. $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:reload', TRUE) . '">'
. $this->iconFactory->getIcon('actions-system-refresh', Icon::SIZE_SMALL) . '</a></li>';
. $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL) . '</a></li>';
if ($renderPart === 'top') {
// Add js to traverse a page select input to a pointer value
$content = '
......
......@@ -2,7 +2,7 @@
<f:layout name="Default" />
<f:section name="iconButtons">
<a data-action="reload" title="{f:translate(key:'button.reload')}"><core:icon identifier="actions-system-refresh" /></a>
<a data-action="reload" title="{f:translate(key:'button.reload')}"><core:icon identifier="actions-refresh" /></a>
</f:section>
<f:section name="content">
......
......@@ -1522,7 +1522,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
'shortcut' => $this->getShortcutButton()
);
if (empty($this->CMD) || $this->CMD === 'list' || $this->CMD === 'delete' || $this->CMD === 'stop' || $this->CMD === 'toggleHidden') {
$buttons['reload'] = '<a href="' . htmlspecialchars($this->moduleUri) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.reload', TRUE) . '">' . $this->iconFactory->getIcon('actions-system-refresh', Icon::SIZE_SMALL) . '</a>';
$buttons['reload'] = '<a href="' . htmlspecialchars($this->moduleUri) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.reload', TRUE) . '">' . $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL) . '</a>';
if ($this->MOD_SETTINGS['function'] === 'scheduler' && !empty($this->getRegisteredClasses())) {
$link = $this->moduleUri . '&CMD=add';
$image = $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL);
......
......@@ -31,7 +31,7 @@
</div>
<div class="right">
<a href="javascript:document.getElementById('tx_viewpage_iframe').contentWindow.location.reload(true);" title="{f:translate(key: 'refreshPage')}">
<core:icon identifier="actions-system-refresh" />
<core:icon identifier="actions-refresh" />
</a>
<f:be.buttons.shortcut/>
</div>
......
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