Subject: [PATCH] [FEATURE] Allow ext_icon.png besides ext_icon.gif

Allow ext_icon.png as extension icon besides ext_icon.gif.

Change-Id: I15661e68bb71cf81ebe9058eb497ca5b8c3e3459
Fixes: #37595
Releases: 6.0
---
 t3lib/class.t3lib_extmgm.php                       |   33 ++++++++++++++++++-
 typo3/db_new.php                                   |    3 +-
 .../extensions/class.tx_em_extensions_list.php     |    5 ++-
 typo3/sysext/em/classes/index.php                  |    5 ++-
 4 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/t3lib/class.t3lib_extmgm.php b/t3lib/class.t3lib_extmgm.php
index 379a67e..889f541 100644
--- a/t3lib/class.t3lib_extmgm.php
+++ b/t3lib/class.t3lib_extmgm.php
@@ -1314,7 +1314,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');
@@ -1584,7 +1585,7 @@ tt_content.' . $key . $prefix . ' {
 			'ext_tables.sql',
 			'ext_tables_static+adt.sql',
 			'ext_typoscript_constants.txt',
-			'ext_typoscript_setup.txt'
+			'ext_typoscript_setup.txt',
 		);
 
 			// Clear file status cache to make sure we get good results from is_dir()
@@ -1624,12 +1625,40 @@ 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 $full$ReturnFullPath Return full path of file.
+	 * @return string
+	 * @throws BadFunctionCallException
+	 */
+	public static function getExtensionIcon($extensionPath, $ReturnFullPath = FALSE){
+		$icon = '';
+		$iconFileTypesToCheckFor = array(
+			'gif',
+			'png',
+			'jpg',
+		);
+
+		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
diff --git a/typo3/db_new.php b/typo3/db_new.php
index 9e10f40..4db9f3e 100644
--- a/typo3/db_new.php
+++ b/typo3/db_new.php
@@ -514,7 +514,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] = '';
diff --git a/typo3/sysext/em/classes/extensions/class.tx_em_extensions_list.php b/typo3/sysext/em/classes/extensions/class.tx_em_extensions_list.php
index e3bde3e87..ef2ed5c 100644
--- a/typo3/sysext/em/classes/extensions/class.tx_em_extensions_list.php
+++ b/typo3/sysext/em/classes/extensions/class.tx_em_extensions_list.php
@@ -245,7 +245,10 @@ class tx_em_Extensions_List {
 					$list[$key]['doc'] = '<a href="' . htmlspecialchars($manualRelPath) . '" target="_blank">'
 						. t3lib_iconWorks::getSpriteIcon('actions-system-extension-documentation') . '</a>';
 				}
-				$list[$key]['icon'] = @is_file($path . $extKey . '/ext_icon.gif') ? '<img src="' . $relPath . $extKey . '/ext_icon.gif" alt="" height="16" />' : '<img src="clear.gif" alt="" width="16" height="16" />';
+				$list[$key]['icon'] = @is_file(t3lib_extMgm::getExtensionIcon($path . $extKey . '/', TRUE)) ?
+					'<img src="' . $relPath . $extKey  . '/' .
+						t3lib_extMgm::getExtensionIcon($path . $extKey . '/') . '" alt="" height="16" />' :
+					'<img src="clear.gif" alt="" width="16" height="16" />';
 
 				$list[$key]['categoryShort'] = $list[$key]['category'];
 				$list[$key]['category'] = isset($this->categories[$list[$key]['category']]) ? $this->categories[$list[$key]['category']] : $list[$key]['category'];
diff --git a/typo3/sysext/em/classes/index.php b/typo3/sysext/em/classes/index.php
index 126ada0..683e148 100644
--- a/typo3/sysext/em/classes/index.php
+++ b/typo3/sysext/em/classes/index.php
@@ -2361,10 +2361,11 @@ class SC_mod_tools_em_index extends t3lib_SCbase {
 	 * @return	string		HTML; Extension title and image.
 	 */
 	function extensionTitleIconHeader($extKey, $extInfo, $align = 'top') {
-		$imgInfo = @getImageSize(tx_em_Tools::getExtPath($extKey, $extInfo['type']) . '/ext_icon.gif');
+		$imgInfo = @getImageSize(tx_em_Tools::getExtPath($extKey, $extInfo['type']) . $extInfo['ext_icon']);
 		$out = '';
 		if (is_array($imgInfo)) {
-			$out .= '<img src="' . $GLOBALS['BACK_PATH'] . tx_em_Tools::typeRelPath($extInfo['type']) . $extKey . '/ext_icon.gif" ' . $imgInfo[3] . ' align="' . $align . '" alt="" />';
+			$out .= '<img src="' . $GLOBALS['BACK_PATH'] . tx_em_Tools::typeRelPath($extInfo['type']) . $extKey . '/' .
+				$extInfo['ext_icon'] .'" ' . $imgInfo[3] . ' align="' . $align . '" alt="" height="16" />';
 		}
 		$out .= $extInfo['EM_CONF']['title'] ? htmlspecialchars(t3lib_div::fixed_lgd_cs($extInfo['EM_CONF']['title'], 40)) : '<em>' . htmlspecialchars($extKey) . '</em>';
 		return $out;
-- 
1.7.7.5 (Apple Git-26)+GitX