mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-28 01:29:05 +01:00
"allow to have more then one nextmatch widget on a page, for nathan and pERP :-)"
This commit is contained in:
parent
42824ef687
commit
c57b02c59f
@ -119,13 +119,27 @@
|
||||
/**
|
||||
* returns last part of a form-name
|
||||
*
|
||||
* @internal
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
function last_part($name)
|
||||
static private function last_part($name)
|
||||
{
|
||||
list($last) = self::get_parts($name,-1,1);
|
||||
return $last;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns last part of a form-name
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $offset positive or negative offset (negative is count from the end)
|
||||
* @param int $length=null positiv means return $length elements, negative return til negative offset in $length, default = null means all
|
||||
* @return array
|
||||
*/
|
||||
static private function get_parts($name,$offset,$length=null)
|
||||
{
|
||||
$parts = explode('[',str_replace(']','',$name));
|
||||
return $parts[count($parts)-1];
|
||||
return array_slice($parts,$offset,$length);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,7 +157,9 @@
|
||||
*/
|
||||
function pre_process($name,&$value,array &$cell,&$readonlys,&$extension_data,etemplate &$tmpl)
|
||||
{
|
||||
$nm_global = &$GLOBALS['egw_info']['etemplate']['nextmatch'];
|
||||
// extract the original nextmatch name from $name, taken into account the nextmatch-* subwidgets
|
||||
$nm_global = implode('/',self::get_parts($name,1,$cell['type']=='nextmatch' ? null : -2));
|
||||
$nm_global = &$GLOBALS['egw_info']['etemplate']['nextmatch'][$nm_global];
|
||||
//echo "<p>nextmatch_widget.pre_process(name='$name',type='$cell[type]'): value = "; _debug_array($value);
|
||||
//echo "<p>nextmatch_widget.pre_process(name='$name',type='$cell[type]'): nm_global = "; _debug_array($nm_global);
|
||||
|
||||
@ -164,7 +180,7 @@
|
||||
{
|
||||
$cell['help'] = 'click to order after that criteria';
|
||||
}
|
||||
if ($this->last_part($name) == $nm_global['order']) // we're the active column
|
||||
if (self::last_part($name) == $nm_global['order']) // we're the active column
|
||||
{
|
||||
$cell[1] = $cell;
|
||||
unset($cell[1]['align']);
|
||||
@ -204,7 +220,7 @@
|
||||
$parts = explode(',',$cell['span']);
|
||||
$parts[1] .= ($parts[1] ? ' ' : '').'filterheader';
|
||||
$cell['span'] = implode(',',$parts);
|
||||
$extension_data['old_value'] = $value = $nm_global['col_filter'][$this->last_part($name)];
|
||||
$extension_data['old_value'] = $value = $nm_global['col_filter'][self::last_part($name)];
|
||||
return True;
|
||||
|
||||
case 'nextmatch-customfields':
|
||||
@ -647,7 +663,9 @@
|
||||
*/
|
||||
function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
|
||||
{
|
||||
$nm_global = &$GLOBALS['egw_info']['etemplate']['nextmatch'];
|
||||
// extract the original nextmatch name from $name, taken into account the nextmatch-* subwidgets
|
||||
$nm_global = implode('/',$cell['type']=='nextmatch' || !($parts = self::get_parts($name,1,-2)) ? self::get_parts($name,1) : $parts);
|
||||
$nm_global = &$GLOBALS['egw_info']['etemplate']['nextmatch'][$nm_global];
|
||||
|
||||
if ($this->debug) { echo "<p>nextmatch_widget.post_process(type='$extension_data[type]', name='$name',value_in=".print_r($value_in,true).",order='$nm_global[order]'): value = "; _debug_array($value); }
|
||||
|
||||
@ -659,7 +677,7 @@
|
||||
case 'nextmatch-sortheader':
|
||||
if ($value_in)
|
||||
{
|
||||
$nm_global['order'] = $this->last_part($name);
|
||||
$nm_global['order'] = self::last_part($name);
|
||||
$nm_global['default_sort'] = $extension_data['default_sort'];
|
||||
}
|
||||
return False; // dont report value back, as it's in the wrong location (rows)
|
||||
@ -669,8 +687,8 @@
|
||||
case 'nextmatch-filterheader':
|
||||
if ((string)$value_in != (string)$extension_data['old_value'])
|
||||
{
|
||||
if ($this->debug) echo "<p>setting nm_global[filter][".$this->last_part($name)."]='$value_in' (was '$extension_data[old_value]')</p>\n";
|
||||
$nm_global['filter'][$this->last_part($name)] = $value_in;
|
||||
if ($this->debug) echo "<p>setting nm_global[filter][".self::last_part($name)."]='$value_in' (was '$extension_data[old_value]')</p>\n";
|
||||
$nm_global['filter'][self::last_part($name)] = $value_in;
|
||||
}
|
||||
return False; // dont report value back, as it's in the wrong location (rows)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user