From bd023081e677d731b9c94f2c213df06b16d96210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20St=C3=B6ckel?= Date: Thu, 10 Jun 2010 10:33:00 +0000 Subject: [PATCH] Fixed handling of json requests using etemplate.process_exec and fixes in the json encoding of hierarchical values --- phpgwapi/inc/class.egw_json.inc.php | 13 ++++++++----- phpgwapi/js/egw_json.js | 7 ++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/phpgwapi/inc/class.egw_json.inc.php b/phpgwapi/inc/class.egw_json.inc.php index 323c7d4a93..595352d4bb 100644 --- a/phpgwapi/inc/class.egw_json.inc.php +++ b/phpgwapi/inc/class.egw_json.inc.php @@ -51,7 +51,6 @@ class egw_json_request $parameters = $request['parameters']; /*$parameters = array_stripslashes($request['parameters']);*/ } - //Call the supplied callback function along with the menuaction and the passed parameters $this->handleRequest($menuaction, $parameters); } @@ -82,15 +81,15 @@ class egw_json_request switch($handler) { case '/etemplate/process_exec': - $menuaction = $appName.'.'.$className.'.'.$functionName; + $_GET['menuaction'] = $appName.'.'.$className.'.'.$functionName; $appName = $className = 'etemplate'; $functionName = 'process_exec'; $menuaction = 'etemplate.etemplate.process_exec'; $parameters = array( - $argList[0]['etemplate_exec_id'], - $argList[0]['submit_button'], - $argList[0], + $parameters[0]['etemplate_exec_id'], + $parameters[0]['submit_button'], + $parameters[0], 'xajaxResponse', ); //error_log("xajax_doXMLHTTP() /etemplate/process_exec handler: arg0='$menuaction', menuaction='$_GET[menuaction]'"); @@ -127,6 +126,10 @@ class egw_json_request $parameters = translation::convert($parameters, 'utf-8'); +// error_log(print_r($parameters, true)); + +// _debug_array($parameters); + call_user_func_array(array($ajaxClass, $functionName), $parameters); } } diff --git a/phpgwapi/js/egw_json.js b/phpgwapi/js/egw_json.js index e306d42403..e58e7fb23a 100644 --- a/phpgwapi/js/egw_json.js +++ b/phpgwapi/js/egw_json.js @@ -320,10 +320,11 @@ function _egw_json_getFormValue(serialized, child) } var name = child.name; - var values = new Array; + var values = null; if ('select-multiple' == child.type) { + values = new Array; for (var j = 0; j < child.length; ++j) { var option = child.options[j]; @@ -344,7 +345,7 @@ function _egw_json_getFormValue(serialized, child) var k = n.substr(0, n.indexOf('[')); var a = n.substr(n.indexOf('[')); if (typeof serialized[k] == 'undefined') - serialized[k] = []; + serialized[k] = new Object; var p = serialized; // pointer reset while (a.length != 0) { var sa = a.substr(0, a.indexOf(']')+1); @@ -364,7 +365,7 @@ function _egw_json_getFormValue(serialized, child) } } if (typeof p[k] == 'undefined') - p[k] = []; + p[k] = new Object; } p[k] = values; } else {