.

Filter Class Reference
[Controller]

Class to create a filter widget and to filter search results. More...

Inheritance diagram for Filter:
IDBQueryModifier

List of all members.

Public Member Functions

  __construct ($page_data, $filtergroups, $adapter=false)
  Contructor.
  apply ($query)
  Apply this filter to a query.
  prepare_view ($view)

Static Public Member Functions

static  apply_to_url ($url, $filter, $group_id= '')
  Prepare URL so filter gets applied.

Protected Member Functions

  prepare_filter_group ($filtergroup)
  Prepare a filter group.

Protected Attributes

  $adapter
  $filter_data = array()

Detailed Description

Class to create a filter widget and to filter search results.

Author:
Gerd Riesselmann

Definition at line 8 of file filter.cls.php.


Constructor & Destructor Documentation

Filter::__construct ( page_data,
filtergroups,
adapter = false  
)

Contructor.

Parameters:
PageData  $page_data
Mixed  Either a single DBFilterGroup instance or an array of it or an instance of ISearchAdapter. In later case, get_filters() is invoked in the search adapter.
IFilterAdapter  $adapter

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

00026                                                                                  {
00027                 $this->adapter = ($adapter instanceof IFilterAdapter) ? $adapter : new FilterDefaultAdapter($page_data);
00028                 
00029                 if ($filtergroups instanceof ISearchAdapter) {
00030                         $filtergroups = $filtergroups->get_filters();
00031                 }
00032                 if (!is_array($filtergroups)) {
00033                         $filtergroups = ($filtergroups) ? array($filtergroups) : array(new DBFilterGroup());
00034                 }
00035                 
00036                 foreach($filtergroups as $filtergroup) {
00037                         // Add "all" filter
00038                         $this->prepare_filter_group($filtergroup);
00039                 }
00040                 
00041                 $this->filter_data['filter_groups'] = $filtergroups;
00042                 $this->filter_data['filter_url_builder'] = $this->adapter;
00043                 $this->filter_data['page_data'] = $page_data;
00044         }

Member Function Documentation

Filter::apply ( query  ) 

Apply this filter to a query.

Implements IDBQueryModifier.

Definition at line 65 of file filter.cls.php.

00065                                       {
00066                 // Simply delegate to current filter
00067                 foreach($this->filter_data['filter_groups'] as $filtergroup) {
00068                         $query->apply_modifier($filtergroup);
00069                 }
00070         }
static Filter::apply_to_url ( url,
filter,
group_id = ''  
) [static]

Prepare URL so filter gets applied.

Parameters:
Url  Instance of URL class. This instance is changed.
string  Filter to append
Returns:
void
Deprecated:
Used function on FilterAdapter instead

Definition at line 86 of file filter.cls.php.

00086                                                                            {
00087                 return FilterDefaultAdapter::apply_to_url($url, $filter, $group_id);
00088         }
Filter::prepare_filter_group ( filtergroup  )  [protected]

Prepare a filter group.

Parameters:
DBFilterGroup  $filtergroup

Definition at line 51 of file filter.cls.php.

00051                                                               {
00052                 if ($filtergroup->count() > 1) {
00053                         $filtergroup->add_filter('all', new DBFilter(tr('Show All', 'core')));
00054                         if (!$filtergroup->get_default_key()) {
00055                                 $filtergroup->set_default_key('all');
00056                         }
00057                 }
00058                 $current_key = $this->adapter->get_current_key($filtergroup->get_group_id(), $filtergroup->get_default_key());
00059                 $filtergroup->set_current_key($current_key);            
00060         }
Filter::prepare_view ( view  ) 

Definition at line 72 of file filter.cls.php.

00072                                             {
00073                 $view->assign('filter_data', $this->filter_data);
00074         }

Member Data Documentation

Filter::$adapter [protected]

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

Filter::$filter_data = array() [protected]

Definition at line 9 of file filter.cls.php.


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