[TASK] Remove leftover icon resolving code 31/47031/6
authorBenni Mack <benni@typo3.org>
Fri, 4 Mar 2016 08:34:17 +0000 (09:34 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 4 Mar 2016 18:54:08 +0000 (19:54 +0100)
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>
typo3/sysext/backend/Classes/Form/Element/SelectCheckBoxElement.php
typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php
typo3/sysext/backend/Classes/Form/Utility/FormEngineUtility.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php
typo3/sysext/core/Classes/Imaging/IconRegistry.php

index 469fbf5..287c1a2 100644 (file)
@@ -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
                         );
index 7d815e9..827fff6 100644 (file)
@@ -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,
index a707590..7c5c215 100644 (file)
@@ -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);
index 39b6879..9cd7800 100644 (file)
@@ -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,
             ],
         ];
index 5445146..c5802fe 100644 (file)
@@ -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'];
                 }
             }
         }