| 1: | <?php | 
| 2: |  | 
| 3: |  | 
| 4: |  | 
| 5: |  | 
| 6: |  | 
| 7: |  | 
| 8: |  | 
| 9: |  | 
| 10: |  | 
| 11: |  | 
| 12: | class Smarty_Internal_Method_LoadFilter | 
| 13: | { | 
| 14: |  | 
| 15: |  | 
| 16: |  | 
| 17: |  | 
| 18: |  | 
| 19: | public $objMap = 3; | 
| 20: |  | 
| 21: |  | 
| 22: |  | 
| 23: |  | 
| 24: |  | 
| 25: |  | 
| 26: | private $filterTypes = array('pre' => true, 'post' => true, 'output' => true, 'variable' => true); | 
| 27: |  | 
| 28: |  | 
| 29: |  | 
| 30: |  | 
| 31: |  | 
| 32: |  | 
| 33: |  | 
| 34: |  | 
| 35: |  | 
| 36: |  | 
| 37: |  | 
| 38: |  | 
| 39: |  | 
| 40: |  | 
| 41: |  | 
| 42: | public function loadFilter(Smarty_Internal_TemplateBase $obj, $type, $name) | 
| 43: | { | 
| 44: | $smarty = $obj->_getSmartyObj(); | 
| 45: | $this->_checkFilterType($type); | 
| 46: | $_plugin = "smarty_{$type}filter_{$name}"; | 
| 47: | $_filter_name = $_plugin; | 
| 48: | if (is_callable($_plugin)) { | 
| 49: | $smarty->registered_filters[ $type ][ $_filter_name ] = $_plugin; | 
| 50: | return true; | 
| 51: | } | 
| 52: | if ($smarty->loadPlugin($_plugin)) { | 
| 53: | if (class_exists($_plugin, false)) { | 
| 54: | $_plugin = array($_plugin, 'execute'); | 
| 55: | } | 
| 56: | if (is_callable($_plugin)) { | 
| 57: | $smarty->registered_filters[ $type ][ $_filter_name ] = $_plugin; | 
| 58: | return true; | 
| 59: | } | 
| 60: | } | 
| 61: | throw new SmartyException("{$type}filter '{$name}' not found or callable"); | 
| 62: | } | 
| 63: |  | 
| 64: |  | 
| 65: |  | 
| 66: |  | 
| 67: |  | 
| 68: |  | 
| 69: |  | 
| 70: |  | 
| 71: | public function _checkFilterType($type) | 
| 72: | { | 
| 73: | if (!isset($this->filterTypes[ $type ])) { | 
| 74: | throw new SmartyException("Illegal filter type '{$type}'"); | 
| 75: | } | 
| 76: | } | 
| 77: | } | 
| 78: |  |