[FEATURE] Allow ext_icon.png as extension icon besides ext_icon.gif
authorJohannes Feustel <s@feustel.eu>
Sat, 18 Aug 2012 11:34:49 +0000 (13:34 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 18 Aug 2012 15:11:31 +0000 (17:11 +0200)
Search for ext_icon.png and ext_icon.gif and store to
$GLOBALS['TYPO3_LOADED_EXT'][$_EXTKEY]['ext_icon']

Change-Id: I4867ba9c46b3c9d1674d91313599b2aada5e9295
Resolves: #37595
Releases: 6.0
Reviewed-on: http://review.typo3.org/13888
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
t3lib/class.t3lib_extmgm.php
typo3/db_new.php
typo3/sysext/extensionmanager/Classes/Utility/List.php
typo3/sysext/extensionmanager/Resources/Private/Templates/List/Index.html

index 7b1049a..45065ce 100644 (file)
@@ -1315,7 +1315,8 @@ class t3lib_extMgm {
        public static function addPlugin($itemArray, $type = 'list_type') {
                $_EXTKEY = $GLOBALS['_EXTKEY'];
                if ($_EXTKEY && !$itemArray[2]) {
-                       $itemArray[2] = self::extRelPath($_EXTKEY) . 'ext_icon.gif';
+                       $itemArray[2] = self::extRelPath($_EXTKEY) .
+                               $GLOBALS['TYPO3_LOADED_EXT'][$_EXTKEY]['ext_icon'];
                }
 
                t3lib_div::loadTCA('tt_content');
@@ -1624,12 +1625,39 @@ tt_content.' . $key . $prefix . ' {
                                        }
                                }
                        }
+                               // Register found extension icon
+                       $loadedExtensionInformation[$extensionKey]['ext_icon'] = self::getExtensionIcon(PATH_site . $loadedExtensionInformation[$extensionKey]['siteRelPath']);
                }
 
                return $loadedExtensionInformation;
        }
 
        /**
+        * Find extension icon
+        *
+        * @param string $extensionPath Path to extension directory.
+        * @param string $returnFullPath Return full path of file.
+        * @return string
+        * @throws BadFunctionCallException
+        */
+       public static function getExtensionIcon($extensionPath, $returnFullPath = FALSE){
+               $icon = '';
+               $iconFileTypesToCheckFor = array(
+                       'png',
+                       'gif',
+               );
+
+               foreach ($iconFileTypesToCheckFor as $fileType){
+                       if (@is_file($extensionPath . 'ext_icon.' . $fileType)) {
+                               $icon = 'ext_icon.' . $fileType;
+                               break;
+                       }
+               }
+
+               return $returnFullPath ? $extensionPath . $icon : $icon;
+       }
+
+       /**
         * Cache identifier of cached Typo3LoadedExtensionInformation array
         *
         * @return string
index 1ef6574..4414d84 100644 (file)
@@ -503,7 +503,8 @@ class SC_db_new {
                                                                                        include(t3lib_extMgm::extPath($_EXTKEY) . 'ext_emconf.php');
                                                                                        $thisTitle = $EM_CONF[$_EXTKEY]['title'];
                                                                                }
-                                                                               $iconFile[$_EXTKEY] = '<img src="' . t3lib_extMgm::extRelPath($_EXTKEY) . 'ext_icon.gif" />';
+                                                                               $iconFile[$_EXTKEY] = '<img alt="" src="' . t3lib_extMgm::extRelPath($_EXTKEY) .
+                                                                                       $GLOBALS['TYPO3_LOADED_EXT'][$_EXTKEY]['ext_icon'] . '" height="16" />';
                                                                        } else {
                                                                                $thisTitle = $nameParts[1];
                                                                                $iconFile[$_EXTKEY] = '';
index c587fa0..67e52ee 100644 (file)
@@ -107,7 +107,8 @@ class Tx_Extensionmanager_Utility_List implements t3lib_Singleton {
                                                        $extensions[$extKey] = array(
                                                                'siteRelPath' => str_replace(PATH_site, '', $path . $extKey),
                                                                'type' => $installationType,
-                                                               'key' => $extKey
+                                                               'key' => $extKey,
+                                                               'ext_icon' => t3lib_extMgm::getExtensionIcon( $path . $extKey . '/'),
                                                        );
                                                }
                                        }
@@ -120,7 +121,7 @@ class Tx_Extensionmanager_Utility_List implements t3lib_Singleton {
        }
 
        /**
-        * Reduce the available extensions list to only installed extensions
+        * Reduce the available extensions list to only loaded extensions
         *
         * @param array $availableExtensions
         * @return array
index 3ac558d..d0435eb 100644 (file)
@@ -57,7 +57,7 @@
                                        </f:else>
                                </f:if>
 
-                                       <em:image src="../{extension.siteRelPath}/ext_icon.gif" alt="{extension.title}" />{extension.title}
+                                       <em:image src="../{extension.siteRelPath}/{extension.ext_icon}" alt="{extension.title}" height="16" />{extension.title}
                                </td>
                                <td>
                                        {extensionKey}