From 92a8f623c99d57337bc23564c8844742c2088353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20N=C3=A4gler?= <typo3@naegler.net> Date: Sat, 2 May 2015 18:51:04 +0200 Subject: [PATCH] [TASK] Cleanup usage of InfoboxViewHelper In several places in the core, the InfoboxViewHelper was used in controller context. This patch changes this and makes use of a StandaloneView. Resolves: #66753 Related: #66723 Releases: master Change-Id: I16044a4c663aad4eb0cffce0b11bbf63047118f5 Reviewed-on: http://review.typo3.org/39205 Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../Controller/PageLayoutController.php | 33 +++++++++---------- .../Resources/Private/Templates/InfoBox.html | 3 ++ .../Controller/PageFunctionsController.php | 16 ++++----- .../Resources/Private/Templates/InfoBox.html | 3 ++ .../TypoScriptTemplateModuleController.php | 17 +++++----- ...eObjectBrowserModuleFunctionController.php | 16 ++++----- .../Resources/Private/Templates/InfoBox.html | 3 ++ 7 files changed, 46 insertions(+), 45 deletions(-) create mode 100644 typo3/sysext/backend/Resources/Private/Templates/InfoBox.html create mode 100644 typo3/sysext/func/Resources/Private/Templates/InfoBox.html create mode 100644 typo3/sysext/tstemplate/Resources/Private/Templates/InfoBox.html diff --git a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php index dbfecc8d67f9..3133a82fbfbd 100644 --- a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php +++ b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php @@ -22,6 +22,7 @@ use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; +use TYPO3\CMS\Fluid\View\StandaloneView; use TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper; /** @@ -399,17 +400,15 @@ class PageLayoutController { $title = $GLOBALS['LANG']->getLL('goToListModule'); $message = '<p>' . $GLOBALS['LANG']->getLL('goToListModuleMessage') . '</p>'; $message .= '<a class="btn btn-info" href="javascript:top.goToModule(\'web_list\',1);">' . $GLOBALS['LANG']->getLL('goToListModule') . '</a>'; - // @todo Usage of InfoboxViewHelper this way is pretty ugly, but the best way at the moment - // A complete refactoring is necessary at this point - $arguments = array( + + $view = GeneralUtility::makeInstance(StandaloneView::class); + $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates/InfoBox.html')); + $view->assignMultiple(array( 'title' => $title, 'message' => $message, - 'state' => InfoboxViewHelper::STATE_INFO, - 'iconName' => NULL, - 'disableIcon' => FALSE, - ); - $renderingContext = new \TYPO3\CMS\Fluid\Core\Rendering\RenderingContext(); - $content .= InfoboxViewHelper::renderStatic($arguments, function() {}, $renderingContext); + 'state' => InfoboxViewHelper::STATE_INFO + )); + $content .= $view->render(); } } // If content from different pid is displayed @@ -624,17 +623,15 @@ class PageLayoutController { $title = $GLOBALS['LANG']->getLL('clickAPage_header'); $message = $GLOBALS['LANG']->getLL('clickAPage_content'); - // @todo Usage of InfoboxViewHelper this way is pretty ugly, but the best way at the moment - // A complete refactoring is necessary at this point - $arguments = array( + + $view = GeneralUtility::makeInstance(StandaloneView::class); + $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates/InfoBox.html')); + $view->assignMultiple(array( 'title' => $title, 'message' => $message, - 'state' => InfoboxViewHelper::STATE_INFO, - 'iconName' => NULL, - 'disableIcon' => FALSE, - ); - $renderingContext = new \TYPO3\CMS\Fluid\Core\Rendering\RenderingContext(); - $body .= InfoboxViewHelper::renderStatic($arguments, function() {}, $renderingContext); + 'state' => InfoboxViewHelper::STATE_INFO + )); + $body .= $view->render(); // Setting up the buttons and markers for docheader $docHeaderButtons = array( diff --git a/typo3/sysext/backend/Resources/Private/Templates/InfoBox.html b/typo3/sysext/backend/Resources/Private/Templates/InfoBox.html new file mode 100644 index 000000000000..a526fbbd5e57 --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/Templates/InfoBox.html @@ -0,0 +1,3 @@ +<f:be.infobox title="{title}" state="{state}"> + <f:format.html>{message}</f:format.html> +</f:be.infobox> diff --git a/typo3/sysext/func/Classes/Controller/PageFunctionsController.php b/typo3/sysext/func/Classes/Controller/PageFunctionsController.php index 6b47e63b6ab3..6f44dea2470e 100644 --- a/typo3/sysext/func/Classes/Controller/PageFunctionsController.php +++ b/typo3/sysext/func/Classes/Controller/PageFunctionsController.php @@ -17,6 +17,7 @@ namespace TYPO3\CMS\Func\Controller; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; +use TYPO3\CMS\Fluid\View\StandaloneView; use TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper; /** @@ -102,17 +103,14 @@ class PageFunctionsController extends \TYPO3\CMS\Backend\Module\BaseScriptClass // If no access or if ID == zero $title = $this->getLanguageService()->getLL('title'); $message = $this->getLanguageService()->getLL('clickAPage_content'); - // @todo Usage of InfoboxViewHelper this way is pretty ugly, but the best way at the moment - // A complete refactoring is necessary at this point - $arguments = array( + $view = GeneralUtility::makeInstance(StandaloneView::class); + $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:func/Resources/Private/Templates/InfoBox.html')); + $view->assignMultiple(array( 'title' => $title, 'message' => $message, - 'state' => InfoboxViewHelper::STATE_INFO, - 'iconName' => NULL, - 'disableIcon' => FALSE, - ); - $renderingContext = new \TYPO3\CMS\Fluid\Core\Rendering\RenderingContext(); - $this->content = InfoboxViewHelper::renderStatic($arguments, function() {}, $renderingContext); + 'state' => InfoboxViewHelper::STATE_INFO + )); + $this->content = $view->render(); // Setting up the buttons and markers for docheader $docHeaderButtons = $this->getButtons(); diff --git a/typo3/sysext/func/Resources/Private/Templates/InfoBox.html b/typo3/sysext/func/Resources/Private/Templates/InfoBox.html new file mode 100644 index 000000000000..a526fbbd5e57 --- /dev/null +++ b/typo3/sysext/func/Resources/Private/Templates/InfoBox.html @@ -0,0 +1,3 @@ +<f:be.infobox title="{title}" state="{state}"> + <f:format.html>{message}</f:format.html> +</f:be.infobox> diff --git a/typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateModuleController.php b/typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateModuleController.php index 79a66bb34c27..7b510bcf5478 100644 --- a/typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateModuleController.php +++ b/typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateModuleController.php @@ -24,6 +24,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\Utility\IconUtility; use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; +use TYPO3\CMS\Fluid\View\StandaloneView; use TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper; /** @@ -358,17 +359,15 @@ class TypoScriptTemplateModuleController extends BaseScriptClass { $title = $lang->getLL('noTemplate'); $message = '<p>' . $lang->getLL('noTemplateDescription') . '<br />' . $lang->getLL('createTemplateToEditConfiguration') . '</p>'; - // @todo Usage of InfoboxViewHelper this way is pretty ugly, but the best way at the moment - // A complete refactoring is necessary at this point - $arguments = array( + + $view = GeneralUtility::makeInstance(StandaloneView::class); + $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:tstemplate/Resources/Private/Templates/InfoBox.html')); + $view->assignMultiple(array( 'title' => $title, 'message' => $message, - 'state' => InfoboxViewHelper::STATE_INFO, - 'iconName' => NULL, - 'disableIcon' => FALSE, - ); - $renderingContext = new \TYPO3\CMS\Fluid\Core\Rendering\RenderingContext(); - $theOutput = InfoboxViewHelper::renderStatic($arguments, function() {}, $renderingContext); + 'state' => InfoboxViewHelper::STATE_INFO + )); + $theOutput = $view->render(); // New standard? if ($newStandardTemplate) { diff --git a/typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateObjectBrowserModuleFunctionController.php b/typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateObjectBrowserModuleFunctionController.php index ca27253c189c..82f57bb5af4d 100644 --- a/typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateObjectBrowserModuleFunctionController.php +++ b/typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateObjectBrowserModuleFunctionController.php @@ -24,6 +24,7 @@ use TYPO3\CMS\Core\TypoScript\ExtendedTemplateService; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; +use TYPO3\CMS\Fluid\View\StandaloneView; use TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper; use TYPO3\CMS\Frontend\Page\PageRepository; @@ -438,17 +439,14 @@ class TypoScriptTemplateObjectBrowserModuleFunctionController extends AbstractFu $title = $lang->getLL('errorsWarnings'); $message = '<p>' . implode($errMsg, '<br />') . '</p>'; - // @todo Usage of InfoboxViewHelper this way is pretty ugly, but the best way at the moment - // A complete refactoring is necessary at this point - $arguments = array( + $view = GeneralUtility::makeInstance(StandaloneView::class); + $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:tstemplate/Resources/Private/Templates/InfoBox.html')); + $view->assignMultiple(array( 'title' => $title, 'message' => $message, - 'state' => InfoboxViewHelper::STATE_WARNING, - 'iconName' => NULL, - 'disableIcon' => FALSE, - ); - $renderingContext = new \TYPO3\CMS\Fluid\Core\Rendering\RenderingContext(); - $theOutput .= InfoboxViewHelper::renderStatic($arguments, function() {}, $renderingContext); + 'state' => InfoboxViewHelper::STATE_WARNING + )); + $theOutput .= $view->render(); } if (isset($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][$theKey])) { diff --git a/typo3/sysext/tstemplate/Resources/Private/Templates/InfoBox.html b/typo3/sysext/tstemplate/Resources/Private/Templates/InfoBox.html new file mode 100644 index 000000000000..a526fbbd5e57 --- /dev/null +++ b/typo3/sysext/tstemplate/Resources/Private/Templates/InfoBox.html @@ -0,0 +1,3 @@ +<f:be.infobox title="{title}" state="{state}"> + <f:format.html>{message}</f:format.html> +</f:be.infobox> -- GitLab