[TASK] Use FLUIDTEMPLATE for rendering module Configuration 78/32778/9
authorFrank Nägler <typo3@naegler.net>
Mon, 15 Sep 2014 12:14:32 +0000 (14:14 +0200)
committerMarkus Klein <klein.t3@reelworx.at>
Sat, 20 Sep 2014 21:27:14 +0000 (23:27 +0200)
As cleanup and improvement for the backend it is important to remove the
HTML code from the PHP logic. This patch removes the HTML code and uses
StandaloneView to render the content of the module.

The markup was removed as far as possible.

Resolves: #61604
Releases: 6.3
Change-Id: Ic515c790d1d76499cc18ecd633a570de9bfff2ca
Reviewed-on: http://review.typo3.org/32778
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/lowlevel/Classes/View/ConfigurationView.php
typo3/sysext/lowlevel/Resources/Private/Language/locallang.xlf [new file with mode: 0644]
typo3/sysext/lowlevel/Resources/Private/Templates/Backend/Configuration.html [new file with mode: 0644]
typo3/sysext/lowlevel/config/locallang.xlf [deleted file]

index 0171395..819b383 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Lowlevel\View;
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
 
 /**
  * Script class for the Config module
@@ -23,6 +24,15 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 class ConfigurationView {
+       /**
+        * @var \TYPO3\CMS\Fluid\View\StandaloneView
+        */
+       protected $view;
+
+       /**
+        * @var \TYPO3\CMS\Core\Messaging\FlashMessageQueue
+        */
+       protected $flashMessageQueue;
 
        /**
         * @todo Define visibility
@@ -61,8 +71,9 @@ class ConfigurationView {
         * Constructor
         */
        public function __construct() {
-               $GLOBALS['LANG']->includeLLFile('EXT:lowlevel/config/locallang.xlf');
                $GLOBALS['BE_USER']->modAccess($GLOBALS['MCONF'], 1);
+               $this->view = GeneralUtility::makeInstance('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
+               $this->view->getRequest()->setControllerExtensionName('lowlevel');
        }
 
        /**
@@ -95,16 +106,16 @@ class ConfigurationView {
                // Values NOT in this array will not be saved in the settings-array for the module.
                $this->MOD_MENU = array(
                        'function' => array(
-                               0 => $GLOBALS['LANG']->getLL('typo3ConfVars', TRUE),
-                               1 => $GLOBALS['LANG']->getLL('tca', TRUE),
-                               2 => $GLOBALS['LANG']->getLL('tcaDescr', TRUE),
-                               3 => $GLOBALS['LANG']->getLL('loadedExt', TRUE),
-                               4 => $GLOBALS['LANG']->getLL('t3services', TRUE),
-                               5 => $GLOBALS['LANG']->getLL('tbemodules', TRUE),
-                               6 => $GLOBALS['LANG']->getLL('tbemodulesext', TRUE),
-                               7 => $GLOBALS['LANG']->getLL('tbeStyles', TRUE),
-                               8 => $GLOBALS['LANG']->getLL('beUser', TRUE),
-                               9 => $GLOBALS['LANG']->getLL('usersettings', TRUE)
+                               0 => LocalizationUtility::translate('typo3ConfVars', 'lowlevel'),
+                               1 => LocalizationUtility::translate('tca', 'lowlevel'),
+                               2 => LocalizationUtility::translate('tcaDescr', 'lowlevel'),
+                               3 => LocalizationUtility::translate('loadedExt', 'lowlevel'),
+                               4 => LocalizationUtility::translate('t3services', 'lowlevel'),
+                               5 => LocalizationUtility::translate('tbemodules', 'lowlevel'),
+                               6 => LocalizationUtility::translate('tbemodulesext', 'lowlevel'),
+                               7 => LocalizationUtility::translate('tbeStyles', 'lowlevel'),
+                               8 => LocalizationUtility::translate('beUser', 'lowlevel'),
+                               9 => LocalizationUtility::translate('usersettings', 'lowlevel')
                        ),
                        'regexsearch' => '',
                        'fixedLgd' => ''
@@ -123,31 +134,14 @@ class ConfigurationView {
                $arrayBrowser = GeneralUtility::makeInstance('TYPO3\\CMS\\Lowlevel\\Utility\\ArrayBrowser');
                $label = $this->MOD_MENU['function'][$this->MOD_SETTINGS['function']];
                $search_field = GeneralUtility::_GP('search_field');
-               $this->content = $this->doc->header($GLOBALS['LANG']->getLL('configuration', TRUE));
-               $this->content .= '<h2>' . $label . '</h2>';
-
-               $this->content .= '<div id="lowlevel-config">
-                                               <label for="search_field">' . $GLOBALS['LANG']->getLL('enterSearchPhrase', TRUE) . '</label>
-                                               <input type="text" id="search_field" name="search_field" value="' . htmlspecialchars($search_field) . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' />
-                                               <input type="submit" name="search" id="search" value="' . $GLOBALS['LANG']->getLL('search', TRUE) . '" />';
-
-               $this->content .= '<div class="checkbox">' .
-                       '<label for="checkRegexsearch">' .
-                               BackendUtility::getFuncCheck(0, 'SET[regexsearch]', $this->MOD_SETTINGS['regexsearch'], '', '', 'id="checkRegexsearch"') .
-                               $GLOBALS['LANG']->getLL('useRegExp', TRUE) .
-                       '</label>' .
-                       '</div>';
-
-               $this->content .= '<div class="checkbox">' .
-                       '<label for="checkFixedLgd">' .
-                               BackendUtility::getFuncCheck(0, 'SET[fixedLgd]', $this->MOD_SETTINGS['fixedLgd'], '', '', 'id="checkFixedLgd"') .
-                       $GLOBALS['LANG']->getLL('cropLines', TRUE) .
-                       '</label>' .
-                       '</div>';
 
-               $this->content .= '</div>';
+               $templatePathAndFilename = GeneralUtility::getFileAbsFileName('EXT:lowlevel/Resources/Private/Templates/Backend/Configuration.html');
+               $this->view->setTemplatePathAndFilename($templatePathAndFilename);
+               $this->view->assign('label', $label);
+               $this->view->assign('search_field', $search_field);
+               $this->view->assign('checkbox_checkRegexsearch', BackendUtility::getFuncCheck(0, 'SET[regexsearch]', $this->MOD_SETTINGS['regexsearch'], '', '', 'id="checkRegexsearch"'));
+               $this->view->assign('checkbox_checkFixedLgd', BackendUtility::getFuncCheck(0, 'SET[fixedLgd]', $this->MOD_SETTINGS['fixedLgd'], '', '', 'id="checkFixedLgd"'));
 
-               $this->content .= $this->doc->spacer(5);
                switch ($this->MOD_SETTINGS['function']) {
                        case 0:
                                $theVar = $GLOBALS['TYPO3_CONF_VARS'];
@@ -227,9 +221,10 @@ class ConfigurationView {
                        $theVar['SYS']['encryptionKey'] = '***** (length: ' . strlen($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']) . ' characters)';
                }
                $tree = $arrayBrowser->tree($theVar, '', '');
-               $this->content .= $this->doc->sectionEnd();
+               $this->view->assign('tree', $tree);
                // Variable name:
                if (GeneralUtility::_GP('varname')) {
+                       $this->view->assign('varname', TRUE);
                        $line = GeneralUtility::_GP('_') ? GeneralUtility::_GP('_') : GeneralUtility::_GP('varname');
                        // Write the line to extTables.php
                        if (GeneralUtility::_GP('writetoexttables')) {
@@ -253,7 +248,7 @@ class ConfigurationView {
                                                'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
                                                '',
                                                sprintf(
-                                                       $GLOBALS['LANG']->getLL('writeMessage', TRUE),
+                                                       LocalizationUtility::translate('writeMessage', 'lowlevel'),
                                                        TYPO3_extTableDef_script,
                                                        '<br />',
                                                        '<strong>' . nl2br(htmlspecialchars($changedLine)) . '</strong>'
@@ -265,30 +260,31 @@ class ConfigurationView {
                                        $flashMessage = GeneralUtility::makeInstance(
                                                'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
                                                '',
-                                               sprintf($GLOBALS['LANG']->getLL('writeMessageFailed', TRUE), TYPO3_extTableDef_script),
+                                               sprintf(LocalizationUtility::translate('writeMessageFailed', 'lowlevel'), TYPO3_extTableDef_script),
                                                \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR
                                        );
                                }
-                               $this->content .= $flashMessage->render();
+                               $this->getFlashMessageQueue()->enqueue($flashMessage);
                        }
-                       $this->content .= '<div id="lowlevel-config-var">
-                               <strong>' . $GLOBALS['LANG']->getLL('variable', TRUE) . '</strong><br />
-                               <input type="text" name="_" value="' . trim(htmlspecialchars($line)) . '" size="120" /><br/>';
+
+                       $this->view->assign('line', trim($line));
+
                        if (TYPO3_extTableDef_script !== '' && ($this->MOD_SETTINGS['function'] === '1' || $this->MOD_SETTINGS['function'] === '4')) {
                                // write only for $TCA and TBE_STYLES if  TYPO3_extTableDef_script is defined
-                               $this->content .= '<br /><input type="submit" name="writetoexttables" value="' . $GLOBALS['LANG']->getLL('writeValue', TRUE) . '" /></div>';
+                               $this->view->assign('showSaveButton', TRUE);
                        } else {
-                               $this->content .= $GLOBALS['LANG']->getLL('copyPaste', TRUE) . LF . '</div>';
+                               $this->view->assign('showSaveButton', FALSE);
                        }
+               } else {
+                       $this->view->assign('varname', FALSE);
                }
-               $this->content .= '<div class="nowrap">' . $tree . '</div>';
 
                // Setting up the buttons and markers for docheader
                $docHeaderButtons = $this->getButtons();
                $markers = array(
                        'CSH' => $docHeaderButtons['csh'],
                        'FUNC_MENU' => $this->getFuncMenu(),
-                       'CONTENT' => $this->content
+                       'CONTENT' => $this->view->render(),
                );
                // Build the <body> for the module
                $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
@@ -333,4 +329,16 @@ class ConfigurationView {
                return $funcMenu;
        }
 
+       /**
+        * @return \TYPO3\CMS\Core\Messaging\FlashMessageQueue
+        */
+       protected function getFlashMessageQueue() {
+               if (!$this->flashMessageQueue instanceof \TYPO3\CMS\Core\Messaging\FlashMessageQueue) {
+                       /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
+                       $flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
+                       $this->flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
+               }
+
+               return $this->flashMessageQueue;
+       }
 }
