[TASK] Move Preview Info hook to hook_eofe 72/57872/2
authorBenni Mack <benni@typo3.org>
Sat, 11 Aug 2018 14:52:33 +0000 (16:52 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 11 Aug 2018 17:42:53 +0000 (19:42 +0200)
The Frontend Request uses two hooks separately to
allow modifying the content via TSFE. In order
to deprecate one (previewInfo), the Frontend Hook
to show the "Preview" info box, is moved to the
hook_eofe hook.

Resolves: #85816
Releases: master
Change-Id: I66fe66a43364c670bdaf7837793180122e329e7b
Reviewed-on: https://review.typo3.org/57872
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/frontend/Classes/Hooks/FrontendHooks.php
typo3/sysext/frontend/ext_localconf.php

index 612bdfd..9275948 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+declare(strict_types = 1);
+
 namespace TYPO3\CMS\Frontend\Hooks;
 
 /*
@@ -27,16 +29,15 @@ class FrontendHooks
      * in the LIVE workspace
      *
      * @param array $params
-     * @param TypoScriptFrontendController $pObj
-     * @return string
+     * @param TypoScriptFrontendController $controller
      */
-    public function hook_previewInfo($params, $pObj)
+    public function displayPreviewInfoMessage($params, TypoScriptFrontendController $controller)
     {
-        if (!$pObj->fePreview || $pObj->doWorkspacePreview()) {
-            return '';
+        if (!$controller->fePreview || $controller->doWorkspacePreview()) {
+            return;
         }
-        if ($pObj->config['config']['message_preview']) {
-            $message = $pObj->config['config']['message_preview'];
+        if ($controller->config['config']['message_preview']) {
+            $message = $controller->config['config']['message_preview'];
         } else {
             $label = $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_tsfe.xlf:preview');
             $styles = [];
@@ -57,7 +58,9 @@ class FrontendHooks
             $styles[] = 'border-radius: 2px';
             $message = '<div id="typo3-preview-info" style="' . implode(';', $styles) . '">' . htmlspecialchars($label) . '</div>';
         }
-        return $message;
+        if (!empty($message)) {
+            $controller->content = str_ireplace('</body>', $message . '</body>', $controller->content);
+        }
     }
 
     /**
index 0d4f657..6b0d92b 100644 (file)
@@ -79,7 +79,7 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['proc
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['moveRecordClass'][] = \TYPO3\CMS\Frontend\Hooks\TreelistCacheUpdateHooks::class;
 
 // Register hook to show preview info
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_previewInfo']['cms'] = \TYPO3\CMS\Frontend\Hooks\FrontendHooks::class . '->hook_previewInfo';
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_eofe']['preview-message'] = \TYPO3\CMS\Frontend\Hooks\FrontendHooks::class . '->displayPreviewInfoMessage';
 
 // Register for hooks to show preview of tt_content elements in page module
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']['image'] =