Revert "[FEATURE] Use FormEngine in Template and Filelist modules" 69/49869/3
authorAndreas Fernandez <typo3@scripting-base.de>
Tue, 6 Sep 2016 06:05:01 +0000 (08:05 +0200)
committerAndreas Fernandez <typo3@scripting-base.de>
Tue, 6 Sep 2016 07:38:47 +0000 (09:38 +0200)
This reverts commit 3618b5c084a52ad3771bc92c2a2cf9aa75da17dd.

This change requires further architectural changes within the controllers
of EXT:filelist which were not considered.

Resolves: #77858
Resolves: #77857
Reverts: #77727

Change-Id: I1ff9d72cd8f0bffd597d2c5452fd684f716ff412
Reviewed-on: https://review.typo3.org/49869
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Ralf Merz <info@merzilla.de>
Tested-by: Ralf Merz <info@merzilla.de>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/backend/Classes/Controller/File/EditFileController.php
typo3/sysext/backend/Classes/Controller/File/FileController.php
typo3/sysext/core/Documentation/Changelog/master/Feature-77727-UseFormEngineInTemplateAndFilelistModules.rst [deleted file]
typo3/sysext/t3editor/Classes/Form/Element/T3editorElement.php
typo3/sysext/t3editor/Classes/Hook/FileEditHook.php
typo3/sysext/t3editor/Classes/Hook/TypoScriptTemplateInfoHook.php
typo3/sysext/t3editor/Classes/T3editor.php
typo3/sysext/t3editor/ext_localconf.php
typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateInformationModuleFunctionController.php
typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateModuleController.php

index a178291..e3fa473 100644 (file)
@@ -16,8 +16,6 @@ namespace TYPO3\CMS\Backend\Controller\File;
 
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
-use TYPO3\CMS\Backend\Form\FormResultCompiler;
-use TYPO3\CMS\Backend\Form\NodeFactory;
 use TYPO3\CMS\Backend\Module\AbstractModule;
 use TYPO3\CMS\Backend\Template\Components\ButtonBar;
 use TYPO3\CMS\Backend\Template\DocumentTemplate;
