mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 00:58:55 +01:00
- Added "beforeSubmit" callback handler to the PHP json class
- Added "clientCall" and "clientSetOption" function to the base etemplate widget class - Got the client side HTML area widget work with the new functions described above
This commit is contained in:
parent
04983df258
commit
47a7fc9337
@ -145,6 +145,11 @@ class egw_json_response
|
||||
*/
|
||||
private $hasData = false;
|
||||
|
||||
/**
|
||||
* Array containing all beforeSendData callbacks
|
||||
*/
|
||||
protected $beforeSendDataProcs = array();
|
||||
|
||||
/**
|
||||
* Holds the actual response data which is then encoded to JSON
|
||||
* once the "getJSON" function is called
|
||||
@ -190,7 +195,12 @@ class egw_json_response
|
||||
{
|
||||
$inst = self::get();
|
||||
|
||||
//Call each attached before send data proc
|
||||
foreach ($inst->beforeSendDataProcs as $proc)
|
||||
call_user_func_array($proc['proc'], $proc['params']);
|
||||
|
||||
$inst->sendHeader();
|
||||
|
||||
echo $inst->getJSON();
|
||||
}
|
||||
|
||||
@ -390,6 +400,28 @@ class egw_json_response
|
||||
return json_encode($res); //PHP5.3+, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function which can be used to add an event listener callback function to
|
||||
* the "beforeSendData" callback. This callback might be used to add a response
|
||||
* which always has to be added after all other responses.
|
||||
* @param callback Callback function or method which should be called before the response gets sent
|
||||
* @param mixed n Optional parameters which get passed to the callback function.
|
||||
*/
|
||||
public function addBeforeSendDataCallback($proc)
|
||||
{
|
||||
//Get the current instance
|
||||
$inst = self::get();
|
||||
|
||||
//Get all parameters passed to the function and delete the first one
|
||||
$params = func_get_args();
|
||||
array_shift($params);
|
||||
|
||||
$inst->beforeSendDataProcs[] = array(
|
||||
'proc' => $proc,
|
||||
'params' => $params
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
|
@ -187,7 +187,7 @@ egw_json_request.prototype.sendRequest = function(_async, _callback, _sender)
|
||||
"parameters": this.parameters
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
//Send the request via the jquery AJAX interface to the server
|
||||
$.ajax({url: this.url + '?menuaction=' + this.menuaction,
|
||||
|
Loading…
Reference in New Issue
Block a user