[BUGFIX] Evaluator in JS fails with namespaces 17/25317/2
authorStefan Aebischer <aebischer@pixtron.ch>
Mon, 28 Oct 2013 22:07:09 +0000 (23:07 +0100)
committerMarkus Klein <klein.t3@mfc-linz.at>
Tue, 12 Nov 2013 15:16:06 +0000 (16:16 +0100)
If you add an own evaluator, you have to insert the
class inclusive namespaces. JavaScript in TYPO3
backend fails to use the correct class set in
namespaces.

Resolves: #52904
Releases: 6.2,6.1,6.0
Change-Id: I356a2a7ff169462307506c64234741e6a690f8e2
Reviewed-on: https://review.typo3.org/25317
Reviewed-by: Markus Klein
Tested-by: Markus Klein
t3lib/jsfunc.evalfield.js
typo3/sysext/backend/Classes/Form/FormEngine.php

index 0666c54..99bc0dd 100644 (file)
@@ -62,10 +62,8 @@ function evalFunc_evalObjValue(FObj,value) {
        var theEvalType = (FObj.evallist) ? this.split(evallist, ",", index) : false;
        var newValue=value;
        while (theEvalType) {
-               if (theEvalType.slice(0, 3) == 'tx_' || theEvalType.slice(0, 3) == 'Tx_') {
-                       if(typeof window[theEvalType] == 'function') {
-                               newValue = window[theEvalType](newValue);       // variable function call, calling functions like tx_myext_myeval(value)
-                       }
+               if (TBE_EDITOR.customEvalFunctions[theEvalType] && typeof TBE_EDITOR.customEvalFunctions[theEvalType] == 'function') {
+                       newValue = TBE_EDITOR.customEvalFunctions[theEvalType](newValue);
                } else {
                        newValue = evalFunc.input(theEvalType, newValue);
                }
@@ -527,4 +525,4 @@ function evalFunc_convertClientTimestampToUTC(timestamp, timeonly) {
                        // seconds since the "unix-epoch"
                return this.getTimestamp(timeObj);
        }
-}
\ No newline at end of file
+}
index 4ab9454..433f6d8 100644 (file)
@@ -1367,8 +1367,7 @@ class FormEngine {
                        $evalObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData] . ':&' . $evalData);
                        if (is_object($evalObj) && method_exists($evalObj, 'returnFieldJS')) {
                                $this->extJSCODE .= '
-
-function ' . $evalData . '(value) {
+TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
 ' . $evalObj->returnFieldJS() . '
 }
 ';
@@ -5473,6 +5472,9 @@ function ' . $evalData . '(value) {
                        TBE_EDITOR.labels.onChangeAlert = ' . $GLOBALS['LANG']->JScharCode($this->getLL('m_onChangeAlert')) . ';
                        evalFunc.USmode = ' . ($GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? '1' : '0') . ';
                        TBE_EDITOR.backend_interface = "' . $GLOBALS['BE_USER']->uc['interfaceSetup'] . '";
+
+                       TBE_EDITOR.customEvalFunctions = {};
+
                        ';
                }
                // Add JS required for inline fields