From 36b89324e665ecc6891b65715712fa3e972fb974 Mon Sep 17 00:00:00 2001
From: Benjamin Mack <benni@typo3.org>
Date: Thu, 26 Mar 2015 19:05:45 +0100
Subject: [PATCH] [TASK] Move backend logo rendering to fluid

The backend logo in the left corner was rendered via it's own
simple class which can easily be replaced by Fluid and the logic
for that.

The old LogoView class is now marked for deprecation.

Resolves: #66065
Releases: master
Change-Id: Ief36fece1fcde3633cf67367153db4f75985e166
Reviewed-on: http://review.typo3.org/38263
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
Tested-by: Andreas Fernandez <andreas.fernandez@aspedia.de>
---
 .../Classes/Controller/BackendController.php  | 20 +++++++++++--
 .../sysext/backend/Classes/View/LogoView.php  |  3 ++
 .../Private/Templates/Backend/Main.html       |  5 +++-
 ...cation-66065-BackendLogoViewDeprecated.rst | 29 +++++++++++++++++++
 4 files changed, 54 insertions(+), 3 deletions(-)
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Deprecation-66065-BackendLogoViewDeprecated.rst

diff --git a/typo3/sysext/backend/Classes/Controller/BackendController.php b/typo3/sysext/backend/Classes/Controller/BackendController.php
index 115f299c4155..f31c84d76ca0 100644
--- a/typo3/sysext/backend/Classes/Controller/BackendController.php
+++ b/typo3/sysext/backend/Classes/Controller/BackendController.php
@@ -203,8 +203,24 @@ class BackendController {
 
 		// Prepare the scaffolding, at this point extension may still add javascript and css
 		$view = $this->getFluidTemplateObject($this->templatePath . 'Backend/Main.html');
-		// @todo: kick logo view class and move all logic to Fluid
-		$view->assign('logo', GeneralUtility::makeInstance(\TYPO3\CMS\Backend\View\LogoView::class)->render());
+
+		// Render the TYPO3 logo in the left corner
+		$logoUrl = $GLOBALS['TBE_STYLES']['logo'] ?: 'gfx/typo3-topbar@2x.png';
+		$logoPath = \TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath(PATH_typo3 . $logoUrl);
+		list($logoWidth, $logoHeight) = @getimagesize($logoPath);
+
+		// High-resolution?
+		if (strpos($logoUrl, '@2x.') !== FALSE) {
+			$logoWidth = $logoWidth/2;
+			$logoHeight = $logoHeight/2;
+		}
+
+		$view->assign('logoUrl', $logoUrl);
+		$view->assign('logoWidth', $logoWidth);
+		$view->assign('logoHeight', $logoHeight);
+		$view->assign('logoLink', TYPO3_URL_GENERAL);
+		$view->assign('applicationVersion', TYPO3_version);
+		$view->assign('siteName', $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']);
 		$view->assign('moduleMenu', $this->generateModuleMenu());
 		$view->assign('toolbar', $this->renderToolbar());
 
diff --git a/typo3/sysext/backend/Classes/View/LogoView.php b/typo3/sysext/backend/Classes/View/LogoView.php
index 1fe26f8100b4..f54608b5c467 100644
--- a/typo3/sysext/backend/Classes/View/LogoView.php
+++ b/typo3/sysext/backend/Classes/View/LogoView.php
@@ -18,6 +18,7 @@ namespace TYPO3\CMS\Backend\View;
  * class to render the TYPO3 logo in the backend
  *
  * @author Ingo Renner <ingo@typo3.org>
+ * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8 - change the logic of the logo directly in the corresponding Fluid template
  */
 class LogoView {
 
@@ -28,8 +29,10 @@ class LogoView {
 
 	/**
 	 * Constructor
+	 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8 - change the logic of the logo directly in the corresponding Fluid template
 	 */
 	public function __construct() {
+		\TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
 		$this->logo = 'gfx/typo3-topbar@2x.png';
 	}
 
diff --git a/typo3/sysext/backend/Resources/Private/Templates/Backend/Main.html b/typo3/sysext/backend/Resources/Private/Templates/Backend/Main.html
index 7c8c03bd7004..c82fc334460f 100644
--- a/typo3/sysext/backend/Resources/Private/Templates/Backend/Main.html
+++ b/typo3/sysext/backend/Resources/Private/Templates/Backend/Main.html
@@ -1,6 +1,9 @@
 <div class="typo3-topbar-container" role="navigation" id="typo3-top-container">
 	<div class="typo3-topbar-site">
-		<f:format.raw>{logo}</f:format.raw>
+		<a class="typo3-topbar-site-logo" href="{logoLink}" target="_blank">
+			<img src="{logoUrl}" width="{logoWidth}" height="{logoHeight}" title="TYPO3 Content Management System" alt="" />
+		</a>
+		<span class="typo3-topbar-site-name">{siteName} [{applicationVersion}]</span>
 	</div>
 	<div class="typo3-topbar-navigation" id="typo3-topbar-navigation">
 		<ul class="typo3-topbar-navigation-items" data-typo3-role="typo3-module-menu">
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-66065-BackendLogoViewDeprecated.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-66065-BackendLogoViewDeprecated.rst
new file mode 100644
index 000000000000..06cb8393fb3d
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-66065-BackendLogoViewDeprecated.rst
@@ -0,0 +1,29 @@
+==================================================
+Deprecation - #66065: Backend Logo View Deprecated
+==================================================
+
+Description
+===========
+
+The logo view class responsible for the rendering of the TYPO3 Logo in the left corner of the backend is not in use
+anymore and marked for deprecation. The logic for exchanging the logo via TBE_STYLES is still available.
+
+
+Impact
+======
+
+Installations extending ``TYPO3\CMS\Backend\View\LogoView`` as an XCLASS will not see
+any modified output instead.
+
+
+Affected Installations
+======================
+
+Installations extending ``TYPO3\CMS\Backend\View\LogoView`` as an XCLASS.
+
+
+Migration
+=========
+
+As the same logic is now done in the BackendController and the main Backend Fluid Template, the template can be
+modified to fit the installations' needs.
-- 
GitLab