[FEATURE] High-res TYPO3 logo in topbar 40/24340/2
authorFelix Kopp <felix-source@phorax.com>
Thu, 3 Oct 2013 18:01:51 +0000 (20:01 +0200)
committerPhilipp Gampe <philipp.gampe@typo3.org>
Fri, 4 Oct 2013 15:14:16 +0000 (17:14 +0200)
Allow hi-res logo in TYPO3 backend topbar.
Automatically scales when @2x in filename is detected.

Change-Id: I17044b909e11c3efa1ab2e13bda1b9cf1ac9624e
Resolves: #52514
Releases: 6.2
Reviewed-on: https://review.typo3.org/24340
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
typo3/gfx/typo3-topbar@2x.png [new file with mode: 0644]
typo3/sysext/backend/Classes/Controller/BackendController.php
typo3/sysext/backend/Classes/View/LogoView.php

diff --git a/typo3/gfx/typo3-topbar@2x.png b/typo3/gfx/typo3-topbar@2x.png
new file mode 100644 (file)
index 0000000..62c806a
Binary files /dev/null and b/typo3/gfx/typo3-topbar@2x.png differ
index 9fb48ed..d305372 100644 (file)
@@ -166,9 +166,10 @@ class BackendController {
         */
        public function render() {
                $this->executeHook('renderPreProcess');
+
                // Prepare the scaffolding, at this point extension may still add javascript and css
                $logo = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\View\\LogoView');
-               $logo->setLogo('gfx/typo3logo_mini.png');
+
                // Create backend scaffolding
                $backendScaffolding = '
                <div id="typo3-top-container" class="x-hide-display">
index 58dffbf..43e90dd 100644 (file)
@@ -32,14 +32,10 @@ namespace TYPO3\CMS\Backend\View;
  * @author Ingo Renner <ingo@typo3.org>
  */
 class LogoView {
+       protected $logo = '';
 
-       protected $logo;
-
-       /**
-        * constructor
-        */
        public function __construct() {
-               $this->logo = NULL;
+               $this->logo = 'gfx/typo3-topbar@2x.png';
        }
 
        /**
@@ -48,20 +44,26 @@ class LogoView {
         * @return string Logo html code snippet to use in the backend
         */
        public function render() {
-               // Default
-               $logoFile = 'gfx/alt_backend_logo.gif';
-               if (is_string($this->logo)) {
-                       // Overwrite
-                       $logoFile = $this->logo;
-               }
-               $imgInfo = getimagesize(PATH_site . TYPO3_mainDir . $logoFile);
-               $logo = '<a href="' . TYPO3_URL_GENERAL . '" target="_blank">' . '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg('', $logoFile, $imgInfo[3]) . ' title="TYPO3 Content Management System" alt="" />' . '</a>';
+               $imgInfo = getimagesize(PATH_site . TYPO3_mainDir . $this->logo);
+               $imgUrl = $this->logo;
+
                // Overwrite with custom logo
                if ($GLOBALS['TBE_STYLES']['logo']) {
                        $imgInfo = @getimagesize(\TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath((PATH_typo3 . $GLOBALS['TBE_STYLES']['logo']), 3));
-                       $logo = '<a href="' . TYPO3_URL_GENERAL . '" target="_blank">' . '<img src="' . $GLOBALS['TBE_STYLES']['logo'] . '" ' . $imgInfo[3] . ' title="TYPO3 Content Management System" alt="" />' . '</a>';
+                       $imgUrl = $GLOBALS['TBE_STYLES']['logo'];
                }
-               return $logo;
+
+               // High-res?
+               $width = $imgInfo[0];
+               $height = $imgInfo[1];
+
+               if (strpos($imgUrl, '@2x.')) {
+                       $width = $width/2;
+                       $height = $height/2;
+               }
+
+               $logoTag = '<img src="' . $imgUrl . '" width="' . $width . '" height="' . $height . '" title="TYPO3 Content Management System" alt="" />';
+               return '<a href="' . TYPO3_URL_GENERAL . '" target="_blank">' . $logoTag . '</a>';
        }
 
        /**