[FEATURE] Allow additional paths for extension icons 06/49306/3
authorBenni Mack <benni@typo3.org>
Tue, 2 Aug 2016 11:13:44 +0000 (13:13 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Wed, 3 Aug 2016 14:28:59 +0000 (16:28 +0200)
Until now, the extension icon had to be located under ext_icon.png,
ext_icon.svg, ext_icon.gif within the extension directory.

In order to prepare a way to allow only files under Resources/Public/
to be public, the icon can now also be put under
Resources/Public/Icons/Extension.png or .svg

Several paths where hard-coded extension icon paths are replaced
with the getExtensionIcon() API in the Core.

Resolves: #77349
Releases: master
Change-Id: Ib273f347498d412530ca256a083d896d168f65fa
Reviewed-on: https://review.typo3.org/49306
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/backend/Classes/Controller/NewRecordController.php
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
typo3/sysext/core/Documentation/Changelog/master/Feature-77349-AdditionalLocationsForExtensionIcons.rst [new file with mode: 0644]
typo3/sysext/documentation/Classes/Utility/MiscUtility.php
typo3/sysext/reports/Classes/ViewHelpers/IconViewHelper.php

index dc3e651..52c30e6 100644 (file)
@@ -27,6 +27,7 @@ use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\HttpUtility;
+use TYPO3\CMS\Core\Utility\PathUtility;
 use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
@@ -540,13 +541,14 @@ class NewRecordController extends AbstractModule
                                         $langFile = $temp[0];
                                         $thisTitle = $lang->sL('LLL:EXT:' . $_EXTKEY . '/' . $langFile . ':extension.title');
                                         // If no localisation available, read title from ext_emconf.php
-                                        $extEmConfFile = ExtensionManagementUtility::extPath($_EXTKEY) . 'ext_emconf.php';
+                                        $extPath = ExtensionManagementUtility::extPath($_EXTKEY);
+                                        $extEmConfFile = $extPath . 'ext_emconf.php';
                                         if (!$thisTitle && is_file($extEmConfFile)) {
                                             $EM_CONF = array();
                                             include $extEmConfFile;
                                             $thisTitle = $EM_CONF[$_EXTKEY]['title'];
                                         }
-                                        $iconFile[$_EXTKEY] = '<img ' . 'src="' . ExtensionManagementUtility::extRelPath($_EXTKEY) . $GLOBALS['TYPO3_LOADED_EXT'][$_EXTKEY]['ext_icon'] . '" ' . 'width="16" height="16" ' . 'alt="' . $thisTitle . '" />';
+                                        $iconFile[$_EXTKEY] = '<img src="' . PathUtility::getAbsoluteWebPath(ExtensionManagementUtility::getExtensionIcon($extPath, true)) . '" ' . 'width="16" height="16" ' . 'alt="' . $thisTitle . '" />';
                                     }
                                 }
                                 if (empty($thisTitle)) {
index 52c73be..0e0ef6d 100644 (file)
@@ -1574,10 +1574,17 @@ tt_content.' . $key . $suffix . ' {
     public static function getExtensionIcon($extensionPath, $returnFullPath = false)
     {
         $icon = '';
-        $iconFileTypesToCheckFor = array('png', 'svg', 'gif');
-        foreach ($iconFileTypesToCheckFor as $fileType) {
-            if (file_exists($extensionPath . 'ext_icon.' . $fileType)) {
-                $icon = 'ext_icon.' . $fileType;
+        $locationsToCheckFor = [
+            'Resources/Public/Icons/Extension.png',
+            'Resources/Public/Icons/Extension.svg',
+            'Resources/Public/Icons/Extension.gif',
+            'ext_icon.png',
+            'ext_icon.svg',
+            'ext_icon.gif',
+        ];
+        foreach ($locationsToCheckFor as $fileLocation) {
+            if (file_exists($extensionPath . $fileLocation)) {
+                $icon = $fileLocation;
                 break;
             }
         }
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-77349-AdditionalLocationsForExtensionIcons.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-77349-AdditionalLocationsForExtensionIcons.rst
new file mode 100644 (file)
index 0000000..e40f887
--- /dev/null
@@ -0,0 +1,12 @@
+==========================================================
+Feature: #77349 - Additional locations for extension icons
+==========================================================
+
+Description
+===========
+
+Extensions can now hold their extension icons in additional locations to the existing ones (ext_icon.png, ext_icon.svg, ext_icon.gif):
+
+* Resources/Public/Icons/Extension.png
+* Resources/Public/Icons/Extension.svg
+* Resources/Public/Icons/Extension.gif
\ No newline at end of file
index 2997353..85b9d8a 100644 (file)
@@ -59,7 +59,8 @@ class MiscUtility
         $documentPath = $basePath . $documentKey . '/';
 
         // Fallback icon
-        $icon = ExtensionManagementUtility::siteRelPath('documentation') . 'ext_icon.png';
+        $icon = ExtensionManagementUtility::getExtensionIcon(ExtensionManagementUtility::extPath('documentation'));
+        $icon = ExtensionManagementUtility::siteRelPath('documentation') . $icon;
 
         if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($documentKey, 'typo3cms.extensions.')) {
             // Standard extension icon
index 97f701a..19544a1 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Reports\ViewHelpers;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
 use TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper;
@@ -69,7 +70,14 @@ class IconViewHelper extends AbstractBackendViewHelper
         $icon = $arguments['icon'];
         $title = $arguments['title'];
 
-        $icon = GeneralUtility::getFileAbsFileName($icon ?: 'EXT:reports/ext_icon.png');
+        $icon = GeneralUtility::getFileAbsFileName($icon);
+
+        // use the extension icon from EXT:reports as fallback
+        if (!$icon) {
+            $fallbackIconPath = ExtensionManagementUtility::extPath('reports');
+            $icon = ExtensionManagementUtility::getExtensionIcon($fallbackIconPath, true);
+        }
+
         return '<img src="' . htmlspecialchars(PathUtility::getAbsoluteWebPath($icon))
                . '" width="16" height="16" title="' . htmlspecialchars($title)
                . '" alt="' . htmlspecialchars($title) . '" />';