Hoa central
Array.php
Go to the documentation of this file.
1 <?php
2 
46 import('Filter.Abstract');
47 
51 import('Filter.~');
52 
68 
74  protected $arguments = array(
75  'filters' => 'specify an associative array of key => filter to apply.'
76  );
77 
78 
79 
90  public function filter ( $string = null ) {
91 
92  if(!is_array($string))
93  $string = array($string);
94 
95  $filters = $this->getFilterArgument('filters');
96  $lastFilter = current($filters);
97 
98  foreach($filters as $key => &$filter)
99  if($filter === null)
100  $filter = $lastFilter;
101  else
102  $lastFilter = $filters[$key];
103 
104  foreach($string as $key => &$value) {
105 
106  $add = new Hoa_Filter();
107 
108  if(!isset($filters[$key]))
109  if(isset($filters['*']))
110  $add->addFilter($filters['*']);
111  else
112  continue;
113  else
114  $add->addFilter($filters[$key]);
115 
116  $value = $add->filter($value);
117  $add = null;
118  }
119 
120  return $string;
121  }
122 }
getFilterArgument($name)
Definition: Abstract.php:146
filter($string=null)
Definition: Array.php:90