From 9173bea01c8a53b774342f004e6e221da99a6d02 Mon Sep 17 00:00:00 2001 From: Benni Mack <benni@typo3.org> Date: Fri, 4 Mar 2016 09:34:17 +0100 Subject: [PATCH] [TASK] Remove leftover icon resolving code Icons within the TCA (iconfile and icons in options) are handled by the IconRegistry. The TcaMigration takes care of that. The code within FormEngine can thus be removed as it is never executed. Resolves: #74157 Releases: master Change-Id: Ia79349193f4a5da0e7046bd63e2221a9e7759d79 Reviewed-on: https://review.typo3.org/47031 Reviewed-by: Daniel Maier <dani-maier@gmx.de> Tested-by: Daniel Maier <dani-maier@gmx.de> Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl> Reviewed-by: Frederic Gaus <frederic.gaus@flagbit.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../Form/Element/SelectCheckBoxElement.php | 2 +- .../FormDataProvider/AbstractItemProvider.php | 6 +--- .../Form/Utility/FormEngineUtility.php | 36 ++++++------------- .../FormDataProvider/TcaSelectItemsTest.php | 6 ++-- .../core/Classes/Imaging/IconRegistry.php | 10 +----- 5 files changed, 17 insertions(+), 43 deletions(-) diff --git a/typo3/sysext/backend/Classes/Form/Element/SelectCheckBoxElement.php b/typo3/sysext/backend/Classes/Form/Element/SelectCheckBoxElement.php index 469fbf51d66e..287c1a217c87 100644 --- a/typo3/sysext/backend/Classes/Form/Element/SelectCheckBoxElement.php +++ b/typo3/sysext/backend/Classes/Form/Element/SelectCheckBoxElement.php @@ -102,7 +102,7 @@ class SelectCheckBoxElement extends AbstractFormElement 'checked' => $checked, 'disabled' => false, 'class' => '', - 'icon' => (!empty($p[2]) ? FormEngineUtility::getIconHtml($p[2]) : $this->iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render()), + 'icon' => FormEngineUtility::getIconHtml(!empty($p[2]) ? $p[2] : 'empty-empty'), 'title' => htmlspecialchars($p[0], ENT_COMPAT, 'UTF-8', false), 'help' => $help ); diff --git a/typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php b/typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php index 7d815e98d8de..827fff635971 100644 --- a/typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php +++ b/typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php @@ -316,10 +316,6 @@ abstract class AbstractItemProvider } else { $icon = $loadModules->modules[$theMod]['iconIdentifier']; } - if ($icon) { - $iconFactory = GeneralUtility::makeInstance(IconFactory::class); - $icon = $iconFactory->getIcon($icon)->render(); - } // Add help text $helpText = [ 'title' => $languageService->moduleLabels['labels'][$theMod . '_tablabel'], @@ -386,7 +382,7 @@ abstract class AbstractItemProvider foreach ($fileArray as $fileReference) { $fileInformation = pathinfo($fileReference); $icon = GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], strtolower($fileInformation['extension'])) - ? '../' . PathUtility::stripPathSitePrefix($fileFolder) . $fileReference + ? $fileFolder . $fileReference : ''; $items[] = [ $fileReference, diff --git a/typo3/sysext/backend/Classes/Form/Utility/FormEngineUtility.php b/typo3/sysext/backend/Classes/Form/Utility/FormEngineUtility.php index a707590de8d9..7c5c215f67be 100644 --- a/typo3/sysext/backend/Classes/Form/Utility/FormEngineUtility.php +++ b/typo3/sysext/backend/Classes/Form/Utility/FormEngineUtility.php @@ -123,33 +123,19 @@ class FormEngineUtility public static function getIconHtml($icon, $alt = '', $title = '') { $icon = (string)$icon; - $iconFile = ''; - $iconInfo = false; + $absoluteFilePath = GeneralUtility::getFileAbsFileName($icon); + if (!empty($absoluteFilePath) && is_file($absoluteFilePath)) { + $iconInfo = StringUtility::endsWith($absoluteFilePath, '.svg') + ? true + : getimagesize($absoluteFilePath); - if (StringUtility::beginsWith($icon, 'EXT:')) { - $absoluteFilePath = GeneralUtility::getFileAbsFileName($icon); - if (!empty($absoluteFilePath) && is_file($absoluteFilePath)) { - $iconFile = '../' . PathUtility::stripPathSitePrefix($absoluteFilePath); - $iconInfo = (StringUtility::endsWith($absoluteFilePath, '.svg')) - ? true - : getimagesize($absoluteFilePath); + if ($iconInfo !== false) { + return '<img' + . ' src="' . htmlspecialchars(PathUtility::getAbsoluteWebPath($absoluteFilePath)) . '"' + . ' alt="' . htmlspecialchars($alt) . '" ' + . ($title ? 'title="' . htmlspecialchars($title) . '"' : '') + . ' />'; } - } elseif (StringUtility::beginsWith($icon, '../')) { - // @TODO: this is special modList, files from folders and selicon - $iconFile = GeneralUtility::resolveBackPath($icon); - if (is_file(PATH_site . GeneralUtility::resolveBackPath(substr($icon, 3)))) { - $iconInfo = (StringUtility::endsWith($icon, '.svg')) - ? true - : getimagesize((PATH_site . GeneralUtility::resolveBackPath(substr($icon, 3)))); - } - } - - if ($iconInfo !== false && is_file(GeneralUtility::resolveBackPath(PATH_typo3 . $iconFile))) { - return '<img' - . ' src="' . htmlspecialchars($iconFile) . '"' - . ' alt="' . htmlspecialchars($alt) . '" ' - . ($title ? 'title="' . htmlspecialchars($title) . '"' : '') - . ' />'; } $iconFactory = GeneralUtility::makeInstance(IconFactory::class); diff --git a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php index 39b6879354bd..9cd78008ee9b 100644 --- a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php +++ b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php @@ -1085,7 +1085,7 @@ class TcaSelectItemsTest extends UnitTestCase 0 => [ 0 => 'aModuleLabel', 1 => 'aModule', - 2 => '<span class="t3js-icon icon icon-size-default icon-state-default icon-empty-empty" data-identifier="empty-empty"><span class="icon-markup"><span class="icon-unify"><i class="fa fa-empty-empty"></i></span></span></span>', + 2 => 'empty-empty', 3 => [ 'title' => 'aModuleTabLabel', 'description' => 'aModuleTabDescription', @@ -1139,13 +1139,13 @@ class TcaSelectItemsTest extends UnitTestCase 0 => [ 0 => 'anImage.gif', 1 => 'anImage.gif', - 2 => '../' . $directory . 'anImage.gif', + 2 => PATH_site . $directory . 'anImage.gif', 3 => null, ], 1 => [ 0 => 'subdir/anotherImage.gif', 1 => 'subdir/anotherImage.gif', - 2 => '../' . $directory . 'subdir/anotherImage.gif', + 2 => PATH_site . $directory . 'subdir/anotherImage.gif', 3 => null, ], ]; diff --git a/typo3/sysext/core/Classes/Imaging/IconRegistry.php b/typo3/sysext/core/Classes/Imaging/IconRegistry.php index 544514683c34..c5802fe95357 100644 --- a/typo3/sysext/core/Classes/Imaging/IconRegistry.php +++ b/typo3/sysext/core/Classes/Imaging/IconRegistry.php @@ -2850,20 +2850,12 @@ class IconRegistry implements SingletonInterface // This method is only needed for TCA tables where typeicon_classes are not configured if (is_array($GLOBALS['TCA'][$tableName])) { $tcaCtrl = $GLOBALS['TCA'][$tableName]['ctrl']; - $icon = null; $iconIdentifier = 'tcarecords-' . $tableName . '-default'; if (isset($this->icons[$iconIdentifier])) { continue; } if (isset($tcaCtrl['iconfile'])) { - if (StringUtility::beginsWith($tcaCtrl['iconfile'], 'EXT:')) { - $icon = $tcaCtrl['iconfile']; - } elseif (strpos($tcaCtrl['iconfile'], '/') !== false) { - $icon = TYPO3_mainDir . GeneralUtility::resolveBackPath($tcaCtrl['iconfile']); - } - if ($icon !== null) { - $resultArray[$iconIdentifier] = $icon; - } + $resultArray[$iconIdentifier] = $tcaCtrl['iconfile']; } } } -- GitLab