[BUGFIX] Properly size icons in translation overview 62/36962/4
authorMichael Oehlhof <typo3@oehlhof.de>
Tue, 17 Feb 2015 00:49:19 +0000 (01:49 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Thu, 19 Feb 2015 02:38:16 +0000 (03:38 +0100)
Limit size of extension icons and use styling of app icons.

Resolves: #65114
Releases: master
Change-Id: I95584bb5d9a328560fa97069b94c9aad73602047
Reviewed-on: http://review.typo3.org/36962
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Tested-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/extensionmanager/Classes/Utility/ListUtility.php
typo3/sysext/lang/Classes/Domain/Model/Extension.php
typo3/sysext/lang/Classes/Domain/Repository/ExtensionRepository.php
typo3/sysext/lang/Resources/Public/JavaScript/LanguageModule.js

index 9a1a2ba..6557149 100644 (file)
@@ -146,6 +146,27 @@ class ListUtility implements \TYPO3\CMS\Core\SingletonInterface {
                return $extensions;
        }
 
+       /**
+        * Adds information about icon size to the extension information
+        *
+        * @param array $extensions
+        * @return array
+        */
+       public function enrichExtensionsWithIconInformation(array $extensions) {
+               foreach ($extensions as &$properties) {
+                       $iInfo = @getimagesize(PATH_site . $properties['siteRelPath'] . $properties['ext_icon']);
+                       if ($iInfo !== FALSE) {
+                               $properties['ext_icon_width'] = $iInfo[0];
+                               $properties['ext_icon_height'] = $iInfo[1];
+                       } else {
+                               $properties['ext_icon_width'] = 0;
+                               $properties['ext_icon_height'] = 0;
+                       }
+               }
+               unset($properties);
+               return $extensions;
+       }
+
        /**
         * Gets all available and installed extension with additional information
         * from em_conf and TER (if available)
@@ -155,6 +176,7 @@ class ListUtility implements \TYPO3\CMS\Core\SingletonInterface {
        public function getAvailableAndInstalledExtensionsWithAdditionalInformation() {
                $availableExtensions = $this->getAvailableExtensions();
                $availableAndInstalledExtensions = $this->getAvailableAndInstalledExtensions($availableExtensions);
+               $availableAndInstalledExtensions = $this->enrichExtensionsWithIconInformation($availableAndInstalledExtensions);
                return $this->enrichExtensionsWithEmConfAndTerInformation($availableAndInstalledExtensions);
        }
 
index 3800bd5..dec7e11 100644 (file)
@@ -37,6 +37,16 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
         */
        protected $icon = '';
 
+       /**
+        * @var int
+        */
+       protected $iconWidth = 0;
+
+       /**
+        * @var int
+        */
+       protected $iconHeight = 0;
+
        /**
         * @var int
         */
@@ -79,6 +89,34 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
                return $this->icon;
        }
 
+       /**
+        * @return int
+        */
+       public function getIconWidth() {
+               return $this->iconWidth;
+       }
+
+       /**
+        * @param int $iconWidth
+        */
+       public function setIconWidth($iconWidth) {
+               $this->iconWidth = $iconWidth;
+       }
+
+       /**
+        * @return int
+        */
+       public function getIconHeight() {
+               return $this->iconHeight;
+       }
+
+       /**
+        * @param int $iconHeight
+        */
+       public function setIconHeight($iconHeight) {
+               $this->iconHeight = $iconHeight;
+       }
+
        /**
         * Setter for the key
         *
@@ -177,6 +215,8 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
                        'title'   => $this->getTitle(),
                        'icon'    => $this->getIcon(),
                        'version' => $this->getVersion(),
+                       'width'   => $this->getIconWidth(),
+                       'height'  => $this->getIconHeight()
                );
        }
 
index a0ac0fb..8159b97 100644 (file)
@@ -57,6 +57,9 @@ class ExtensionRepository {
                                        $this->getExtensionIconWithPath($entry)
                                );
                                $extension->setVersionFromString($entry['version']);
+                               $extension->setIconWidth($entry['ext_icon_width']);
+                               $extension->setIconHeight($entry['ext_icon_height']);
+
                                $this->extensions[$entry['key']] = $extension;
                        }
                        ksort($this->extensions);
index ba038a2..c389d55 100644 (file)
@@ -262,7 +262,7 @@ define('TYPO3/CMS/Lang/LanguageModule', ['jquery', 'datatables', 'jquery/jquery.
                        columns = [
                                {
                                        render: function(data, type, row) {
-                                               return LanguageModule.buildImage(data.icon, data.title);
+                                               return LanguageModule.buildImage(data.icon, data.title, data.title, data.width, data.height);
                                        },
                                        width: '20px',
                                        orderable: false,
@@ -519,12 +519,17 @@ define('TYPO3/CMS/Lang/LanguageModule', ['jquery', 'datatables', 'jquery/jquery.
        /**
         * Build image
         */
-       LanguageModule.buildImage = function(uri, alt, tilte) {
+       LanguageModule.buildImage = function(uri, alt, title, width, heigth) {
                var $image = $('<img>');
                $image.attr('src', uri);
                $image.attr('alt', alt ? alt : '');
-               $image.attr('tilte', tilte ? tilte : '');
-               return $image.wrap('<span>').parent().html();
+               $image.attr('title', title ? title : '');
+               $image.attr('style', 'width: ' + width + 'px; height: ' + heigth + 'px;');
+               var $span = $('<span>');
+               $span.addClass('typo3-app-icon');
+               $span.attr('style', 'background: none; text-align: center;');
+               $span.html($image);
+               return $span.wrap('<span>').parent().html();
        };
 
        /**