cvs: pear /Template/Template Filter.php

From: Date: Sun, 04 Jul 2004 05:43:12 +0000
Subject: cvs: pear /Template/Template Filter.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-21482@lists.php.net to get a copy of this message
jausions Sun Jul 4 01:43:12 2004 EDT Modified files: /pear/Template/Template Filter.php Log: Fixed filter.sources for pre-loaded classes ('MyClass' => '') http://cvs.php.net/diff.php/pear/Template/Template/Filter.php?r1=1.2&r2=1.3&ty=u Index: pear/Template/Template/Filter.php diff -u pear/Template/Template/Filter.php:1.2 pear/Template/Template/Filter.php:1.3 --- pear/Template/Template/Filter.php:1.2 Fri Jun 25 08:42:33 2004 +++ pear/Template/Template/Filter.php Sun Jul 4 01:43:12 2004 @@ -16,7 +16,7 @@ // | Authors: Philippe Jausions <Philippe.Jausions -@- 11abacus.com> | // +----------------------------------------------------------------------+ // -// $Id: Filter.php,v 1.2 2004/06/25 12:42:33 alan_k Exp $ +// $Id: Filter.php,v 1.3 2004/07/04 05:43:12 jausions Exp $ // // Filter provider. // @@ -41,16 +41,16 @@ // 'TrimWhiteSpace', (built in) // 'MyClass' => '/path/to/filter', // load from.. // 'MyClass' => '', // just use the class (assume it's loaded) - + // array('someclass','somemethod'), // call_user_func - // array($this,'somemethod'), // call_user_func + // array($this,'somemethod'), // call_user_func // array('myfunction') // call_user_func // use this function - + // $object, // object that implements Filter. - + ), ); - + /** * A reference to the list of filters @@ -108,7 +108,7 @@ * Return a filtered output of the template * * @access public - * @return bool|PEAR_Error TRUE or PEAR_Error object on error + * @return string|PEAR_Error Result or PEAR_Error object on error **/ function toString() { // if we are already filtering (or filtering is not enabled... @@ -120,7 +120,7 @@ $this->_loadFilters(); // dont recurse! $this->template->options['filter.enabled'] = false; - + // get the template result as a string if (!is_string($r = $this->template->toString())) { return $r; @@ -135,12 +135,12 @@ if (is_string($this->filter[$i])) { $r = $this->filter[$i]($r); } - // call a user class/method etc.. + // call a user class/method etc.. if (is_array($this->filter[$i]) && is_callable($this->filter[$i])) { $r = call_user_func($this->filter[$i],$r); } // technically if this filter didnt get used.. it's an error condition!! - + if (!is_string($r)) { break; } @@ -153,21 +153,22 @@ /** * loads the required filters into $this->filters.. * - * @interface + * @interface * @access public - * @return string|PEAR_Error + * @return string|PEAR_Error **/ - function _loadFilters() + function _loadFilters() { // already loaded? if ($this->filters) { return; } - foreach(array_keys($this->template->options['filter.sources']) as $k) { + foreach (array_keys($this->template->options['filter.sources']) as $k) { if (!is_int($k)) { // then it's classname => filename - $filename = $this->template->options['filter.sources'][$k]; - include_once $filename; + if ($filename = $this->template->options['filter.sources'][$k]) { + include_once $filename; + } $this->filters[$classname] = new $k; // ??? use initProvider???? $this->filters[$classname]->initProvider($this->template); @@ -185,7 +186,7 @@ $this->filters[get_class($v)] = &$this->template->options['filter.sources'][$k]; continue; } - + // an array if (is_array($v)) { if (count($v) == 1) { @@ -210,22 +211,22 @@ ); } // we should have all the stuff loaded into filters now.!! - + } - + /** * perform the actual filtering. * - * @interface + * @interface * @access public - * @return string|PEAR_Error + * @return string|PEAR_Error **/ - - function filter($string) + + function filter($string) { return $string; } - + } ?>

« previous php.pear.cvs (#21482) next »