Yii Advanced Filters Extension
  • Package
  • Class

Packages

  • advancedfilters
    • components
    • dbhelpers
    • filters

Classes

  • AfBaseFilter
  • AfDefaultFilter
  • AfExactFilter
  • AfRangeFilter
  • AfRegexFilter
  • AfSubstringFilter
 1 <?php
 2 
 3 /**
 4  * AfDefaultFilter class file.
 5  * 
 6  * @author Keith Burton <kburton@kappasoft.net>
 7  * @package advancedfilters.filters
 8  */
 9 
10 /**
11  * This filter acts as a catch-all and matches columns where every word in the
12  * expression appears in any order.
13  */
14 class AfDefaultFilter extends AfBaseFilter
15 {
16     /**
17      * @var string the string used to split the expression into separate words.
18      * Any whitespace around the resulting words will be trimmed.
19      */
20     public $wordDelimiter = ' ';
21     
22     /**
23      * The AfDefaultFilter class acts as a catch all, so accepts any expression.
24      * 
25      * @return true
26      */
27     public function acceptsFilterExpression()
28     {
29         return true;
30     }
31     
32     /**
33      * Builds a new CDbCriteria object based on the expression provided.
34      * 
35      * @return CDbCriteria the new criteria object.
36      */
37     public function getCriteria()
38     {
39         $searchTerms = preg_split(
40                 '/\\s*' . preg_quote($this->wordDelimiter, '/') . '\\s*/i',
41                 $this->filterExpression, null, PREG_SPLIT_NO_EMPTY);
42         
43         $operator = $this->invertLogic ? 'OR' : 'AND';
44         $like = $this->invertLogic ? 'NOT LIKE' : 'LIKE';
45         
46         $criteria = new CDbCriteria;
47         
48         foreach ($searchTerms as $searchTerm)
49             $criteria->addSearchCondition($this->columnExpression, $searchTerm,
50                     true, $operator, $like);
51         
52         return $criteria;
53     }
54 }
55 
Yii Advanced Filters Extension API documentation generated by ApiGen