Commit 2007789b authored by Tomas Norre Mikkelsen's avatar Tomas Norre Mikkelsen

Merge branch '250-ext_icon-svg-should-be-preferred' into 'develop'

Adds order of showing extension icons in frontend

Closes #250

See merge request !229
parents a229716d 3d6c5a16
Pipeline #2369 passed with stages
in 2 minutes and 22 seconds
...@@ -165,26 +165,25 @@ class TerIndexer extends \ApacheSolrForTypo3\Solr\IndexQueue\Indexer ...@@ -165,26 +165,25 @@ class TerIndexer extends \ApacheSolrForTypo3\Solr\IndexQueue\Indexer
*/ */
protected function getExtensionIcon($extensionKey, $extensionVersion) protected function getExtensionIcon($extensionKey, $extensionVersion)
{ {
$fileTypesToCheck = [
// check if there is a gif or a png icon or if there is no icon 'svg',
$iconFilePng = $this->generateIconFileName( 'png',
$extensionKey,
$extensionVersion,
'png'
);
$iconFileGif = $this->generateIconFileName(
$extensionKey,
$extensionVersion,
'gif' 'gif'
); ];
$iconPath = 'fileadmin/ter/'; $iconPath = 'fileadmin/ter/';
$icon = ''; $icon = '';
if (file_exists(PATH_site.$iconPath.$iconFilePng)) { foreach ($fileTypesToCheck as $fileType) {
$icon = \T3o\TerFe2\Utility\File::getRelativeUrlFromAbsolutePath($iconPath.$iconFilePng); $iconFile = $this->generateIconFileName(
} elseif (file_exists(PATH_site.$iconPath.$iconFileGif)) { $extensionKey,
$icon = \T3o\TerFe2\Utility\File::getRelativeUrlFromAbsolutePath($iconPath.$iconFileGif); $extensionVersion,
$fileType
);
if (file_exists(PATH_site . $iconPath . $iconFile)) {
$icon = \T3o\TerFe2\Utility\File::getRelativeUrlFromAbsolutePath($iconPath . $iconFile);
break;
}
} }
return $icon; return $icon;
......
...@@ -42,6 +42,15 @@ class ExtensionIconViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractT ...@@ -42,6 +42,15 @@ class ExtensionIconViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractT
*/ */
protected $providerManager; protected $providerManager;
/**
* @var array
*/
protected $fileIconOrder = [
'svg',
'png',
'gif'
];
/** /**
* Initialize arguments * Initialize arguments
* *
...@@ -59,10 +68,9 @@ class ExtensionIconViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractT ...@@ -59,10 +68,9 @@ class ExtensionIconViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractT
* Renders an extension icon for given version object * Renders an extension icon for given version object
* *
* @param \T3o\TerFe2\Domain\Model\Version $version Version object * @param \T3o\TerFe2\Domain\Model\Version $version Version object
* @param string $fileType File type
* @return string Rendered image tag * @return string Rendered image tag
*/ */
public function render(\T3o\TerFe2\Domain\Model\Version $version = null, $fileType = 'png') public function render(\T3o\TerFe2\Domain\Model\Version $version = null)
{ {
if ($version === null) { if ($version === null) {
$version = $this->renderChildren(); $version = $this->renderChildren();
...@@ -71,9 +79,11 @@ class ExtensionIconViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractT ...@@ -71,9 +79,11 @@ class ExtensionIconViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractT
$imageUrl = ''; $imageUrl = '';
$provider = $version->getExtensionProvider(); $provider = $version->getExtensionProvider();
if (!empty($provider)) { if (!empty($provider)) {
$imageUrl = $this->providerManager->getProvider($provider)->getIconUrl($version, $fileType); foreach ($this->fileIconOrder as $fileType) {
if (empty($imageUrl) || !file_exists(\T3o\TerFe2\Utility\File::getAbsolutePathFromUrl($imageUrl))) { $imageUrl = $this->providerManager->getProvider($provider)->getIconUrl($version, $fileType);
$imageUrl = $this->providerManager->getProvider($provider)->getIconUrl($version, 'gif'); if (!empty($imageUrl) && file_exists(\T3o\TerFe2\Utility\File::getAbsolutePathFromUrl($imageUrl))) {
break;
}
} }
} }
......
Markdown is supported
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