[BUGFIX] Save and close not working in file edit 80/41880/2
authorWouter Wolters <typo3@wouterwolters.nl>
Thu, 23 Jul 2015 12:51:29 +0000 (14:51 +0200)
committerSusanne Moog <typo3@susannemoog.de>
Thu, 23 Jul 2015 17:52:43 +0000 (19:52 +0200)
File edit for example a CSS file can't save and close.
The onclick event handler was removed completely.
This is wrong for save and close.

A wrong htmlspecialchars created a wrong URL for the redirect.

Both issues are solved with this commit.

Resolves: #68487
Releases: master
Change-Id: I0dfa75733fcd1978378ad4503d9d99b3d4b33110
Reviewed-on: http://review.typo3.org/41880
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
typo3/sysext/backend/Classes/Controller/File/EditFileController.php
typo3/sysext/t3editor/Resources/Public/JavaScript/FileEdit.js

index c37dae6..6856ffc 100644 (file)
@@ -227,7 +227,7 @@ class EditFileController {
                $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>';
                // Save and Close button
                $theIcon = IconUtility::getSpriteIcon('actions-document-save-close');
-               $buttons['SAVE_CLOSE'] = '<a href="#" onclick="document.editform.redirect.value=' . GeneralUtility::quoteJSvalue(htmlspecialchars($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="#" 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 = IconUtility::getSpriteIcon('actions-document-close');
                $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 60bb426..42745c3 100644 (file)
@@ -20,7 +20,14 @@ define('TYPO3/CMS/T3editor/FileEdit', ['jquery', 'TYPO3/CMS/T3editor/T3editor'],
                $('.t3-icon-document-save, .t3-icon-document-save-close').each(function() {
                        var $link = $(this).parent('a');
                        if ($link) {
-                               $link.removeAttr('onclick');
+
+                               // 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();
@@ -32,6 +39,7 @@ define('TYPO3/CMS/T3editor/FileEdit', ['jquery', 'TYPO3/CMS/T3editor/T3editor'],
                                                T3editor.saveFunction(T3editor.instances[0]);
                                        } else {
                                                T3editor.updateTextarea(T3editor.instances[0]);
+                                               document.editform.submit();
                                        }
                                        return false;
                                });