[BUGFIX] T3editor: Make errors/exceptions show correctly 99/24999/3
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Thu, 24 Oct 2013 23:26:02 +0000 (01:26 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Wed, 30 Oct 2013 22:23:01 +0000 (23:23 +0100)
* Display T3editor.lang.errorWhileSaving in a flashmessage.
* Pass exception-messages through the AJAX-call and display
  them in the flashmessage as well.

Change-Id: Ia743b5a3fc9a7b272854920bcc0e9d081d4822ef
Resolves: #53115
Releases: 6.2, 6.1, 6.0, 4.5
Reviewed-on: https://review.typo3.org/24999
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Stefan Neufeind
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/t3editor/Classes/T3Editor.php
typo3/sysext/t3editor/res/jslib/t3editor.js

index de8a81d..03cb328 100644 (file)
@@ -405,15 +405,20 @@ class T3Editor implements \TYPO3\CMS\Core\SingletonInterface {
                        $ajaxObj->setContentFormat('json');
                        $codeType = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('t3editor_savetype');
                        $savingsuccess = FALSE;
                        $ajaxObj->setContentFormat('json');
                        $codeType = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('t3editor_savetype');
                        $savingsuccess = FALSE;
-                       if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/t3editor/classes/class.tx_t3editor.php']['ajaxSaveCode'])) {
-                               $_params = array(
-                                       'pObj' => &$this,
-                                       'type' => $codeType,
-                                       'ajaxObj' => &$ajaxObj
-                               );
-                               foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/t3editor/classes/class.tx_t3editor.php']['ajaxSaveCode'] as $key => $_funcRef) {
-                                       $savingsuccess = \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($_funcRef, $_params, $this) || $savingsuccess;
+                       try {
+                               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/t3editor/classes/class.tx_t3editor.php']['ajaxSaveCode'])) {
+                                       $_params = array(
+                                               'pObj' => &$this,
+                                               'type' => $codeType,
+                                               'ajaxObj' => &$ajaxObj
+                                       );
+                                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/t3editor/classes/class.tx_t3editor.php']['ajaxSaveCode'] as $key => $_funcRef) {
+                                               $savingsuccess = \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($_funcRef, $_params, $this) || $savingsuccess;
+                                       }
                                }
                                }
+                       } catch (\Exception $e) {
+                               $ajaxObj->setContent(array('result' => FALSE, 'exceptionMessage' => htmlspecialchars($e->getMessage()), 'exceptionCode' => $e->getCode()));
+                               return;
                        }
                        $ajaxObj->setContent(array('result' => $savingsuccess));
                }
                        }
                        $ajaxObj->setContent(array('result' => $savingsuccess));
                }
index d72ab12..e589b30 100644 (file)
@@ -181,11 +181,15 @@ T3editor.prototype = {
                },
 
                // callback if saving was successful
                },
 
                // callback if saving was successful
-               saveFunctionComplete: function(wasSuccessful) {
+               saveFunctionComplete: function(wasSuccessful,returnedData) {
                        if (wasSuccessful) {
                                this.textModified = false;
                        } else {
                        if (wasSuccessful) {
                                this.textModified = false;
                        } else {
-                               alert(T3editor.lang.errorWhileSaving);
+                               if (typeof returnedData.exceptionMessage != 'undefined') {
+                                       TYPO3.Flashmessage.display(4, T3editor.lang.errorWhileSaving[0]['target'], returnedData.exceptionMessage);
+                               } else {
+                                       TYPO3.Flashmessage.display(4, T3editor.lang.errorWhileSaving[0]['target']);
+                               }
                        }
                        this.modalOverlay.hide();
                },
                        }
                        this.modalOverlay.hide();
                },
@@ -335,7 +339,7 @@ if (!Prototype.Browser.MobileSafari) {
                                                                onComplete: function(ajaxrequest) {
                                                                        var wasSuccessful = ajaxrequest.status == 200
                                                                        && ajaxrequest.headerJSON.result == true
                                                                onComplete: function(ajaxrequest) {
                                                                        var wasSuccessful = ajaxrequest.status == 200
                                                                        && ajaxrequest.headerJSON.result == true
-                                                                       event.memo.t3editor.saveFunctionComplete(wasSuccessful);
+                                                                       event.memo.t3editor.saveFunctionComplete(wasSuccessful,ajaxrequest.headerJSON);
                                                                }
                                                        }
                                                );
                                                                }
                                                        }
                                                );