From 35ad45c0d3eccf97a93499c9004e68a35cf87917 Mon Sep 17 00:00:00 2001 From: Michael Oehlhof <typo3@oehlhof.de> Date: Mon, 7 Mar 2016 01:37:15 +0100 Subject: [PATCH] [TASK] Fluidification of Function Module Moved all HTML code from the PHP code to an own Fluid template. Resolves: #74382 Releases: master Change-Id: I840cf5ebb4acc758751da143f5a0360c7024c0ab Reviewed-on: https://review.typo3.org/47144 Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl> Tested-by: Wouter Wolters <typo3@wouterwolters.nl> Reviewed-by: Frank Naegler <frank.naegler@typo3.org> Tested-by: Frank Naegler <frank.naegler@typo3.org> --- .../Controller/PageFunctionsController.php | 48 ++++++++++++++----- .../Resources/Private/Templates/Main.html | 7 +++ 2 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 typo3/sysext/func/Resources/Private/Templates/Main.html diff --git a/typo3/sysext/func/Classes/Controller/PageFunctionsController.php b/typo3/sysext/func/Classes/Controller/PageFunctionsController.php index b2f89c1ee7b7..3ece499e34b8 100644 --- a/typo3/sysext/func/Classes/Controller/PageFunctionsController.php +++ b/typo3/sysext/func/Classes/Controller/PageFunctionsController.php @@ -62,6 +62,11 @@ class PageFunctionsController extends \TYPO3\CMS\Backend\Module\BaseScriptClass */ protected $iconFactory; + /** + * @var StandaloneView + */ + protected $view; + /** * Constructor */ @@ -125,28 +130,27 @@ class PageFunctionsController extends \TYPO3\CMS\Backend\Module\BaseScriptClass 'if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int)$this->id . ';'); // Setting up the context sensitive menu: $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu'); - $this->content .= '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('web_func')) . '" id="PageFunctionsController" method="post"><input type="hidden" name="id" value="' . htmlspecialchars($this->id) . '" />'; - $vContent = $this->moduleTemplate->getVersionSelector($this->id, true); - if ($vContent) { - $this->content .= '<div>' . $vContent . '</div>'; - } - $this->extObjContent(); + + $this->view = $this->getFluidTemplateObject('func', 'func'); + $this->view->assign('moduleName', BackendUtility::getModuleUrl('web_func')); + $this->view->assign('id', $this->id); + $this->view->assign('versionSelector', $this->moduleTemplate->getVersionSelector($this->id, true)); + $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 $title = $this->getLanguageService()->getLL('title'); $message = $this->getLanguageService()->getLL('clickAPage_content'); - $view = GeneralUtility::makeInstance(StandaloneView::class); - $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:func/Resources/Private/Templates/InfoBox.html')); - $view->assignMultiple(array( + $this->view = $this->getFluidTemplateObject('func', 'func', 'InfoBox'); + $this->view->assignMultiple(array( 'title' => $title, 'message' => $message, 'state' => InfoboxViewHelper::STATE_INFO )); - $this->content = $view->render(); + $this->content = $this->view->render(); // Setting up the buttons and markers for docheader $this->getButtons(); } @@ -231,4 +235,26 @@ class PageFunctionsController extends \TYPO3\CMS\Backend\Module\BaseScriptClass { return $GLOBALS['BE_USER']; } + + /** + * returns a new standalone view, shorthand function + * + * @param string $extensionName + * @param string $controllerExtensionname + * @param string $templateName + * @return StandaloneView + */ + protected function getFluidTemplateObject($extensionName, $controllerExtensionName, $templateName = 'Main') + { + /** @var StandaloneView $view */ + $view = GeneralUtility::makeInstance(StandaloneView::class); + $view->setLayoutRootPaths(array(GeneralUtility::getFileAbsFileName('EXT:' . $extensionName . '/Resources/Private/Layouts'))); + $view->setPartialRootPaths(array(GeneralUtility::getFileAbsFileName('EXT:' . $extensionName . '/Resources/Private/Partials'))); + $view->setTemplateRootPaths(array(GeneralUtility::getFileAbsFileName('EXT:' . $extensionName . '/Resources/Private/Templates'))); + + $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:' . $extensionName . '/Resources/Private/Templates/' . $templateName . '.html')); + + $view->getRequest()->setControllerExtensionName($controllerExtensionName); + return $view; + } } diff --git a/typo3/sysext/func/Resources/Private/Templates/Main.html b/typo3/sysext/func/Resources/Private/Templates/Main.html new file mode 100644 index 000000000000..5feda647ac79 --- /dev/null +++ b/typo3/sysext/func/Resources/Private/Templates/Main.html @@ -0,0 +1,7 @@ +<form action="{moduleName}" method="post" id="PageFunctionsController"> + <input type="hidden" name="id" value="{id}" /> + <f:if condition="{versionSelector}"> + <div><f:format.raw>{versionSelector}</f:format.raw></div> + </f:if> + <f:format.raw>{functionMenuModuleContent}</f:format.raw> +</form> -- GitLab