[FEATURE] High-res TYPO3 logo in topbar
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / View / LogoView.php
1 <?php
2 namespace TYPO3\CMS\Backend\View;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2007-2013 Ingo Renner <ingo@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * class to render the TYPO3 logo in the backend
31 *
32 * @author Ingo Renner <ingo@typo3.org>
33 */
34 class LogoView {
35 protected $logo = '';
36
37 public function __construct() {
38 $this->logo = 'gfx/typo3-topbar@2x.png';
39 }
40
41 /**
42 * renders the actual logo code
43 *
44 * @return string Logo html code snippet to use in the backend
45 */
46 public function render() {
47 $imgInfo = getimagesize(PATH_site . TYPO3_mainDir . $this->logo);
48 $imgUrl = $this->logo;
49
50 // Overwrite with custom logo
51 if ($GLOBALS['TBE_STYLES']['logo']) {
52 $imgInfo = @getimagesize(\TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath((PATH_typo3 . $GLOBALS['TBE_STYLES']['logo']), 3));
53 $imgUrl = $GLOBALS['TBE_STYLES']['logo'];
54 }
55
56 // High-res?
57 $width = $imgInfo[0];
58 $height = $imgInfo[1];
59
60 if (strpos($imgUrl, '@2x.')) {
61 $width = $width/2;
62 $height = $height/2;
63 }
64
65 $logoTag = '<img src="' . $imgUrl . '" width="' . $width . '" height="' . $height . '" title="TYPO3 Content Management System" alt="" />';
66 return '<a href="' . TYPO3_URL_GENERAL . '" target="_blank">' . $logoTag . '</a>';
67 }
68
69 /**
70 * Sets the logo
71 *
72 * @param string $logo Path to logo file as seen from typo3/
73 * @throws \InvalidArgumentException
74 */
75 public function setLogo($logo) {
76 if (!is_string($logo)) {
77 throw new \InvalidArgumentException('parameter $logo must be of type string', 1194041104);
78 }
79 $this->logo = $logo;
80 }
81
82 }