Commit 9173bea0 authored by Benni Mack's avatar Benni Mack Committed by Christian Kuhn
Browse files

[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's avatarDaniel Maier <dani-maier@gmx.de>
Tested-by: Daniel Maier's avatarDaniel Maier <dani-maier@gmx.de>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: default avatarFrederic Gaus <frederic.gaus@flagbit.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 183e49f5
......@@ -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
);
......
......@@ -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,
......
......@@ -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);
......
......@@ -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,
],
];
......
......@@ -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'];
}
}
}
......
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