mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-23 14:28:45 +01:00
Synchronized jdots with trunk
This commit is contained in:
parent
78c663b084
commit
b99d1822d2
@ -507,6 +507,35 @@ abstract class egw_framework
|
||||
return egw::link($index,$GLOBALS['egw_info']['flags']['params'][$app]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used internally to store unserialized value of $GLOBALS['egw_info']['user']['preferences']['common']['user_apporder']
|
||||
*/
|
||||
private static $user_apporder = array();
|
||||
|
||||
/**
|
||||
* Internal usort callback function used to sort an array according to the
|
||||
* user sort order
|
||||
*/
|
||||
private static function _sort_apparray($a, $b)
|
||||
{
|
||||
//Unserialize the user_apporder array
|
||||
$arr = self::$user_apporder;
|
||||
|
||||
$ind_a = isset($arr[$a['name']]) ? $arr[$a['name']] : null;
|
||||
$ind_b = isset($arr[$b['name']]) ? $arr[$b['name']] : null;
|
||||
|
||||
if ($ind_a == $ind_b)
|
||||
return 0;
|
||||
|
||||
if ($ind_a == null)
|
||||
return -1;
|
||||
|
||||
if ($ind_b == null)
|
||||
return 1;
|
||||
|
||||
return $ind_a > $ind_b ? 1 : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare an array with apps used to render the navbar
|
||||
*
|
||||
@ -578,6 +607,16 @@ abstract class egw_framework
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Sort the applications accordingly to their user sort setting
|
||||
if ($GLOBALS['egw_info']['user']['preferences']['common']['user_apporder'])
|
||||
{
|
||||
//Sort the application array using the user_apporder array as sort index
|
||||
self::$user_apporder =
|
||||
unserialize($GLOBALS['egw_info']['user']['preferences']['common']['user_apporder']);
|
||||
uasort($apps, 'egw_framework::_sort_apparray');
|
||||
}
|
||||
|
||||
if ($GLOBALS['egw_info']['flags']['currentapp'] == 'preferences' || $GLOBALS['egw_info']['flags']['currentapp'] == 'about')
|
||||
{
|
||||
$app = $app_title = 'EGroupware';
|
||||
|
@ -4,24 +4,23 @@
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package api$request['menuaction'], $parameters
|
||||
* @package api
|
||||
* @subpackage ajax
|
||||
* @author Andreas Stoeckel <as@stylite.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class handling JSON requests to the server
|
||||
* Class handling JSON requests to the server
|
||||
*/
|
||||
class egw_json_request
|
||||
{
|
||||
/**
|
||||
* Parses the raw input data supplied with the input_data parameter and calls the menuaction
|
||||
* passing all parameters supplied in the request to it.
|
||||
*
|
||||
*
|
||||
* @param string menuaction to call
|
||||
* @param string $input_data is the RAW input data as it was received from the client
|
||||
* @returns NULL if parsing the request failed, or the result of the callback function if the request has been successfully decoded.
|
||||
*/
|
||||
public function parseRequest($menuaction, $input_data)
|
||||
{
|
||||
@ -45,23 +44,22 @@ class egw_json_request
|
||||
if (isset($json['request']))
|
||||
{
|
||||
$request = $json['request'];
|
||||
|
||||
|
||||
//Check whether any parameters were supplied along with the request
|
||||
if (isset($request['parameters']))
|
||||
{
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request handler
|
||||
*
|
||||
*
|
||||
* @param string $menuaction
|
||||
* @param array $parameters
|
||||
*/
|
||||
@ -121,15 +119,11 @@ class egw_json_request
|
||||
}
|
||||
else
|
||||
{
|
||||
$ajaxClass = CreateObject($appName.'.'.$className);
|
||||
$ajaxClass = CreateObject($appName.'.'.$className);
|
||||
}
|
||||
|
||||
|
||||
$parameters = translation::convert($parameters, 'utf-8');
|
||||
|
||||
// error_log(print_r($parameters, true));
|
||||
|
||||
// _debug_array($parameters);
|
||||
|
||||
call_user_func_array(array($ajaxClass, $functionName), $parameters);
|
||||
}
|
||||
}
|
||||
@ -140,31 +134,31 @@ class egw_json_request
|
||||
class egw_json_response
|
||||
{
|
||||
/**
|
||||
* A response can only contain one generic data part.
|
||||
* A response can only contain one generic data part.
|
||||
* This variable is used to store, whether a data part had already been added to the response.
|
||||
*
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $hasData = false;
|
||||
|
||||
/**
|
||||
* Holds the actual response data which is then encoded to JSON
|
||||
* Holds the actual response data which is then encoded to JSON
|
||||
* once the "getJSON" function is called
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $responseArray = array();
|
||||
|
||||
/**
|
||||
* Holding instance of class for singelton egw_json_response::get()
|
||||
*
|
||||
*
|
||||
* @var egw_json_response
|
||||
*/
|
||||
private static $response = null;
|
||||
|
||||
/**
|
||||
* Singelton for class
|
||||
*
|
||||
*
|
||||
* @return egw_json_response
|
||||
*/
|
||||
public static function get()
|
||||
@ -191,9 +185,10 @@ class egw_json_response
|
||||
public function sendResult()
|
||||
{
|
||||
$this->sendHeader();
|
||||
|
||||
echo $this->getJSON();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* xAjax compatibility function
|
||||
*/
|
||||
@ -214,10 +209,10 @@ class egw_json_response
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a "data" response to the json response.
|
||||
*
|
||||
* Adds a "data" response to the json response.
|
||||
*
|
||||
* This function may only be called once for a single JSON response object.
|
||||
*
|
||||
*
|
||||
* @param object|array|string $data can be of any data type and will be added JSON Encoded to your response.
|
||||
*/
|
||||
public function data($data)
|
||||
@ -235,10 +230,10 @@ class egw_json_response
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an "alert" to the response which can be handeled on the client side.
|
||||
*
|
||||
* Adds an "alert" to the response which can be handeled on the client side.
|
||||
*
|
||||
* The default implementation simply displays the text supplied here with the JavaScript function "alert".
|
||||
*
|
||||
*
|
||||
* @param string $message contains the actual message being sent to the client.
|
||||
* @param string $details (optional) can be used to inform the user on the client side about additional details about the error. This might be information how the error can be resolved/why it was raised or simply some debug data.
|
||||
*/
|
||||
@ -258,10 +253,10 @@ class egw_json_response
|
||||
|
||||
/**
|
||||
* Allows to add a generic java script to the response which will be executed upon the request gets received.
|
||||
*
|
||||
*
|
||||
* @deprecated
|
||||
* @param string $script the script code which should be executed upon receiving
|
||||
*/
|
||||
*/
|
||||
public function script($script)
|
||||
{
|
||||
if (is_string($script))
|
||||
@ -276,9 +271,9 @@ class egw_json_response
|
||||
|
||||
/**
|
||||
* Allows to add a global javascript function with giben parameters
|
||||
*
|
||||
*
|
||||
* @param string $script the script code which should be executed upon receiving
|
||||
*/
|
||||
*/
|
||||
public function jquery($selector,$method,array $parameters=array())
|
||||
{
|
||||
if (is_string($selector) && is_string($method))
|
||||
@ -297,7 +292,7 @@ class egw_json_response
|
||||
|
||||
/**
|
||||
* Adds an html assign to the response, which is excecuted upon the request is received.
|
||||
*
|
||||
*
|
||||
* @param string $id id of dom element to modify
|
||||
* @param string $key attribute name of dom element which should be modified
|
||||
* @param string $value the value which should be assigned to the given attribute
|
||||
@ -317,10 +312,10 @@ class egw_json_response
|
||||
throw new Exception("Invalid parameters supplied");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Redirect to given url
|
||||
*
|
||||
*
|
||||
* @param string $url
|
||||
*/
|
||||
public function redirect($url, $global = false)
|
||||
@ -337,14 +332,14 @@ class egw_json_response
|
||||
|
||||
/**
|
||||
* Returns the actual JSON code generated by calling the above "add" function.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
*/
|
||||
public function getJSON()
|
||||
{
|
||||
/* Wrap the result array into a parent "response" Object */
|
||||
$res = array('response' => $this->responseArray);
|
||||
|
||||
|
||||
return json_encode($res); //PHP5.3+, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
|
||||
}
|
||||
|
||||
@ -387,7 +382,7 @@ class egw_json_response
|
||||
$args = func_get_args();
|
||||
$func = array_shift($args);
|
||||
|
||||
$this->script("$func(".implode(",", $args).");");
|
||||
$this->script("window['".$func."'].apply(window, ".json_encode($args).");");
|
||||
}
|
||||
|
||||
public function getXML()
|
||||
|
@ -87,11 +87,13 @@ function egw_json_encode(input)
|
||||
{
|
||||
switch (input.constructor)
|
||||
{
|
||||
case Array:
|
||||
case Array:
|
||||
var buf = [];
|
||||
for (var k in input)
|
||||
{
|
||||
buf.push(egw_json_encode(input[k]));
|
||||
//Filter the remove function, which is added to arrays in egw_fw_classes
|
||||
if (k != 'remove')
|
||||
buf.push(egw_json_encode(input[k]));
|
||||
}
|
||||
return '[' + buf.join(',') + ']';
|
||||
|
||||
@ -307,7 +309,7 @@ egw_json_request.prototype.handleResponse = function(data, textStatus, XMLHttpRe
|
||||
}
|
||||
}
|
||||
|
||||
function egw_json_getFormValues(_form)
|
||||
function egw_json_getFormValues(_form, _filterClass)
|
||||
{
|
||||
var elem = null;
|
||||
if (typeof _form == 'object')
|
||||
@ -322,7 +324,10 @@ function egw_json_getFormValues(_form)
|
||||
var serialized = new Object;
|
||||
if (typeof elem != "undefined" && elem && elem.childNodes)
|
||||
{
|
||||
_egw_json_getFormValues(serialized, elem.childNodes)
|
||||
if (typeof _filterClass == 'undefined')
|
||||
_filterClass = null;
|
||||
|
||||
_egw_json_getFormValues(serialized, elem.childNodes, _filterClass)
|
||||
}
|
||||
|
||||
return serialized;
|
||||
@ -379,16 +384,22 @@ window.xajax = {
|
||||
* run over all form elements
|
||||
* @param serialized is the object which will contain the form data
|
||||
* @param children is the children node of the form we're runing over
|
||||
* @param string _filterClass if given only return
|
||||
*/
|
||||
function _egw_json_getFormValues(serialized, children)
|
||||
function _egw_json_getFormValues(serialized, children, _filterClass)
|
||||
{
|
||||
//alert('_egw_json_getFormValues(,,'+_filterClass+')');
|
||||
for (var i = 0; i < children.length; ++i) {
|
||||
var child = children[i];
|
||||
|
||||
if (typeof child.childNodes != "undefined")
|
||||
_egw_json_getFormValues(serialized, child.childNodes);
|
||||
_egw_json_getFormValues(serialized, child.childNodes, _filterClass);
|
||||
|
||||
_egw_json_getFormValue(serialized, child);
|
||||
if ((!_filterClass || $(child).hasClass(_filterClass)) && typeof child.name != "undefined")
|
||||
{
|
||||
//alert('_egw_json_getFormValues(,,'+_filterClass+') calling _egw_json_getFormValue for name='+child.name+', class='+child.class+', value='+child.value);
|
||||
_egw_json_getFormValue(serialized, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user