[BUGFIX] Make t3editor save data again 86/43486/6
authorWouter Wolters <typo3@wouterwolters.nl>
Tue, 22 Sep 2015 20:45:50 +0000 (22:45 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Wed, 23 Sep 2015 13:09:47 +0000 (15:09 +0200)
Several save buttons don't work anymore after icon changes

Resolves: #70013
Releases: master
Change-Id: Id3abb129208a7a9f2ea68521ed0b6bbb5abd8ef4
Reviewed-on: http://review.typo3.org/43486
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/backend/Classes/Controller/File/EditFileController.php
typo3/sysext/t3editor/Resources/Public/JavaScript/FileEdit.js
typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateConstantEditorModuleFunctionController.php
typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateInformationModuleFunctionController.php
typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateModuleController.php

index 706702c..3b7deeb 100644 (file)
@@ -247,10 +247,10 @@ class EditFileController {
                $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'file_edit');
                // Save button
                $theIcon = $this->iconFactory->getIcon('actions-document-save', Icon::SIZE_SMALL);
-               $buttons['SAVE'] = '<a href="#" onclick="document.editform.submit();" title="' . $lang->makeEntities($lang->sL('LLL:EXT:lang/locallang_core.xlf:file_edit.php.submit', TRUE)) . '">' . $theIcon . '</a>';
+               $buttons['SAVE'] = '<a href="#" class="t3js-fileedit-save" onclick="document.editform.submit();" title="' . $lang->makeEntities($lang->sL('LLL:EXT:lang/locallang_core.xlf:file_edit.php.submit', TRUE)) . '">' . $theIcon . '</a>';
                // Save and Close button
                $theIcon = $this->iconFactory->getIcon('actions-document-save-close', Icon::SIZE_SMALL);
-               $buttons['SAVE_CLOSE'] = '<a href="#" onclick="document.editform.redirect.value=' . htmlspecialchars(GeneralUtility::quoteJSvalue($this->returnUrl)) . '; document.editform.submit();" title="' . $lang->makeEntities($lang->sL('LLL:EXT:lang/locallang_core.xlf:file_edit.php.saveAndClose', TRUE)) . '">' . $theIcon . '</a>';
+               $buttons['SAVE_CLOSE'] = '<a href="#" class="t3js-fileedit-save-close" onclick="document.editform.redirect.value=' . htmlspecialchars(GeneralUtility::quoteJSvalue($this->returnUrl)) . '; document.editform.submit();" title="' . $lang->makeEntities($lang->sL('LLL:EXT:lang/locallang_core.xlf:file_edit.php.saveAndClose', TRUE)) . '">' . $theIcon . '</a>';
                // Cancel button
                $theIcon = $this->iconFactory->getIcon('actions-document-close', Icon::SIZE_SMALL);
                $buttons['CANCEL'] = '<a href="#" onclick="backToList(); return false;" title="' . $lang->makeEntities($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.cancel', TRUE)) . '">' . $theIcon . '</a>';
index 42745c3..5cb234d 100644 (file)
 define('TYPO3/CMS/T3editor/FileEdit', ['jquery', 'TYPO3/CMS/T3editor/T3editor'], function ($, T3editor) {
 
        $(document).ready(function() {
-               $('.t3-icon-document-save, .t3-icon-document-save-close').each(function() {
-                       var $link = $(this).parent('a');
-                       if ($link) {
-
-                               // Only remove onclick for save, save and close needs to have document.editform.submit to be removed
-                               if ($link.children('span').hasClass('t3-icon-document-save')) {
-                                       $link.removeAttr('onclick');
-                               } else {
-                                       var onClick = $link.attr('onclick');
-                                       $link.attr('onclick', onClick.replace('document.editform.submit();', ''));
-                               }
-
-                               $link.on('click', function(e) {
-                                       e.preventDefault();
-                                       if (!T3editor || !T3editor.instances[0]) {
-                                               document.editform.submit();
-                                               return false;
-                                       }
-                                       if ($(this).children('span').hasClass('t3-icon-document-save')) {
-                                               T3editor.saveFunction(T3editor.instances[0]);
-                                       } else {
-                                               T3editor.updateTextarea(T3editor.instances[0]);
-                                               document.editform.submit();
-                                       }
-                                       return false;
-                               });
+
+               // Remove document.editform.submit from save and close onclick
+               // Form will be submitted by the new on click handler
+               var onClick = $('.t3js-fileedit-save-close').attr('onclick');
+               $('.t3js-fileedit-save-close').attr('onclick', onClick.replace('document.editform.submit();', ''));
+
+               // Remove onclick for save icon, saving is done by an AJAX-call
+               $('.t3js-fileedit-save').removeAttr('onclick');
+
+               $('.t3js-fileedit-save').on('click', function(e) {
+                       e.preventDefault();
+
+                       if (!T3editor || !T3editor.instances[0]) {
+                               document.editform.submit();
+                               return false;
+                       }
+
+                       T3editor.saveFunction(T3editor.instances[0]);
+                       return false;
+               });
+
+               $('.t3js-fileedit-save-close').on('click', function(e) {
+                       e.preventDefault();
+
+                       if (!T3editor || !T3editor.instances[0]) {
+                               document.editform.submit();
+                               return false;
                        }
+                       T3editor.updateTextarea(T3editor.instances[0]);
+                       document.editform.submit();
+                       return false;
                });
+
        });
 });
index c3c54ce..7b01edf 100644 (file)
@@ -125,7 +125,7 @@ class TypoScriptTemplateConstantEditorModuleFunctionController extends AbstractF
                        $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Tstemplate/ConstantEditor');
                        $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
                        // Update template ?
-                       if (GeneralUtility::_POST('submit') ) {
+                       if (GeneralUtility::_POST('_savedok') ) {
                                $templateService->changed = 0;
                                $templateService->ext_procesInput(GeneralUtility::_POST(), array(), $theConstants, $tplRow);
                                if ($templateService->changed) {
index 78f7459..a503371 100644 (file)
@@ -200,8 +200,8 @@ class TypoScriptTemplateInformationModuleFunctionController extends AbstractFunc
                        // Update template ?
                        $POST = GeneralUtility::_POST();
                        if (
-                               isset($POST['submit'])
-                               || isset($POST['saveclose'])
+                               isset($POST['_savedok'])
+                               || isset($POST['_saveandclosedok'])
                        ) {
                                // Set the data to be saved
                                $recData = array();
@@ -259,7 +259,7 @@ class TypoScriptTemplateInformationModuleFunctionController extends AbstractFunc
                        $theOutput .= $this->pObj->doc->spacer(10);
                        $numberOfRows = 35;
                        // If abort pressed, nothing should be edited:
-                       if (isset($POST['saveclose'])) {
+                       if (isset($POST['_saveandclosedok'])) {
                                unset($e);
                        }
                        if (isset($e['constants'])) {
index 5fb34f0..bfa3af1 100755 (executable)
@@ -314,15 +314,15 @@ class TypoScriptTemplateModuleController extends BaseScriptClass {
                                        'createExtension' => 'new'
                                );
                                $buttons['new'] = '<a href="' . htmlspecialchars(BackendUtility::getModuleUrl('web_ts', $urlParameters)) . '" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:db_new.php.pagetitle', TRUE) . '">' . $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL) . '</a>';
-                               if (!empty($this->e) && !GeneralUtility::_POST('saveclose')) {
+                               if (!empty($this->e) && !GeneralUtility::_POST('_saveandclosedok')) {
                                        // no NEW-button while edit
                                        $buttons['new'] = '';
                                        // SAVE button
-                                       $buttons['save'] = '<button type="submit" class="c-inputButton" name="submit" value="1" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '">'
+                                       $buttons['save'] = '<button type="submit" class="c-inputButton" name="_savedok" value="1" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '">'
                                                . $this->iconFactory->getIcon('actions-document-save', Icon::SIZE_SMALL)
                                                . '</button>';
                                        // SAVE AND CLOSE button
-                                       $buttons['save_close'] = '<button type="submit" class="c-inputButton" name="saveclose" value="1" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc', TRUE) . '">'
+                                       $buttons['save_close'] = '<button type="submit" class="c-inputButton" name="_saveandclosedok" value="1" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc', TRUE) . '">'
                                                . $this->iconFactory->getIcon('actions-document-save-close', Icon::SIZE_SMALL)
                                                . '</button>';
                                        // CLOSE button
@@ -331,7 +331,7 @@ class TypoScriptTemplateModuleController extends BaseScriptClass {
                                }
                        } elseif ($this->extClassConf['name'] === TypoScriptTemplateConstantEditorModuleFunctionController::class && !empty($this->MOD_MENU['constant_editor_cat'])) {
                                // SAVE button
-                               $buttons['save'] = '<button class="c-inputButton" name="submit" value="1" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '">'
+                               $buttons['save'] = '<button class="c-inputButton" name="_savedok" value="1" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '">'
                                        . $this->iconFactory->getIcon('actions-document-save', Icon::SIZE_SMALL)
                                        . '</button>';
                        } elseif ($this->extClassConf['name'] === TypoScriptTemplateObjectBrowserModuleFunctionController::class) {