mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 00:13:35 +01:00
"allow static get_rows callbacks, eg. 'app_ui::get_rows':
- on php5.3+ they get directly called via a variable: $callback($query,$rows,$readonlys) - on php < 5.3 we instancate the class, an call the method non-static: $obj->$method($query,$rows,$readonlys) --> allows application code to be prepared for static callbacks Note: - we can not use call_user_func, as it does NOT support passing by reverence, which is required for $rows and $readonlys parameter - static callbacks allow to NOT instanciate the class again for the callback (without current dirty methods like placing the object in $GLOBALS[$class])"
This commit is contained in:
parent
fe03b91b54
commit
31cb95989e
@ -269,9 +269,22 @@ class nextmatch_widget
|
|||||||
if (!$value['filter_onchange']) $value['filter_onchange'] = 'this.form.submit();';
|
if (!$value['filter_onchange']) $value['filter_onchange'] = 'this.form.submit();';
|
||||||
if (!$value['filter2_onchange']) $value['filter2_onchange'] = 'this.form.submit();';
|
if (!$value['filter2_onchange']) $value['filter2_onchange'] = 'this.form.submit();';
|
||||||
|
|
||||||
list($app,$class,$method) = explode('.',$value['get_rows']);
|
// allow static callbacks
|
||||||
if ($app && $class)
|
if(strpos($method=$value['get_rows'],'::') !== false)
|
||||||
{
|
{
|
||||||
|
// workaround for php < 5.3: do NOT call it static, but allow application code to specify static callbacks
|
||||||
|
if (version_compare(PHP_VERSION,'5.3','<')) list($class,$method) = explode('::',$method);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list($app,$class,$method) = explode('.',$value['get_rows']);
|
||||||
|
}
|
||||||
|
if ($class)
|
||||||
|
{
|
||||||
|
if (!$app && !is_object($GLOBALS[$class]))
|
||||||
|
{
|
||||||
|
$GLOBALS[$class] = new $class();
|
||||||
|
}
|
||||||
if (is_object($GLOBALS[$class])) // use existing instance (put there by a previous CreateObject)
|
if (is_object($GLOBALS[$class])) // use existing instance (put there by a previous CreateObject)
|
||||||
{
|
{
|
||||||
$obj =& $GLOBALS[$class];
|
$obj =& $GLOBALS[$class];
|
||||||
@ -309,19 +322,30 @@ class nextmatch_widget
|
|||||||
$value['options-selectcols'] = array();
|
$value['options-selectcols'] = array();
|
||||||
}
|
}
|
||||||
$rows = array();
|
$rows = array();
|
||||||
if (!is_object($obj) || !method_exists($obj,$method))
|
if(is_callable($method)) // php5.3+ call
|
||||||
{
|
{
|
||||||
etemplate::set_validation_error($name,"nextmatch_widget::pre_process($cell[name]): '$value[get_rows]' is no valid method !!!");
|
$total = $extension_data['total'] = $value['total'] = $method($value['get_rows'],$value,$rows,$readonlys['rows']);
|
||||||
}
|
}
|
||||||
else
|
elseif(is_object($obj) && method_exists($obj,$method))
|
||||||
{
|
{
|
||||||
if (!is_array($readonlys)) $readonlys = array();
|
if (!is_array($readonlys)) $readonlys = array();
|
||||||
$total = $extension_data['total'] = $value['total'] = $obj->$method($value,$rows,$readonlys['rows']);
|
$total = $extension_data['total'] = $value['total'] = $obj->$method($value,$rows,$readonlys['rows']);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
etemplate::set_validation_error($name,"nextmatch_widget::pre_process($cell[name]): '$value[get_rows]' is no valid method !!!");
|
||||||
|
}
|
||||||
if ($method && $total && $value['start'] >= $total)
|
if ($method && $total && $value['start'] >= $total)
|
||||||
{
|
{
|
||||||
$value['start'] = 0;
|
$value['start'] = 0;
|
||||||
$total = $extension_data['total'] = $value['total'] = $obj->$method($value,$rows,$readonlys['rows']);
|
if (is_object($obj))
|
||||||
|
{
|
||||||
|
$total = $extension_data['total'] = $value['total'] = $obj->$method($value,$rows,$readonlys['rows']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$total = $extension_data['total'] = $value['total'] = $method($value['get_rows'],$value,$rows,$readonlys['rows']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// allow the get_rows function to override / set sel_options
|
// allow the get_rows function to override / set sel_options
|
||||||
if (isset($rows['sel_options']) && is_array($rows['sel_options']))
|
if (isset($rows['sel_options']) && is_array($rows['sel_options']))
|
||||||
|
Loading…
Reference in New Issue
Block a user