[TASK] Fluidification of Info Module 29/47129/3
authorMichael Oehlhof <typo3@oehlhof.de>
Sun, 6 Mar 2016 00:42:04 +0000 (01:42 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 6 Mar 2016 12:44:12 +0000 (13:44 +0100)
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>
typo3/sysext/backend/Classes/Module/BaseScriptClass.php
typo3/sysext/info/Classes/Controller/InfoModuleController.php
typo3/sysext/info/Resources/Private/Templates/Main.html [new file with mode: 0644]

index 7ae8631..2bb139f 100644 (file)
@@ -359,6 +359,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
      */
index a23eb22..5da6fb5 100644 (file)
@@ -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
@@ -59,6 +60,11 @@ class InfoModuleController extends BaseScriptClass
     protected $moduleTemplate;
 
     /**
+     * @var StandaloneView
+     */
+    protected $view;
+
+    /**
      * Constructor
      */
     public function __construct()
@@ -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 (file)
index 0000000..589df2d
--- /dev/null
@@ -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>