[TASK] Extract html into fluid template from TS debug module in admin panel 53/56153/4
authorJoerg Boesche <typo3@joergboesche.de>
Thu, 15 Mar 2018 09:27:57 +0000 (10:27 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Thu, 15 Mar 2018 15:10:22 +0000 (16:10 +0100)
The TS debug module should use a fluid template instead of
the old php-html mixed data structure.

Resolves: #84271
Releases: master
Change-Id: I351f2a2f67ad21b06859d9da1cd7bad7e1ae0e1d
Reviewed-on: https://review.typo3.org/56153
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Tested-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Hendrik Stender <h.stender@neusta.de>
Reviewed-by: Tobi Kretschmann <tobi@tobishome.de>
Tested-by: Tobi Kretschmann <tobi@tobishome.de>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
13 files changed:
typo3/sysext/adminpanel/Classes/Modules/AbstractModule.php
typo3/sysext/adminpanel/Classes/Modules/CacheModule.php
typo3/sysext/adminpanel/Classes/Modules/TsDebugModule.php
typo3/sysext/adminpanel/Resources/Private/Language/locallang_tsdebug.xlf [new file with mode: 0644]
typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/DisplayContent.html [new file with mode: 0644]
typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/DisplayMessages.html [new file with mode: 0644]
typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/DisplayTimes.html [new file with mode: 0644]
typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/ForceTemplateParsing.html [new file with mode: 0644]
typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/TrackContentRendering.html [new file with mode: 0644]
typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/Tree.html [new file with mode: 0644]
typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/TypoScriptLog.html [new file with mode: 0644]
typo3/sysext/adminpanel/Resources/Private/Templates/Modules/TsDebug.html [new file with mode: 0644]
typo3/sysext/lang/Resources/Private/Language/locallang_tsfe.xlf

index f248961..090f8da 100644 (file)
@@ -26,6 +26,10 @@ use TYPO3\CMS\Core\Localization\LanguageService;
  */
 abstract class AbstractModule implements AdminPanelModuleInterface
 {
+    /**
+     * @var string
+     */
+    protected $extResources = 'EXT:adminpanel/Resources/Private';
 
     /**
      * @inheritdoc
index c4238a1..5a5fc63 100644 (file)
@@ -24,11 +24,6 @@ use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 class CacheModule extends AbstractModule
 {
     /**
-     * @var string
-     */
-    private $extResources = 'EXT:adminpanel/Resources/Private';
-
-    /**
      * Creates the content for the "cache" section ("module") of the Admin Panel
      *
      * @return string HTML content for the section. Consists of a string with table-rows with four columns.
index aaedcc3..6b33237 100644 (file)
@@ -1,6 +1,5 @@
 <?php
-declare(strict_types=1);
-
+declare(strict_types = 1);
 namespace TYPO3\CMS\Adminpanel\Modules;
 
 /*
@@ -18,6 +17,7 @@ namespace TYPO3\CMS\Adminpanel\Modules;
 
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Fluid\View\StandaloneView;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 
 /**
@@ -25,7 +25,6 @@ use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
  */
 class TsDebugModule extends AbstractModule
 {
-
     /**
      * Creates the content for the "tsdebug" section ("module") of the Admin Panel
      *
@@ -33,78 +32,26 @@ class TsDebugModule extends AbstractModule
      */
     public function getContent(): string
     {
-        $output = [];
-        $beuser = $this->getBackendUser();
-        if ($beuser->uc['TSFE_adminConfig']['display_tsdebug']) {
-            $output[] = '<div class="typo3-adminPanel-form-group">';
-            $output[] = '  <div class="typo3-adminPanel-form-group-checkbox">';
-            $output[] = '    <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_tree]" value="0" />';
-            $output[] = '    <label for="tsdebug_tree">';
-            $output[] = '      <input type="checkbox" id="tsdebug_tree" name="TSFE_ADMIN_PANEL[tsdebug_tree]" value="1"' .
-                        ($this->getBackendUser()->uc['TSFE_adminConfig']['tsdebug_tree'] ? ' checked="checked"' : '') .
-                        ' />';
-            $output[] = '      ' . $this->extGetLL('tsdebug_tree');
-            $output[] = '    </label>';
-            $output[] = '  </div>';
-            $output[] = '  <div class="typo3-adminPanel-form-group-checkbox">';
-            $output[] = '    <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]" value="0" />';
-            $output[] = '    <label for="tsdebug_displayTimes">';
-            $output[] = '      <input type="checkbox" id="tsdebug_displayTimes" name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]" value="1"' .
-                        ($this->getBackendUser(
-                        )->uc['TSFE_adminConfig']['tsdebug_displayTimes'] ? ' checked="checked"' : '') .
-                        ' />';
-            $output[] = '      ' . $this->extGetLL('tsdebug_displayTimes');
-            $output[] = '    </label>';
-            $output[] = '  </div>';
-            $output[] = '  <div class="typo3-adminPanel-form-group-checkbox">';
-            $output[] = '    <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="0" />';
-            $output[] = '    <label for="tsdebug_displayMessages">';
-            $output[] = '      <input type="checkbox" id="tsdebug_displayMessages" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="1"' .
-                        ($this->getBackendUser(
-                        )->uc['TSFE_adminConfig']['tsdebug_displayMessages'] ? ' checked="checked"' : '') .
-                        ' />';
-            $output[] = '      ' . $this->extGetLL('tsdebug_displayMessages');
-            $output[] = '    </label>';
-            $output[] = '  </div>';
-            $output[] = '  <div class="typo3-adminPanel-form-group-checkbox">';
-            $output[] = '    <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="0" />';
-            $output[] = '    <label for="tsdebug_LR">';
-            $output[] = '      <input type="checkbox" id="tsdebug_LR" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="1"' .
-                        ($this->getBackendUser()->uc['TSFE_adminConfig']['tsdebug_LR'] ? ' checked="checked"' : '') .
-                        ' />';
-            $output[] = '      ' . $this->extGetLL('tsdebug_LR');
-            $output[] = '    </label>';
-            $output[] = '  </div>';
-            $output[] = '  <div class="typo3-adminPanel-form-group-checkbox">';
-            $output[] = '    <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="0" />';
-            $output[] = '    <label for="tsdebug_displayContent">';
-            $output[] = '      <input type="checkbox" id="tsdebug_displayContent" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="1"' .
-                        ($this->getBackendUser(
-                        )->uc['TSFE_adminConfig']['tsdebug_displayContent'] ? ' checked="checked"' : '') .
-                        ' />';
-            $output[] = '      ' . $this->extGetLL('tsdebug_displayContent');
-            $output[] = '    </label>';
-            $output[] = '  </div>';
-            $output[] = '  <div class="typo3-adminPanel-form-group-checkbox">';
-            $output[] = '    <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="0" />';
-            $output[] = '    <label for="tsdebug_forceTemplateParsing">';
-            $output[] = '      <input type="checkbox" id="tsdebug_forceTemplateParsing" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="1"' .
-                        ($this->getBackendUser(
-                        )->uc['TSFE_adminConfig']['tsdebug_forceTemplateParsing'] ? ' checked="checked"' : '') .
-                        ' />';
-            $output[] = '      ' . $this->extGetLL('tsdebug_forceTemplateParsing');
-            $output[] = '    </label>';
-            $output[] = '  </div>';
-            $output[] = '</div>';
+        $view = GeneralUtility::makeInstance(StandaloneView::class);
+        $templateNameAndPath = $this->extResources . '/Templates/Modules/TsDebug.html';
+        $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateNameAndPath));
+        $view->setPartialRootPaths([$this->extResources . '/Partials']);
 
-            $timeTracker = $this->getTimeTracker();
-            $timeTracker->printConf['flag_tree'] = $this->getConfigurationOption('tree');
-            $timeTracker->printConf['allTime'] = $this->getConfigurationOption('displayTimes');
-            $timeTracker->printConf['flag_messages'] = $this->getConfigurationOption('displayMessages');
-            $timeTracker->printConf['flag_content'] = $this->getConfigurationOption('displayContent');
-            $output[] = $timeTracker->printTSlog();
-        }
-        return implode('', $output);
+        $tsfeAdminConfig = $this->getBackendUser()->uc['TSFE_adminConfig'];
+        $view->assignMultiple([
+            'isEnabled' => (int)$tsfeAdminConfig['display_tsdebug'],
+            'tree' => (int)$tsfeAdminConfig['tsdebug_tree'],
+            'display' => [
+                'times' => (int)$tsfeAdminConfig['tsdebug_displayTimes'],
+                'messages' => (int)$tsfeAdminConfig['tsdebug_displayMessages'],
+                'content' => (int)$tsfeAdminConfig['tsdebug_displayContent'],
+            ],
+            'trackContentRendering' => (int)$tsfeAdminConfig['tsdebug_LR'],
+            'forceTemplateParsing' => (int)$tsfeAdminConfig['tsdebug_forceTemplateParsing'],
+            'typoScriptLog' => $this->renderTypoScriptLog()
+        ]);
+
+        return $view->render();
     }
 
     /**
@@ -120,7 +67,8 @@ class TsDebugModule extends AbstractModule
      */
     public function getLabel(): string
     {
-        return $this->extGetLL('tsdebug');
+        $locallangFileAndPath = 'LLL:' . $this->extResources . '/Language/locallang_tsdebug.xlf:module.label';
+        return $this->getLanguageService()->sL($locallangFileAndPath);
     }
 
     /**
@@ -159,4 +107,20 @@ class TsDebugModule extends AbstractModule
     {
         return $GLOBALS['TSFE'];
     }
+
+    /**
+     * Renders the TypoScript log as string
+     *
+     * @param $output
+     * @return string
+     */
+    private function renderTypoScriptLog(): string
+    {
+        $timeTracker = $this->getTimeTracker();
+        $timeTracker->printConf['flag_tree'] = $this->getConfigurationOption('tree');
+        $timeTracker->printConf['allTime'] = $this->getConfigurationOption('displayTimes');
+        $timeTracker->printConf['flag_messages'] = $this->getConfigurationOption('displayMessages');
+        $timeTracker->printConf['flag_content'] = $this->getConfigurationOption('displayContent');
+        return $timeTracker->printTSlog();
+    }
 }
