TYPO3  7.6
LogoView.php
Go to the documentation of this file.
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 
21 class LogoView
22 {
26  protected $logo = '';
27 
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 
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 
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 }