diff --git a/typo3/sysext/lowlevel/Resources/Private/Language/locallang.xlf b/typo3/sysext/lowlevel/Resources/Private/Language/locallang.xlf
new file mode 100644 (file)
index 0000000..c6495e6
--- /dev/null
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.0">
+       <file source-language="en" datatype="plaintext" original="messages" date="2011-10-17T20:22:34Z" product-name="lowlevel">
+               <header/>
+               <body>
+                       <trans-unit id="configuration" xml:space="preserve">
+                               <source>Configuration</source>
+                       </trans-unit>
+                       <trans-unit id="typo3ConfVars" xml:space="preserve">
+                               <source>$GLOBALS['TYPO3_CONF_VARS'] (Global Configuration)</source>
+                       </trans-unit>
+                       <trans-unit id="tca" xml:space="preserve">
+                               <source>$GLOBALS['TCA'] (Table configuration array)</source>
+                       </trans-unit>
+                       <trans-unit id="tcaDescr" xml:space="preserve">
+                               <source>$GLOBALS['TCA_DESCR'] (Table Help Description)</source>
+                       </trans-unit>
+                       <trans-unit id="loadedExt" xml:space="preserve">
+                               <source>$GLOBALS['TYPO3_LOADED_EXT'] (Loaded Extensions)</source>
+                       </trans-unit>
+                       <trans-unit id="tbeStyles" xml:space="preserve">
+                               <source>$GLOBALS['TBE_STYLES'] (Skinning Styles)</source>
+                       </trans-unit>
+                       <trans-unit id="beUser" xml:space="preserve">
+                               <source>$GLOBALS['BE_USER']-&gt;uc (User Settings)</source>
+                       </trans-unit>
+                       <trans-unit id="usersettings" xml:space="preserve">
+                               <source>$GLOBALS['TYPO3_USER_SETTINGS'] (User Settings Configuration)</source>
+                       </trans-unit>
+                       <trans-unit id="t3services" xml:space="preserve">
+                               <source>$GLOBALS['T3_SERVICES'] (Registered Services)</source>
+                       </trans-unit>
+                       <trans-unit id="tbemodulesext" xml:space="preserve">
+                               <source>$GLOBALS['TBE_MODULES_EXT'] (BE Modules Extensions)</source>
+                       </trans-unit>
+                       <trans-unit id="tbemodules" xml:space="preserve">
+                               <source>$GLOBALS['TBE_MODULES'] (BE Modules)</source>
+                       </trans-unit>
+                       <trans-unit id="cropLines" xml:space="preserve">
+                               <source>Crop lines</source>
+                       </trans-unit>
+                       <trans-unit id="variable" xml:space="preserve">
+                               <source>Variable:</source>
+                       </trans-unit>
+                       <trans-unit id="copyPaste" xml:space="preserve">
+                               <source>(Now, copy/paste this value into the configuration file where you can set it. This is all you can do from here...)</source>
+                       </trans-unit>
+                       <trans-unit id="enterSearchPhrase" xml:space="preserve">
+                               <source>Enter search phrase:</source>
+                       </trans-unit>
+                       <trans-unit id="search" xml:space="preserve">
+                               <source>Search</source>
+                       </trans-unit>
+                       <trans-unit id="useRegExp" xml:space="preserve">
+                               <source>Use regular expression</source>
+                       </trans-unit>
+                       <trans-unit id="writeValue" xml:space="preserve">
+                               <source>Write value to configuration file</source>
+                       </trans-unit>
+                       <trans-unit id="writeMessage" xml:space="preserve">
+                               <source>Following line was added to configuration file (%s): %s%s</source>
+                       </trans-unit>
+                       <trans-unit id="writeMessageFailed" xml:space="preserve">
+                               <source>Write to configuration file failed (%s)!</source>
+                       </trans-unit>
+               </body>
+       </file>
+</xliff>
diff --git a/typo3/sysext/lowlevel/Resources/Private/Templates/Backend/Configuration.html b/typo3/sysext/lowlevel/Resources/Private/Templates/Backend/Configuration.html
new file mode 100644 (file)
index 0000000..77f3b8b
--- /dev/null
@@ -0,0 +1,45 @@
+<f:flashMessages renderMode="div"/>
+
+<h1><f:translate key="configuration" /></h1>
+<h2>{label}</h2>
+<div id="lowlevel-config">
+       <label for="search_field">
+               <f:translate key="enterSearchPhrase" />
+       </label>
+       <input type="text" id="search_field" name="search_field" value="{search_field}" style="width:192px;"/>
+       <input type="submit" name="search" id="search" value="{f:translate(key: 'search')}"/>
+
+       <div class="checkbox">
+               <label for="checkRegexsearch">
+                       <f:format.raw>{checkbox_checkRegexsearch}</f:format.raw>
+                       <f:translate key="useRegExp" />
+               </label>
+       </div>
+       <div class="checkbox">
+               <label for="checkFixedLgd">
+                       <f:format.raw>{checkbox_checkFixedLgd}</f:format.raw>
+                       <f:translate key="cropLines" />
+               </label>
+       </div>
+</div>
+<div style="padding-top: 5px;" id="lowlevel-config-var">
+       <f:if condition="{varname}">
+               <strong>
+                       <f:translate key="variable" />
+               </strong><br/>
+               <input type="text" name="_" value="{line}" size="120"/><br/>
+
+               <f:if condition="{showSaveButton}">
+                       <f:then>
+                               <br/><input type="submit" name="writetoexttables" value="{f:translate(key: 'writeValue')}"/>
+                       </f:then>
+                       <f:else>
+                               <f:translate key="copyPaste" />
+                       </f:else>
+               </f:if>
+       </f:if>
+</div>
+
+<div class="nowrap" style="margin-top: 20px;">
+       <f:format.raw>{tree}</f:format.raw>
+</div>
\ No newline at end of file
diff --git a/typo3/sysext/lowlevel/config/locallang.xlf b/typo3/sysext/lowlevel/config/locallang.xlf
deleted file mode 100644 (file)
index c6495e6..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xliff version="1.0">
-       <file source-language="en" datatype="plaintext" original="messages" date="2011-10-17T20:22:34Z" product-name="lowlevel">
-               <header/>
-               <body>
-                       <trans-unit id="configuration" xml:space="preserve">
-                               <source>Configuration</source>
-                       </trans-unit>
-                       <trans-unit id="typo3ConfVars" xml:space="preserve">
-                               <source>$GLOBALS['TYPO3_CONF_VARS'] (Global Configuration)</source>
-                       </trans-unit>
-                       <trans-unit id="tca" xml:space="preserve">
-                               <source>$GLOBALS['TCA'] (Table configuration array)</source>
-                       </trans-unit>
-                       <trans-unit id="tcaDescr" xml:space="preserve">
-                               <source>$GLOBALS['TCA_DESCR'] (Table Help Description)</source>
-                       </trans-unit>
-                       <trans-unit id="loadedExt" xml:space="preserve">
-                               <source>$GLOBALS['TYPO3_LOADED_EXT'] (Loaded Extensions)</source>
-                       </trans-unit>
-                       <trans-unit id="tbeStyles" xml:space="preserve">
-                               <source>$GLOBALS['TBE_STYLES'] (Skinning Styles)</source>
-                       </trans-unit>
-                       <trans-unit id="beUser" xml:space="preserve">
-                               <source>$GLOBALS['BE_USER']-&gt;uc (User Settings)</source>
-                       </trans-unit>
-                       <trans-unit id="usersettings" xml:space="preserve">
-                               <source>$GLOBALS['TYPO3_USER_SETTINGS'] (User Settings Configuration)</source>
-                       </trans-unit>
-                       <trans-unit id="t3services" xml:space="preserve">
-                               <source>$GLOBALS['T3_SERVICES'] (Registered Services)</source>
-                       </trans-unit>
-                       <trans-unit id="tbemodulesext" xml:space="preserve">
-                               <source>$GLOBALS['TBE_MODULES_EXT'] (BE Modules Extensions)</source>
-                       </trans-unit>
-                       <trans-unit id="tbemodules" xml:space="preserve">
-                               <source>$GLOBALS['TBE_MODULES'] (BE Modules)</source>
-                       </trans-unit>
-                       <trans-unit id="cropLines" xml:space="preserve">
-                               <source>Crop lines</source>
-                       </trans-unit>
-                       <trans-unit id="variable" xml:space="preserve">
-                               <source>Variable:</source>
-                       </trans-unit>
-                       <trans-unit id="copyPaste" xml:space="preserve">
-                               <source>(Now, copy/paste this value into the configuration file where you can set it. This is all you can do from here...)</source>
-                       </trans-unit>
-                       <trans-unit id="enterSearchPhrase" xml:space="preserve">
-                               <source>Enter search phrase:</source>
-                       </trans-unit>
-                       <trans-unit id="search" xml:space="preserve">
-                               <source>Search</source>
-                       </trans-unit>
-                       <trans-unit id="useRegExp" xml:space="preserve">
-                               <source>Use regular expression</source>
-                       </trans-unit>
-                       <trans-unit id="writeValue" xml:space="preserve">
-                               <source>Write value to configuration file</source>
-                       </trans-unit>
-                       <trans-unit id="writeMessage" xml:space="preserve">
-                               <source>Following line was added to configuration file (%s): %s%s</source>
-                       </trans-unit>
-                       <trans-unit id="writeMessageFailed" xml:space="preserve">
-                               <source>Write to configuration file failed (%s)!</source>
-                       </trans-unit>
-               </body>
-       </file>
-</xliff>