diff --git a/typo3/sysext/adminpanel/Resources/Private/Language/locallang_tsdebug.xlf b/typo3/sysext/adminpanel/Resources/Private/Language/locallang_tsdebug.xlf
new file mode 100644 (file)
index 0000000..9958a75
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
+    <file t3:id="1521103145" source-language="en" datatype="plaintext" original="messages" date="2018-03-15T09:39:00Z" product-name="adminpanel">
+        <header/>
+        <body>
+            <trans-unit id="module.label">
+                <source>TypoScript</source>
+            </trans-unit>
+            <trans-unit id="treeDisplay">
+                <source>Tree display</source>
+            </trans-unit>
+            <trans-unit id="displayTimes">
+                <source>Display all times</source>
+            </trans-unit>
+            <trans-unit id="displayMessages">
+                <source>Display messages</source>
+            </trans-unit>
+            <trans-unit id="displayContent">
+                <source>Display content</source>
+            </trans-unit>
+            <trans-unit id="trackContentRendering">
+                <source>Track content rendering</source>
+            </trans-unit>
+            <trans-unit id="forceTemplateParsing">
+                <source>Force TS Rendering</source>
+            </trans-unit>
+        </body>
+    </file>
+</xliff>
diff --git a/typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/DisplayContent.html b/typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/DisplayContent.html
new file mode 100644 (file)
index 0000000..68aa3e8
--- /dev/null
@@ -0,0 +1,11 @@
+<div class="typo3-adminPanel-form-group-checkbox">
+    <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="0"/>
+    <label for="tsdebug_displayContent">
+        <input type="checkbox"
+               id="tsdebug_displayContent"
+               name="TSFE_ADMIN_PANEL[tsdebug_displayContent]"
+               value="1"
+               {f:if(condition:'{display.content}', then:' checked="checked"')} />
+        <f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_tsdebug.xlf:displayContent"/>
+    </label>
+</div>
diff --git a/typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/DisplayMessages.html b/typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/DisplayMessages.html
new file mode 100644 (file)
index 0000000..6961fa3
--- /dev/null
@@ -0,0 +1,11 @@
+<div class="typo3-adminPanel-form-group-checkbox">
+    <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="0"/>
+    <label for="tsdebug_displayMessages">
+        <input type="checkbox"
+               id="tsdebug_displayMessages"
+               name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]"
+               value="1"
+               {f:if(condition:'{display.messages}', then:' checked="checked"')} />
+        <f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_tsdebug.xlf:displayMessages"/>
+    </label>
+</div>
diff --git a/typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/DisplayTimes.html b/typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/DisplayTimes.html
new file mode 100644 (file)
index 0000000..7e216be
--- /dev/null
@@ -0,0 +1,11 @@
+<div class="typo3-adminPanel-form-group-checkbox">
+    <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]" value="0"/>
+    <label for="tsdebug_displayTimes">
+        <input type="checkbox"
+               id="tsdebug_displayTimes"
+               name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]"
+               value="1"
+               {f:if(condition:'{display.times}', then:' checked="checked"')} />
+        <f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_tsdebug.xlf:displayTimes"/>
+    </label>
+</div>
diff --git a/typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/ForceTemplateParsing.html b/typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/ForceTemplateParsing.html
new file mode 100644 (file)
index 0000000..5c97600
--- /dev/null
@@ -0,0 +1,11 @@
+<div class="typo3-adminPanel-form-group-checkbox">
+    <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="0"/>
+    <label for="tsdebug_forceTemplateParsing">
+        <input type="checkbox"
+               id="tsdebug_forceTemplateParsing"
+               name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]"
+               value="1"
+               {f:if(condition:'{forceTemplateParsing}', then:' checked="checked"')} />
+        <f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_tsdebug.xlf:forceTemplateParsing"/>
+    </label>
+</div>
diff --git a/typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/TrackContentRendering.html b/typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/TrackContentRendering.html
new file mode 100644 (file)
index 0000000..f56d09e
--- /dev/null
@@ -0,0 +1,11 @@
+<div class="typo3-adminPanel-form-group-checkbox">
+    <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="0"/>
+    <label for="tsdebug_LR">
+        <input type="checkbox"
+               id="tsdebug_LR"
+               name="TSFE_ADMIN_PANEL[tsdebug_LR]"
+               value="1"
+               {f:if(condition:'{trackContentRendering}', then:' checked="checked"')} />
+        <f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_tsdebug.xlf:trackContentRendering"/>
+    </label>
+</div>
diff --git a/typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/Tree.html b/typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/Tree.html
new file mode 100644 (file)
index 0000000..7fed5cb
--- /dev/null
@@ -0,0 +1,11 @@
+<div class="typo3-adminPanel-form-group-checkbox">
+    <input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_tree]" value="0"/>
+    <label for="tsdebug_tree">
+        <input type="checkbox"
+               id="tsdebug_tree"
+               name="TSFE_ADMIN_PANEL[tsdebug_tree]"
+               value="1"
+               {f:if(condition:'{tree}', then:' checked="checked"')} />
+        <f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_tsdebug.xlf:treeDisplay"/>
+    </label>
+</div>
diff --git a/typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/TypoScriptLog.html b/typo3/sysext/adminpanel/Resources/Private/Partials/Modules/TsDebug/TypoScriptLog.html
new file mode 100644 (file)
index 0000000..938a9c2
--- /dev/null
@@ -0,0 +1 @@
+{typoScriptLog -> f:format.raw()}
diff --git a/typo3/sysext/adminpanel/Resources/Private/Templates/Modules/TsDebug.html b/typo3/sysext/adminpanel/Resources/Private/Templates/Modules/TsDebug.html
new file mode 100644 (file)
index 0000000..fc19c3b
--- /dev/null
@@ -0,0 +1,11 @@
+<f:if condition="{isEnabled} == 1">
+    <div class="typo3-adminPanel-form-group">
+        <f:render partial="Modules/TsDebug/Tree" arguments="{_all}"/>
+        <f:render partial="Modules/TsDebug/DisplayTimes" arguments="{_all}"/>
+        <f:render partial="Modules/TsDebug/DisplayMessages" arguments="{_all}"/>
+        <f:render partial="Modules/TsDebug/TrackContentRendering" arguments="{_all}"/>
+        <f:render partial="Modules/TsDebug/DisplayContent" arguments="{_all}"/>
+        <f:render partial="Modules/TsDebug/ForceTemplateParsing" arguments="{_all}"/>
+        <f:render partial="Modules/TsDebug/TypoScriptLog" arguments="{_all}"/>
+    </div>
+</f:if>
index bb2aec8..c406204 100644 (file)
                        <trans-unit id="edit_db_list">
                                <source>Web&gt;List module</source>
                        </trans-unit>
-                       <trans-unit id="tsdebug">
-                               <source>TypoScript</source>
-                       </trans-unit>
-                       <trans-unit id="tsdebug_tree">
-                               <source>Tree display</source>
-                       </trans-unit>
-                       <trans-unit id="tsdebug_LR">
-                               <source>Track content rendering</source>
-                       </trans-unit>
-                       <trans-unit id="tsdebug_forceTemplateParsing">
-                               <source>Force TS Rendering</source>
-                       </trans-unit>
-                       <trans-unit id="tsdebug_displayTimes">
-                               <source>Display all times</source>
-                       </trans-unit>
-                       <trans-unit id="tsdebug_displayMessages">
-                               <source>Display messages</source>
-                       </trans-unit>
-                       <trans-unit id="tsdebug_displayContent">
-                               <source>Display content</source>
-                       </trans-unit>
                        <trans-unit id="info">
                                <source>Info</source>
                        </trans-unit>