[TASK] Cleanup usage of InfoboxViewHelper 05/39205/4
authorFrank Nägler <typo3@naegler.net>
Sat, 2 May 2015 16:51:04 +0000 (18:51 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 2 May 2015 17:35:52 +0000 (19:35 +0200)
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>
typo3/sysext/backend/Classes/Controller/PageLayoutController.php
typo3/sysext/backend/Resources/Private/Templates/InfoBox.html [new file with mode: 0644]
typo3/sysext/func/Classes/Controller/PageFunctionsController.php
typo3/sysext/func/Resources/Private/Templates/InfoBox.html [new file with mode: 0644]
typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateModuleController.php
typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateObjectBrowserModuleFunctionController.php
typo3/sysext/tstemplate/Resources/Private/Templates/InfoBox.html [new file with mode: 0644]

index dbfecc8..3133a82 100644 (file)
@@ -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 (file)
index 0000000..a526fbb
--- /dev/null
@@ -0,0 +1,3 @@
+<f:be.infobox title="{title}" state="{state}">
+       <f:format.html>{message}</f:format.html>
+</f:be.infobox>
index 6b47e63..6f44dea 100644 (file)
@@ -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 (file)
index 0000000..a526fbb
--- /dev/null
@@ -0,0 +1,3 @@
+<f:be.infobox title="{title}" state="{state}">
+       <f:format.html>{message}</f:format.html>
+</f:be.infobox>
index 79a66bb..7b510bc 100644 (file)
@@ -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) {
index ca27253..82f57bb 100644 (file)
@@ -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 (file)
index 0000000..a526fbb
--- /dev/null
@@ -0,0 +1,3 @@
+<f:be.infobox title="{title}" state="{state}">
+       <f:format.html>{message}</f:format.html>
+</f:be.infobox>