- Added forloop.* (all variables)
[haanga.git] / haanga / filters.php
blob4b702ba2393cb2729192fb8c2c8da5d2137d7fee
1 <?php
2 /*
3 +---------------------------------------------------------------------------------+
4 | Copyright (c) 2010 Haanga |
5 +---------------------------------------------------------------------------------+
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: |
8 | 1. Redistributions of source code must retain the above copyright |
9 | notice, this list of conditions and the following disclaimer. |
10 | |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | 3. All advertising materials mentioning features or use of this software |
16 | must display the following acknowledgement: |
17 | This product includes software developed by César D. Rodas. |
18 | |
19 | 4. Neither the name of the César D. Rodas nor the |
20 | names of its contributors may be used to endorse or promote products |
21 | derived from this software without specific prior written permission. |
22 | |
23 | THIS SOFTWARE IS PROVIDED BY CÉSAR D. RODAS ''AS IS'' AND ANY |
24 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
25 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
26 | DISCLAIMED. IN NO EVENT SHALL CÉSAR D. RODAS BE LIABLE FOR ANY |
27 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
28 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
29 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
30 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
31 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE |
33 +---------------------------------------------------------------------------------+
34 | Authors: César Rodas <crodas@php.net> |
35 +---------------------------------------------------------------------------------+
38 class Haanga_Filter extends Extensions
40 /**
41 * isValid
45 final function isValid($filter)
47 static $cache = array();
48 $filter = strtolower($filter);
50 if (!isset($cache[$filter])) {
51 $file = $this->getFilePath($filter);
52 if (is_readable($file)) {
53 /* Load custom filter definition */
54 require_once $file;
55 $class_name = $this->getClassName($filter);
56 if (class_exists($class_name)) {
57 $cache[$filter] = TRUE;
60 if (!isset($cache[$filter])) {
61 $cache[$filter] = FALSE;
65 return $cache[$filter];
68 final function getFilePath($file, $rel=TRUE)
70 return parent::getFilePath($file, $rel, 'filters');
73 final function getClassName($filter)
75 return "{$filter}_filter";
82 * Local variables:
83 * tab-width: 4
84 * c-basic-offset: 4
85 * End:
86 * vim600: sw=4 ts=4 fdm=marker
87 * vim<600: sw=4 ts=4