cc6ca8e9843258903b2cf6d906820c2c64532809
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / View / LogoView.php
1 <?php
2 namespace TYPO3\CMS\Backend\View;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * class to render the TYPO3 logo in the backend
19 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8 - change the logic of the logo directly in the corresponding Fluid template
20 */
21 class LogoView
22 {
23 /**
24 * @var string
25 */
26 protected $logo = '';
27
28 /**
29 * Constructor
30 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8 - change the logic of the logo directly in the corresponding Fluid template
31 */
32 public function __construct()
33 {
34 \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
35 $this->logo = 'sysext/backend/Resources/Public/Images/typo3-topbar@2x.png';
36 }
37
38 /**
39 * renders the actual logo code
40 *
41 * @return string Logo html code snippet to use in the backend
42 */
43 public function render()
44 {
45 $imgInfo = getimagesize(PATH_site . TYPO3_mainDir . $this->logo);
46 $imgUrl = $this->logo;
47
48 // Overwrite with custom logo
49 if ($GLOBALS['TBE_STYLES']['logo']) {
50 $imgInfo = @getimagesize(\TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath((PATH_typo3 . $GLOBALS['TBE_STYLES']['logo']), 3));
51 $imgUrl = $GLOBALS['TBE_STYLES']['logo'];
52 }
53
54 // High-res?
55 $width = $imgInfo[0];
56 $height = $imgInfo[1];
57
58 if (strpos($imgUrl, '@2x.')) {
59 $width = $width/2;
60 $height = $height/2;
61 }
62
63 $logoTag = '<img src="' . $imgUrl . '" width="' . $width . '" height="' . $height . '" title="TYPO3 Content Management System" alt="" />';
64 return '<a class="typo3-topbar-site-logo" href="' . htmlspecialchars(TYPO3_URL_GENERAL) . '" target="_blank">' . $logoTag . '</a> <span class="typo3-topbar-site-name">' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . ' [' . TYPO3_version . ']</span>';
65 }
66
67 /**
68 * Sets the logo
69 *
70 * @param string $logo Path to logo file as seen from typo3/
71 * @throws \InvalidArgumentException
72 */
73 public function setLogo($logo)
74 {
75 if (!is_string($logo)) {
76 throw new \InvalidArgumentException('parameter $logo must be of type string', 1194041104);
77 }
78 $this->logo = $logo;
79 }
80 }