[TASK] Fluidification of Function Module 44/47144/4
authorMichael Oehlhof <typo3@oehlhof.de>
Mon, 7 Mar 2016 00:37:15 +0000 (01:37 +0100)
committerFrank Naegler <frank.naegler@typo3.org>
Fri, 10 Jun 2016 08:49:39 +0000 (10:49 +0200)
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>
typo3/sysext/func/Classes/Controller/PageFunctionsController.php
typo3/sysext/func/Resources/Private/Templates/Main.html [new file with mode: 0644]

index b2f89c1..3ece499 100644 (file)
@@ -63,6 +63,11 @@ class PageFunctionsController extends \TYPO3\CMS\Backend\Module\BaseScriptClass
     protected $iconFactory;
 
     /**
+     * @var StandaloneView
+     */
+    protected $view;
+
+    /**
      * Constructor
      */
     public function __construct()
@@ -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 (file)
index 0000000..5feda64
--- /dev/null
@@ -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>