@@ -148,27 +146,13 @@ class EditFileController extends AbstractModule
     public function main()
     {
         $this->getButtons();
-
-        $dataColumnDefinition = [
-            'label' => htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:file'))
-                . ' ' . htmlspecialchars($this->target),
-            'config' => [
-                'type' => 'text',
-                'cols' => 48,
-                'wrap' => 'OFF',
-                'softref' => 'email[subst],url[subst]'
-            ],
-            'defaultExtras' => 'fixed-font: enable-tab'
-        ];
-
-        // Hook before compiling the output
+        // Hook        before compiling the output
         if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'])) {
             $preOutputProcessingHook = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'];
             if (is_array($preOutputProcessingHook)) {
                 $hookParameters = [
                     'content' => &$this->content,
-                    'target' => &$this->target,
-                    'dataColumnDefinition' => &$dataColumnDefinition
+                    'target' => &$this->target
                 ];
                 foreach ($preOutputProcessingHook as $hookFunction) {
                     GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
@@ -196,48 +180,13 @@ class EditFileController extends AbstractModule
                 'target' => $this->origTarget,
                 'returnUrl' => $this->returnUrl
             ]);
-            $formData = [
-                'databaseRow' => [
-                    'uid' => 0,
-                    'data' => $fileContent,
-                    'target' => $this->fileObject->getUid(),
-                    'redirect' => $hValue
-                ],
-                'tableName' => 'editfile',
-                'processedTca' => [
-                    'columns' => [
-                        'data' => $dataColumnDefinition,
-                        'target' => [
-                            'config' => [
-                                'type' => 'input',
-                                'renderType' => 'hidden'
-                            ]
-                        ],
-                        'redirect' => [
-                            'config' => [
-                                'type' => 'input',
-                                'renderType' => 'hidden'
-                            ]
-                        ]
-                    ],
-                    'types' => [
-                        1 => [
-                            'showitem' => 'data,target,redirect',
-                        ],
-                    ],
-                ],
-                'recordTypeValue' => 1,
-                'inlineStructure' => [],
-                'renderType' => 'fullRecordContainer'
-            ];
-
-            $resultArray = GeneralUtility::makeInstance(NodeFactory::class)->create($formData)->render();
-            $formResultCompiler = GeneralUtility::makeInstance(FormResultCompiler::class);
-            $formResultCompiler->mergeResult($resultArray);
-
-            $code .= $formResultCompiler->JStop()
-                . $formResultCompiler->printNeededJSFunctions()
-                . $resultArray['html'];
+            $code .= '
+                <div id="c-edit">
+                                       <textarea rows="30" name="file[editfile][0][data]" wrap="off"  class="form-control text-monospace t3js-enable-tab">' . htmlspecialchars($fileContent) . '</textarea>
+                                       <input type="hidden" name="file[editfile][0][target]" value="' . $this->fileObject->getUid() . '" />
+                                       <input type="hidden" name="redirect" value="' . htmlspecialchars($hValue) . '" />
+                               </div>
+                               <br />';
         } catch (\Exception $e) {
             $code .= sprintf(
                 $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_edit.php.coundNot'),
@@ -248,7 +197,7 @@ class EditFileController extends AbstractModule
         // Ending of section and outputting editing form:
         $pageContent .= $code;
 
-        // Hook after compiling the output
+        // Hook        after compiling the output
         if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook'])) {
             $postOutputProcessingHook = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook'];
             if (is_array($postOutputProcessingHook)) {
index cc75579..1b577c8 100644 (file)
@@ -102,11 +102,11 @@ class FileController
     protected function init()
     {
         // Set the GPvars from outside
-        $this->file = GeneralUtility::_GP('data');
+        $this->file = GeneralUtility::_GP('file');
         $this->CB = GeneralUtility::_GP('CB');
         $this->overwriteExistingFiles = DuplicationBehavior::cast(GeneralUtility::_GP('overwriteExistingFiles'));
         $this->vC = GeneralUtility::_GP('vC');
-        $this->redirect = $this->file['editfile'][0]['redirect'];
+        $this->redirect = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('redirect'));
         $this->initClipboard();
         $this->fileProcessor = GeneralUtility::makeInstance(ExtendedFileUtility::class);
     }
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-77727-UseFormEngineInTemplateAndFilelistModules.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-77727-UseFormEngineInTemplateAndFilelistModules.rst
deleted file mode 100644 (file)
index 2ef1fe7..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-=================================================================
-Feature: #77727 - Use FormEngine in Template and Filelist modules
-=================================================================
-
-Description
-===========
-
-The backend modules "Template" and "Filelist" have been migrated
-to use the FormEngine for rendering the forms.
-
-
-Impact
-======
-
-The class `\TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController` received a new hook
-:php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['preOutputProcessingHook']`
-which takes two parameters:
-* :php:`$parameters` (array)
-* :php:`$pObj` (TypoScriptTemplateInformationModuleFunctionController)
-
-The `formData` element of the array `$parameters` contains the form structure for FormEngine, which may be
-extended in a hook.
-
-The TCA for t3editor fields has received a new configuration option `ajaxSaveType` required for saving hooks.
index d445736..fe30393 100644 (file)
@@ -87,11 +87,6 @@ class T3editorElement extends AbstractFormElement
     protected $codeCompletionComponents = ['TsRef', 'CompletionResult', 'TsParser', 'TsCodeCompletion'];
 
     /**
-     * @var string
-     */
-    protected $ajaxSaveType = '';
-
-    /**
      * Render t3editor element
      *
      * @return array As defined in initializeResultArray() of AbstractNode
@@ -107,8 +102,7 @@ class T3editorElement extends AbstractFormElement
         $parameterArray = $this->data['parameterArray'];
 
         $rows = MathUtility::forceIntegerInRange($parameterArray['fieldConf']['config']['rows'] ?: 10, 1, 40);
-        $this->setMode($parameterArray['fieldConf']['config']['format'] ?? T3editor::MODE_MIXED);
-        $this->ajaxSaveType = $parameterArray['fieldConf']['config']['ajaxSaveType'] ?? '';
+        $this->setMode(isset($parameterArray['fieldConf']['config']['format']) ? $parameterArray['fieldConf']['config']['format'] : T3editor::MODE_MIXED);
 
         $attributes = [];
         $attributes['rows'] = $rows;
@@ -127,10 +121,7 @@ class T3editorElement extends AbstractFormElement
             $parameterArray['itemFormElValue'],
             $attributeString,
             $this->data['tableName'] . ' > ' . $this->data['fieldName'],
-            [
-                'target' => 0,
-                'id' => (int)$this->data['databaseRow']['pageId']
-            ]
+            ['target' => 0]
         );
         $this->resultArray['additionalJavaScriptPost'][] = 'require(["TYPO3/CMS/T3editor/T3editor"], function(T3editor) {T3editor.findAndInitializeEditors();});';
 
@@ -198,7 +189,7 @@ class T3editorElement extends AbstractFormElement
         $attributes['data-instance-number'] =  $this->editorCounter;
         $attributes['data-editor-path'] =  $this->relExtPath;
         $attributes['data-codemirror-path'] =  $this->codemirrorPath;
-        $attributes['data-ajaxsavetype'] = htmlspecialchars($this->ajaxSaveType);
+        $attributes['data-ajaxsavetype'] = ''; // no ajax save in FormEngine at the moment
         $attributes['data-parserfile'] = $this->getParserfileByMode($this->mode);
         $attributes['data-stylesheet'] = $this->getStylesheetByMode($this->mode);
 
index d3eff40..f2bc3b0 100644 (file)
@@ -14,10 +14,8 @@ namespace TYPO3\CMS\T3editor\Hook;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Backend\Controller\File\FileController;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\T3editor\T3editor;
 
 /**
  * File edit hook for t3editor
@@ -25,7 +23,7 @@ use TYPO3\CMS\T3editor\T3editor;
 class FileEditHook
 {
     /**
-     * @var T3editor
+     * @var \TYPO3\CMS\T3editor\T3editor
      */
     protected $t3editor = null;
 
@@ -35,12 +33,12 @@ class FileEditHook
     protected $ajaxSaveType = 'TypoScriptTemplateInformationModuleFunctionController';
 
     /**
-     * @return T3editor
+     * @return \TYPO3\CMS\T3editor\T3editor
      */
     protected function getT3editor()
     {
         if ($this->t3editor === null) {
-            $this->t3editor = GeneralUtility::makeInstance(T3editor::class);
+            $this->t3editor = GeneralUtility::makeInstance(\TYPO3\CMS\T3editor\T3editor::class)->setAjaxSaveType($this->ajaxSaveType);
         }
         return $this->t3editor;
     }
@@ -52,29 +50,67 @@ class FileEditHook
      * @param array $parameters
      * @param \TYPO3\CMS\Backend\Controller\File\EditFileController $pObj
      */
-    public function preOutputProcessingHook(&$parameters, $pObj)
+    public function preOutputProcessingHook($parameters, $pObj)
     {
         $t3editor = $this->getT3editor();
         $t3editor->setModeByFile($parameters['target']);
         if (!$t3editor->getMode()) {
             return;
         }
-        $parameters['dataColumnDefinition']['config']['renderType'] = 't3editor';
-        $parameters['dataColumnDefinition']['config']['format'] = $t3editor->getMode();
-        $parameters['dataColumnDefinition']['config']['ajaxSaveType'] = $this->ajaxSaveType;
+        $t3editor->getJavascriptCode();
+        $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/T3editor/FileEdit');
+    }
+
+    /**
+     * Hook-function: inject t3editor JavaScript code before the page is compiled
+     * called in \TYPO3\CMS\Backend\Template\DocumentTemplate:startPage
+     *
+     * @see \TYPO3\CMS\Backend\Template\DocumentTemplate::startPage
+     */
+    public function preStartPageHook()
+    {
+        // @todo: this is a workaround. Ideally the document template holds the current request so we can match the route
+        // against the name of the route and not the GET parameter
+        if (GeneralUtility::_GET('route') === '/file/editcontent') {
+            $t3editor = $this->getT3editor();
+            $t3editor->getJavascriptCode();
+            $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/T3editor/FileEdit');
+        }
+    }
+
+    /**
+     * Hook-function:
+     * called in file_edit module
+     *
+     * @param array $parameters
+     * @param \TYPO3\CMS\Backend\Controller\File\EditFileController $pObj
+     */
+    public function postOutputProcessingHook($parameters, $pObj)
+    {
+        $t3editor = $this->getT3editor();
+        if (!$t3editor->getMode()) {
+            return;
+        }
+        $attributes = 'rows="30" ' . 'wrap="off"' . $pObj->doc->formWidth(48, true, 'width:98%;height:60%');
+        $title = $GLOBALS['LANG']->getLL('file') . ' ' . htmlspecialchars($pObj->target);
+        $outCode = $t3editor->getCodeEditor('file[editfile][0][data]', 'text-monospace enable-tab', '$1', $attributes, $title, [
+            'target' => (int)$pObj->target
+        ]);
+        $parameters['pageContent'] = preg_replace('/\\<textarea .*name="file\\[editfile\\]\\[0\\]\\[data\\]".*\\>([^\\<]*)\\<\\/textarea\\>/mi', $outCode, $parameters['pageContent']);
     }
 
     /**
      * @param array $parameters
-     * @param T3editor $pObj
+     * @param mixed $pObj
+     *
      * @return bool TRUE if successful
      */
     public function save($parameters, $pObj)
     {
         $savingsuccess = false;
         if ($parameters['type'] === $this->ajaxSaveType) {
-            /** @var FileController $tceFile */
-            $tceFile = GeneralUtility::makeInstance(FileController::class);
+            /** @var \TYPO3\CMS\Backend\Controller\File\FileController $tceFile */
+            $tceFile = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\File\FileController::class);
             $response = $tceFile->processAjaxRequest($parameters['request'], $parameters['response']);
             $result = json_decode((string)$response->getBody(), true);
             $savingsuccess = is_array($result) && $result['editfile'][0];
index 1d10310..c565e2b 100644 (file)
@@ -13,12 +13,6 @@ namespace TYPO3\CMS\T3editor\Hook;
  *
  * The TYPO3 project - inspiring people to share!
  */
-use TYPO3\CMS\Backend\Utility\BackendUtility;
-use TYPO3\CMS\Core\DataHandling\DataHandler;
-use TYPO3\CMS\Core\TypoScript\ExtendedTemplateService;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\T3editor\T3editor;
-use TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController;
 
 /**
  * Hook for tstemplate info
@@ -26,25 +20,63 @@ use TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionC
 class TypoScriptTemplateInfoHook
 {
     /**
+     * @var \TYPO3\CMS\T3editor\T3editor
+     */
+    protected $t3editor = null;
+
+    /**
      * @var string
      */
     protected $ajaxSaveType = 'TypoScriptTemplateInformationModuleFunctionController';
 
     /**
+     * @return \TYPO3\CMS\T3editor\T3editor
+     */
+    protected function getT3editor()
+    {
+        if ($this->t3editor == null) {
+            $this->t3editor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\T3editor\T3editor::class)->setMode(\TYPO3\CMS\T3editor\T3editor::MODE_TYPOSCRIPT)->setAjaxSaveType($this->ajaxSaveType);
+        }
+        return $this->t3editor;
+    }
+
+    /**
+     * Hook-function: inject t3editor JavaScript code before the page is compiled
+     * called in \TYPO3\CMS\Backend\Template\DocumentTemplate:startPage
+     *
+     * @return void
+     * @see \TYPO3\CMS\Backend\Template\DocumentTemplate::startPage
+     */
+    public function preStartPageHook()
+    {
+        // Enable editor in Template-Modul
+        if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('M') === 'web_ts') {
+            $t3editor = $this->getT3editor();
+            // Insert javascript code
+            $t3editor->getJavascriptCode();
+        }
+    }
+
+    /**
      * Hook-function:
      * called in typo3/sysext/tstemplate_info/Classes/Controller/TypoScriptTemplateInformationModuleFunctionController.php
      *
      * @param array $parameters
-     * @param TypoScriptTemplateInformationModuleFunctionController $pObj
+     * @param \TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController $pObj
      * @return void
      */
-    public function preOutputProcessingHook(&$parameters, $pObj)
+    public function postOutputProcessingHook($parameters, $pObj)
     {
-        foreach ($parameters['formData']['processedTca']['columns'] as $column => &$definition) {
-            if ($definition['config']['type'] === 'text') {
-                $definition['config']['renderType'] = 't3editor';
-                $definition['config']['format'] = 'typoscript';
-                $definition['config']['ajaxSaveType'] = $this->ajaxSaveType;
+        $t3editor = $this->getT3editor();
+        $t3editor->getJavascriptCode();
+        foreach (['constants', 'config'] as $type) {
+            if ($parameters['e'][$type]) {
+                $attributes = 'rows="' . (int)$parameters['numberOfRows'] . '" wrap="off" style="width:98%;height:60%"';
+                $title = $GLOBALS['LANG']->getLL('template') . ' ' . $parameters['tplRow']['title'] . $GLOBALS['LANG']->getLL('delimiter') . ' ' . $GLOBALS['LANG']->getLL($type);
+                $outCode = $t3editor->getCodeEditor('data[' . $type . ']', 'text-monospace enable-tab', '$1', $attributes, $title, [
+                    'pageId' => (int)$pObj->pObj->id
+                ]);
+                $parameters['theOutput'] = preg_replace('/\\<textarea name="data\\[' . $type . '\\]".*\\>([^\\<]*)\\<\\/textarea\\>/mi', $outCode, $parameters['theOutput']);
             }
         }
     }
@@ -52,24 +84,22 @@ class TypoScriptTemplateInfoHook
     /**
      * Process saving request like in class.tstemplateinfo.php (TCE processing)
      *
-     * @param array $parameters
-     * @param T3editor $pObj
      * @return bool TRUE if successful
      */
     public function save($parameters, $pObj)
     {
         $savingsuccess = false;
         if ($parameters['type'] == $this->ajaxSaveType) {
-            $pageId = (int)GeneralUtility::_GP('id');
+            $pageId = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('pageId');
             if (!is_numeric($pageId) || $pageId < 1) {
                 return false;
             }
             // If given use the requested template_uid
             // if not, use the first template-record on the page (in this case there should only be one record!)
-            $set = GeneralUtility::_GP('SET');
+            $set = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('SET');
             $template_uid = $set['templatesOnPage'] ?: 0;
             // Defined global here!
-            $tmpl = GeneralUtility::makeInstance(ExtendedTemplateService::class);
+            $tmpl = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\ExtendedTemplateService::class);
             $tmpl->init();
             // Get the first template record on the page, which might be hidden as well
             // (for instance the TypoScript constant editor is persisting to the first template)
@@ -78,23 +108,32 @@ class TypoScriptTemplateInfoHook
             if ($existTemplate) {
                 $saveId = $tplRow['_ORIG_uid'] ?: $tplRow['uid'];
                 // Update template ?
-                $POST = GeneralUtility::_POST();
+                $POST = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST();
                 if ($POST['submit']) {
                     // Set the data to be saved
                     $recData = [];
                     if (is_array($POST['data'])) {
-                        $recData = $POST['data'];
+                        foreach ($POST['data'] as $field => $val) {
+                            switch ($field) {
+                                case 'constants':
+                                case 'config':
+                                    // Replace Windows- and Mac linebreaks
+                                    $val = str_replace([CRLF, CR], LF, $val);
+                                    $recData['sys_template'][$saveId][$field] = $val;
+                                    break;
+                            }
+                        }
                     }
                     if (!empty($recData)) {
                         // process template row before saving
-                        $tstemplateinfo = GeneralUtility::makeInstance(TypoScriptTemplateInformationModuleFunctionController::class);
-                        /* @var $tstemplateinfo TypoScriptTemplateInformationModuleFunctionController */
+                        $tstemplateinfo = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController::class);
+                        /* @var $tstemplateinfo \TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController */
                         // load the MOD_SETTINGS in order to check if the includeTypoScriptFileContent is set
                         $tstemplateinfo->pObj = $pObj;
-                        $tstemplateinfo->pObj->MOD_SETTINGS = BackendUtility::getModuleData(['includeTypoScriptFileContent' => true], [], 'web_ts');
+                        $tstemplateinfo->pObj->MOD_SETTINGS = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData(['includeTypoScriptFileContent' => true], [], 'web_ts');
                         $recData['sys_template'][$saveId] = $tstemplateinfo->processTemplateRowBeforeSaving($recData['sys_template'][$saveId]);
                         // Create new tce-object
-                        $tce = GeneralUtility::makeInstance(DataHandler::class);
+                        $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
                         // Initialize
                         $tce->start($recData, []);
                         // Saved the stuff
index 8dc6249..4a78aed 100644 (file)
@@ -99,12 +99,13 @@ class T3editor implements \TYPO3\CMS\Core\SingletonInterface
      * Set mode by file
      *
      * @param string $file
-     * @return void
+     * @return string
      */
     public function setModeByFile($file)
     {
         $fileInfo = GeneralUtility::split_fileref($file);
-        $this->setModeByType($fileInfo['fileext']);
+        // @TODO: @FIXME: the method setModeByType returns void, so this method will never return a string
+        return $this->setModeByType($fileInfo['fileext']);
     }
 
     /**
index 25f42b8..4dfb77c 100644 (file)
@@ -3,10 +3,13 @@ defined('TYPO3_MODE') or die();
 
 if (TYPO3_MODE === 'BE') {
     // Register hooks for tstemplate module
-    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['preOutputProcessingHook'][] = \TYPO3\CMS\T3editor\Hook\TypoScriptTemplateInfoHook::class . '->preOutputProcessingHook';
-    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'][] = \TYPO3\CMS\T3editor\Hook\FileEditHook::class . '->preOutputProcessingHook';
+    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'][] = \TYPO3\CMS\T3editor\Hook\TypoScriptTemplateInfoHook::class . '->preStartPageHook';
+    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'][] = \TYPO3\CMS\T3editor\Hook\TypoScriptTemplateInfoHook::class . '->postOutputProcessingHook';
     $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/t3editor/classes/class.tx_t3editor.php']['ajaxSaveCode']['tx_tstemplateinfo'] = \TYPO3\CMS\T3editor\Hook\TypoScriptTemplateInfoHook::class . '->save';
     $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/t3editor/classes/class.tx_t3editor.php']['ajaxSaveCode']['file_edit'] = \TYPO3\CMS\T3editor\Hook\FileEditHook::class . '->save';
+    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'][] = \TYPO3\CMS\T3editor\Hook\FileEditHook::class . '->preStartPageHook';
+    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'][] = \TYPO3\CMS\T3editor\Hook\FileEditHook::class . '->preOutputProcessingHook';
+    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook'][] = \TYPO3\CMS\T3editor\Hook\FileEditHook::class . '->postOutputProcessingHook';
 }
 
 $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1433089350] = [
index 904e31d..72715c5 100644 (file)
@@ -14,8 +14,6 @@ namespace TYPO3\CMS\Tstemplate\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Backend\Form\FormResultCompiler;
-use TYPO3\CMS\Backend\Form\NodeFactory;
 use TYPO3\CMS\Backend\Module\AbstractFunctionModule;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\DataHandling\DataHandler;
@@ -213,7 +211,14 @@ class TypoScriptTemplateInformationModuleFunctionController extends AbstractFunc
                 $recData = [];
                 $alternativeFileName = [];
                 if (is_array($POST['data'])) {
-                    $recData = $POST['data'];
+                    foreach ($POST['data'] as $field => $val) {
+                        switch ($field) {
+                            case 'constants':
+                            case 'config':
+                                $recData['sys_template'][$saveId][$field] = $val;
+                            break;
+                        }
+                    }
                 }
                 if (!empty($recData)) {
                     $recData['sys_template'][$saveId] = $this->processTemplateRowBeforeSaving($recData['sys_template'][$saveId]);
@@ -253,96 +258,31 @@ class TypoScriptTemplateInformationModuleFunctionController extends AbstractFunc
             if ($manyTemplatesMenu) {
                 $theOutput .= '<div>' . $manyTemplatesMenu . '</div>';
             }
+            $theOutput .= '<div style="padding-top: 10px;"></div>';
             $numberOfRows = 35;
             // If abort pressed, nothing should be edited:
             if (isset($POST['_saveandclosedok'])) {
                 unset($e);
             }
-            $textareaFieldConfig = [
-                'config' => [
-                    'type' => 'text',
-                    'cols' => 48,
-                    'wrap' => 'OFF',
-                    'softref' => 'email[subst],url[subst]'
-                ],
-                'defaultExtras' => 'fixed-font: enable-tab'
-            ];
-            $formData = [
-                'databaseRow' => [
-                    'uid' => $tplRow['uid'],
-                    'pageId' => $this->pObj->id
-                ],
-                'tableName' => 'sys_template',
-                'processedTca' => [
-                    'columns' => [
-                        'pageId' => [
-                            'config' => [
-                                'type' => 'passthrough'
-                            ]
-                        ]
-                    ],
-                    'types' => [
-                        1 => [
-                            'showitem' => '',
-                        ],
-                    ],
-                ],
-                'recordTypeValue' => 1,
-                'inlineStructure' => [],
-                'renderType' => 'fullRecordContainer'
-            ];
             if (isset($e['constants'])) {
-                $formData['databaseRow']['constants'] = $tplRow['constants'];
-                $formData['processedTca']['columns']['constants'] = array_merge_recursive(
-                    $textareaFieldConfig,
-                    [
-                        'label' => $lang->getLL('constants'),
-                        'config' => [
-                            'rows' => min($numberOfRows, substr_count($tplRow['constants'], LF))
-                        ]
-                    ]
-                );
+                $outCode = '<textarea name="data[constants]" rows="' . $numberOfRows . '" wrap="off" class="text-monospace enable-tab" style="width:98%;height:70%" class="text-monospace">' . htmlspecialchars($tplRow['constants']) . '</textarea>';
+                $outCode .= '<input type="hidden" name="e[constants]" value="1">';
+                // Display "Include TypoScript file content?" checkbox
+                $outCode .= '<div class="checkbox"><label for="checkIncludeTypoScriptFileContent">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[includeTypoScriptFileContent]', $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'], '', '&e[constants]=1', 'id="checkIncludeTypoScriptFileContent"');
+                $outCode .= $lang->getLL('includeTypoScriptFileContent') . '</label></div><br />';
+                $theOutput .= '<div style="padding-top: 15px;"></div>';
+                $theOutput .= '<h3>' . htmlspecialchars($lang->getLL('constants')) . '</h3>';
+                $theOutput .= $outCode;
             }
             if (isset($e['config'])) {
-                $formData['databaseRow']['config'] = $tplRow['config'];
-                $formData['processedTca']['columns']['config'] = array_merge_recursive(
-                    $textareaFieldConfig,
-                    [
-                        'label' => $lang->getLL('setup'),
-                        'config' => [
-                            'rows' => min($numberOfRows, substr_count($tplRow['config'], LF))
-                        ]
-                    ]
-                );
-            }
-
-            // Hook before compiling the output
-            if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['preOutputProcessingHook'])) {
-                $preOutputProcessingHook = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['preOutputProcessingHook'];
-                if (is_array($preOutputProcessingHook)) {
-                    $hookParameters = [
-                        'formData' => &$formData
-                    ];
-                    foreach ($preOutputProcessingHook as $hookFunction) {
-                        GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
-                    }
-                }
-            }
-
-            if (!empty($formData['processedTca']['columns'])) {
-                $formData['processedTca']['types'][1]['showitem'] = implode(',', array_keys($formData['processedTca']['columns']));
-
-                $resultArray = GeneralUtility::makeInstance(NodeFactory::class)->create($formData)->render();
-                $formResultCompiler = GeneralUtility::makeInstance(FormResultCompiler::class);
-                $formResultCompiler->mergeResult($resultArray);
-
-                $theOutput .= $formResultCompiler->JStop()
-                    . $formResultCompiler->printNeededJSFunctions()
-                    . $resultArray['html'];
-                $theOutput .= '<div class="checkbox"><label for="checkIncludeTypoScriptFileContent">' . BackendUtility::getFuncCheck($this->pObj->id,
-                    'SET[includeTypoScriptFileContent]', $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'],
-                    '', GeneralUtility::implodeArrayForUrl('', ['e' => $this->pObj->e]), 'id="checkIncludeTypoScriptFileContent"');
-                $theOutput .= $lang->getLL('includeTypoScriptFileContent') . '</label></div><br />';
+                $outCode = '<textarea name="data[config]" rows="' . $numberOfRows . '" wrap="off" class="text-monospace enable-tab" style="width:98%;height:70%" class="text-monospace">' . htmlspecialchars($tplRow['config']) . '</textarea>';
+                $outCode .= '<input type="hidden" name="e[config]" value="1">';
+                // Display "Include TypoScript file content?" checkbox
+                $outCode .= '<div class="checkbox"><label for="checkIncludeTypoScriptFileContent">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[includeTypoScriptFileContent]', $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'], '', '&e[config]=1', 'id="checkIncludeTypoScriptFileContent"');
+                $outCode .= $lang->getLL('includeTypoScriptFileContent') . '</label></div><br />';
+                $theOutput .= '<div style="padding-top: 15px;"></div>';
+                $theOutput .= '<h3>' . htmlspecialchars($lang->getLL('setup')) . '</h3>';
+                $theOutput .= $outCode;
             }
 
             // Processing:
index 4bdc4da..84a3b31 100644 (file)
@@ -168,8 +168,7 @@ class TypoScriptTemplateModuleController extends BaseScriptClass
         if ($this->id && $this->access) {
             $urlParameters = [
                 'id' => $this->id,
-                'template' => 'all',
-                'e' => $this->e
+                'template' => 'all'
             ];
             $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);