.

DBFilterGroup Class Reference
[Model]

Contains a set of DBFilter instances that form a group. More...

Inheritance diagram for DBFilterGroup:
IDBQueryModifier

List of all members.

Public Member Functions

  __construct ($key= '', $name= '', $filters=array(), $default= '')
  Constructor.
  add_filter ($key, $filter)
  Add a new filter.
  apply ($query)
  Apply filter.
  count ()
  Returns number of filters.
  get_current_filter ()
  Returns current filter.
  get_current_key ()
  Return current filter's key.
  get_default_key ()
  Return default filter's key.
  get_filter ($key)
  Get filter for give key.
  get_filters ()
  Returns an array of all filters.
  get_group_id ()
  Return key of this group.
  get_keys ()
  Returns an array of all filter keys.
  get_name ()
  Return name of this filter.
  set_current_key ($key)
  Set current filter's key.
  set_default_key ($key)
  Set default filter's key.

Protected Attributes

  $filters = array()
  An associative array of DBFilter instances.
  $group_key = ''
  $key_current_filter = ''
  $key_default_filter = ''
  $name = ''

Detailed Description

Contains a set of DBFilter instances that form a group.

For example, all possible filters on a column can form a group

Author:
Gerd Riesselmann

Definition at line 11 of file dbfiltergroup.cls.php.


Constructor & Destructor Documentation

DBFilterGroup::__construct ( key = '',
name = '',
filters = array(),
default = ''  
)

Constructor.

Parameters:
array  Associative array of DBFilter instances

Definition at line 26 of file dbfiltergroup.cls.php.

00026                                                                                               {
00027                 $this->name = $name;
00028                 $this->group_key = $key;
00029                 foreach($filters as $key => $value) {
00030                         $this->add_filter(strval($key), $value);
00031                 }
00032                 $this->set_default_key($default);
00033                 $this->set_current_key($default);
00034         }

Member Function Documentation

DBFilterGroup::add_filter ( key,
filter  
)

Add a new filter.

Parameters:
string  The key for this filter
DBFilter  DBFilter instance

Definition at line 56 of file dbfiltergroup.cls.php.

00056                                                   {
00057                 $filter->set_key($key);
00058                 $this->filters[$key] = $filter;
00059         }
DBFilterGroup::apply ( query  ) 

Apply filter.

Implements IDBQueryModifier.

Definition at line 136 of file dbfiltergroup.cls.php.

00136                                       {
00137                 $query->apply_modifier($this->get_current_filter());
00138         }
DBFilterGroup::count (  ) 

Returns number of filters.

Definition at line 85 of file dbfiltergroup.cls.php.

00085                                 {
00086                 return count($this->filters);
00087         }
DBFilterGroup::get_current_filter (  ) 

Returns current filter.

Returns:
DBFilter

Definition at line 125 of file dbfiltergroup.cls.php.

00125                                              {
00126                 $ret = $this->get_filter($this->get_current_key());
00127                 if ($ret == false) {
00128                         $ret = $this->get_filter($this->get_default_key());
00129                 }
00130                 return $ret;
00131         }
DBFilterGroup::get_current_key (  ) 

Return current filter's key.

Definition at line 116 of file dbfiltergroup.cls.php.

00116                                           {
00117                 return $this->key_current_filter;
00118         }
DBFilterGroup::get_default_key (  ) 

Return default filter's key.

Definition at line 102 of file dbfiltergroup.cls.php.

00102                                           {
00103                 return $this->key_default_filter;
00104         }       
DBFilterGroup::get_filter ( key  ) 

Get filter for give key.

Definition at line 64 of file dbfiltergroup.cls.php.

00064                                          {
00065                 return Arr::get_item($this->filters, $key, false);
00066         }
DBFilterGroup::get_filters (  ) 

Returns an array of all filters.

Definition at line 78 of file dbfiltergroup.cls.php.

00078                                       {
00079                 return array_values($this->filters);
00080         }
DBFilterGroup::get_group_id (  ) 

Return key of this group.

Definition at line 46 of file dbfiltergroup.cls.php.

00046                                        {
00047                 return $this->group_key;
00048         }       
DBFilterGroup::get_keys (  ) 

Returns an array of all filter keys.

Definition at line 71 of file dbfiltergroup.cls.php.

00071                                    {
00072                 return array_keys($this->filters);
00073         }
DBFilterGroup::get_name (  ) 

Return name of this filter.

Definition at line 39 of file dbfiltergroup.cls.php.

00039                                    {
00040                 return $this->name;
00041         }
DBFilterGroup::set_current_key ( key  ) 

Set current filter's key.

Definition at line 109 of file dbfiltergroup.cls.php.

00109                                               {
00110                 $this->key_current_filter = $key;
00111         }
DBFilterGroup::set_default_key ( key  ) 

Set default filter's key.

Definition at line 92 of file dbfiltergroup.cls.php.

00092                                               {
00093                 $this->key_default_filter = $key;
00094                 foreach($this->filters as $f) {
00095                         $f->set_is_default($f->get_key() == $key);
00096                 }
00097         }

Member Data Documentation

DBFilterGroup::$filters = array() [protected]

An associative array of DBFilter instances.

Definition at line 15 of file dbfiltergroup.cls.php.

DBFilterGroup::$group_key = '' [protected]

Definition at line 17 of file dbfiltergroup.cls.php.

DBFilterGroup::$key_current_filter = '' [protected]

Definition at line 19 of file dbfiltergroup.cls.php.

DBFilterGroup::$key_default_filter = '' [protected]

Definition at line 18 of file dbfiltergroup.cls.php.

DBFilterGroup::$name = '' [protected]

Definition at line 16 of file dbfiltergroup.cls.php.


The documentation for this class was generated from the following file: