From 6fc46ad7405f4c758fd84d7fb998b7d376044195 Mon Sep 17 00:00:00 2001 From: Michael Oehlhof <typo3@oehlhof.de> Date: Sun, 6 Mar 2016 01:42:04 +0100 Subject: [PATCH] [TASK] Fluidification of Info Module Moved all HTML code from the PHP code to an own Fluid template. Resolves: #74360 Releases: master Change-Id: Ib583695d8b95140347c4107d6183fbbde9f309eb Reviewed-on: https://review.typo3.org/47129 Reviewed-by: Jan Helke <typo3@helke.de> Tested-by: Jan Helke <typo3@helke.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../Classes/Module/BaseScriptClass.php | 15 +++++++ .../Controller/InfoModuleController.php | 39 +++++++++++++++---- .../Resources/Private/Templates/Main.html | 6 +++ 3 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 typo3/sysext/info/Resources/Private/Templates/Main.html diff --git a/typo3/sysext/backend/Classes/Module/BaseScriptClass.php b/typo3/sysext/backend/Classes/Module/BaseScriptClass.php index 7ae86314df71..2bb139f28423 100644 --- a/typo3/sysext/backend/Classes/Module/BaseScriptClass.php +++ b/typo3/sysext/backend/Classes/Module/BaseScriptClass.php @@ -358,6 +358,21 @@ class BaseScriptClass } } + /** + * Return the content of the 'main' function inside the "Function menu module" if present + * + * @return string + */ + public function getExtObjContent() + { + $savedContent = $this->content; + $this->content = ''; + $this->extObjContent(); + $newContent = $this->content; + $this->content = $savedContent; + return $newContent; + } + /** * Returns the Language Service * @return LanguageService diff --git a/typo3/sysext/info/Classes/Controller/InfoModuleController.php b/typo3/sysext/info/Classes/Controller/InfoModuleController.php index a23eb222b52f..5da6fb5b5f45 100644 --- a/typo3/sysext/info/Classes/Controller/InfoModuleController.php +++ b/typo3/sysext/info/Classes/Controller/InfoModuleController.php @@ -22,6 +22,7 @@ use TYPO3\CMS\Backend\Template\ModuleTemplate; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Fluid\View\StandaloneView; /** * Script Class for the Web > Info module @@ -58,6 +59,11 @@ class InfoModuleController extends BaseScriptClass */ protected $moduleTemplate; + /** + * @var StandaloneView + */ + protected $view; + /** * Constructor */ @@ -107,17 +113,15 @@ class InfoModuleController extends BaseScriptClass ); // Setting up the context sensitive menu: $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu'); - $this->content .= '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl($this->moduleName)) . - '" method="post" id="InfoModuleController" name="webinfoForm" class="form-inline form-inline-spaced">'; - $vContent = $this->moduleTemplate->getVersionSelector($this->id, 1); - if ($vContent) { - $this->content .= '<div>' . $vContent . '</div>'; - } - $this->extObjContent(); + + $this->view = $this->getFluidTemplateObject(); + $this->view->assign('moduleName', htmlspecialchars(BackendUtility::getModuleUrl($this->moduleName))); + $this->view->assign('versionSelector', $this->moduleTemplate->getVersionSelector($this->id, 1)); + $this->view->assign('functionMenuModuleContent', $this->getExtObjContent()); // Setting up the buttons and markers for docheader $this->getButtons(); $this->generateMenu(); - $this->content .= '</form>'; + $this->content .= $this->view->render(); } else { // If no access or if ID == zero $this->content = $this->moduleTemplate->header($this->languageService->getLL('title')); @@ -229,4 +233,23 @@ class InfoModuleController extends BaseScriptClass { return $this->moduleTemplate; } + + /** + * returns a new standalone view, shorthand function + * + * @return StandaloneView + */ + protected function getFluidTemplateObject() + { + /** @var StandaloneView $view */ + $view = GeneralUtility::makeInstance(StandaloneView::class); + $view->setLayoutRootPaths(array(GeneralUtility::getFileAbsFileName('EXT:info/Resources/Private/Layouts'))); + $view->setPartialRootPaths(array(GeneralUtility::getFileAbsFileName('EXT:info/Resources/Private/Partials'))); + $view->setTemplateRootPaths(array(GeneralUtility::getFileAbsFileName('EXT:info/Resources/Private/Templates'))); + + $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:info/Resources/Private/Templates/Main.html')); + + $view->getRequest()->setControllerExtensionName('info'); + return $view; + } } diff --git a/typo3/sysext/info/Resources/Private/Templates/Main.html b/typo3/sysext/info/Resources/Private/Templates/Main.html new file mode 100644 index 000000000000..589df2d2c14e --- /dev/null +++ b/typo3/sysext/info/Resources/Private/Templates/Main.html @@ -0,0 +1,6 @@ +<form action="{moduleName}" method="post" id="InfoModuleController" name="webinfoForm" class="form-inline form-inline-spaced"> + <f:if condition="{versionSelector}"> + <div>{versionSelector}</div> + </f:if> + <f:format.raw>{functionMenuModuleContent}</f:format.raw> +</form> -- GitLab