forked from extern/egroupware
implemented disabled columns
This commit is contained in:
parent
0fdf434321
commit
ec58f52b62
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
// include only widgets which can't be autoloaded (or contain sub-widgets which cant)
|
// include only widgets which can't be autoloaded (or contain sub-widgets which cant)
|
||||||
require_once EGW_INCLUDE_ROOT.'/etemplate/inc/class.etemplate_widget_textbox.inc.php';
|
require_once EGW_INCLUDE_ROOT.'/etemplate/inc/class.etemplate_widget_textbox.inc.php';
|
||||||
|
require_once EGW_INCLUDE_ROOT.'/etemplate/inc/class.etemplate_widget_grid.inc.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* eTemplate widget baseclass
|
* eTemplate widget baseclass
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* eTemplate grid widget
|
* eTemplate grid widget incl. row(s) and column(s)
|
||||||
*/
|
*/
|
||||||
class etemplate_widget_grid extends etemplate_widget_box
|
class etemplate_widget_grid extends etemplate_widget_box
|
||||||
{
|
{
|
||||||
@ -24,4 +24,66 @@ class etemplate_widget_grid extends etemplate_widget_box
|
|||||||
* @var string|array
|
* @var string|array
|
||||||
*/
|
*/
|
||||||
protected $legacy_options = null;
|
protected $legacy_options = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run a given method on all children
|
||||||
|
*
|
||||||
|
* Reimplemented to implement column based disabling:
|
||||||
|
* - added 4th var-parameter to hold key of disabled column
|
||||||
|
* - if a column is disabled run returns false and key get added by columns run to $columns_disabled
|
||||||
|
* - row run method checks now for each child (arbitrary widget) if it the column's key is included in $columns_disabled
|
||||||
|
* - as a grid can contain other grid's as direct child, we have to backup and initialise $columns_disabled in grid run!
|
||||||
|
*
|
||||||
|
* @param string $method_name
|
||||||
|
* @param array $params=array('') parameter(s) first parameter has to be the cname!
|
||||||
|
* @param boolean $respect_disabled=false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children
|
||||||
|
* @param array $columns_disabled=array() disabled columns
|
||||||
|
*/
|
||||||
|
public function run($method_name, $params=array(''), $respect_disabled=false, &$columns_disabled=array())
|
||||||
|
{
|
||||||
|
// as a grid can contain other grid's as direct child, we have to backup and initialise $columns_disabled
|
||||||
|
if ($this->type == 'grid')
|
||||||
|
{
|
||||||
|
$backup_columns_disabled = $columns_disabled;
|
||||||
|
$columns_disabled = array();
|
||||||
|
}
|
||||||
|
if ($respect_disabled && ($disabled = $this->attrs['disabled']))
|
||||||
|
{
|
||||||
|
// check if disabled contains @ or !
|
||||||
|
$cname = $params[0];
|
||||||
|
$disabled = self::check_disabled($disabled, $cname ? self::get_array(self::$request->content, $cname) : self::$request->content);
|
||||||
|
if ($disabled)
|
||||||
|
{
|
||||||
|
error_log(__METHOD__."('$method_name', ".array2string($params).', '.array2string($respect_disabled).") $this disabled='{$this->attrs['disabled']}'='$disabled': NOT running");
|
||||||
|
return false; // return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (method_exists($this, $method_name))
|
||||||
|
{
|
||||||
|
call_user_func_array(array($this, $method_name), $params);
|
||||||
|
}
|
||||||
|
foreach($this->children as $n => $child)
|
||||||
|
{
|
||||||
|
if ($type == 'row')
|
||||||
|
{
|
||||||
|
if (in_array($n, $columns_disabled))
|
||||||
|
{
|
||||||
|
error_log(__METHOD__."('$method_name', ".array2string($params).', '.array2string($respect_disabled).") $this column $n is disabled: NOT running");
|
||||||
|
continue; // do NOT run $method_name on disabled columns
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$disabled = $child->run($method_name, $params, $respect_disabled, $columns_disabled) === false;
|
||||||
|
|
||||||
|
if ($this->type == 'columns' && $disabled)
|
||||||
|
{
|
||||||
|
$columns_disabled[] = $n; // mark column as disabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($this->type == 'grid')
|
||||||
|
{
|
||||||
|
$columns_disabled = $backup_columns_disabled;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
etemplate_widget::registerWidget('etemplate_widget_grid', array('grid', 'rows', 'row', 'columns', 'column'));
|
||||||
|
Loading…
Reference in New Issue
Block a user