cvs: pear /Template Template.php
| From: | Philippe Jausions | Date: | Mon, 05 Jul 2004 00:13:45 +0000 |
| Subject: | cvs: pear /Template Template.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-21511@lists.php.net to get a copy of this message | ||
jausions Sun Jul 4 20:13:45 2004 EDT
Modified files:
/pear/Template Template.php
Log:
Some phpDoc updates
http://cvs.php.net/diff.php/pear/Template/Template.php?r1=1.17&r2=1.18&ty=u Index: pear/Template/Template.php diff -u pear/Template/Template.php:1.17 pear/Template/Template.php:1.18 --- pear/Template/Template.php:1.17 Sun Jul 4 12:41:15 2004 +++ pear/Template/Template.php Sun Jul 4 20:13:44 2004 @@ -48,7 +48,7 @@ * See example usage and in-progress documentation at {@link * http://wiki.ciaweb.net/yawiki/index.php?area=Template} * - * $Id: Template.php,v 1.17 2004/07/04 16:41:15 jausions Exp $ + * $Id: Template.php,v 1.18 2004/07/05 00:13:44 jausions Exp $ * * @package Template * @@ -115,9 +115,9 @@ * @access public */ var $files = array( - 'current_template' => '', - 'requested_template' => '', - 'compiled_template' => '', + 'current_template' => '', + 'requested_template' => '', + 'compiled_template' => '', ); @@ -203,8 +203,8 @@ * use array('string'=>$template_string) or $filepointer * for other types of source. * - * @return bool|PEAR_Error TRUE or string, if 'compiler.toString' is set), - * or PEAR_Error on failure. + * @return bool|string TRUE or string, if 'compiler.toString' is set, + * or FALSE on error. * @access public * @todo Possible alternatives : use / useTemplate */ @@ -263,10 +263,10 @@ // What type of compiler - do we need to do anything.. - switch($this->options['compiler']) { + switch ($this->options['compiler']) { case '': - $this->files['compiledTemplate'] = $this->files['current_template']; + $this->files['compiled_template'] = $this->files['current_template']; $this->debug("Using Raw Compiler"); return true; @@ -274,7 +274,6 @@ return $this->block('load'); default: // some kind of compiler specified... - $this->assertProvider('Compiler'); if (!is_bool($r = $this->provider['Compiler']->needsCompiling())) { return $r; @@ -292,13 +291,11 @@ /** * Outputs the template. * - * @return bool|PEAR_Error TRUE or PEAR_Error object on error + * @return bool TRUE or FALSE on error * @access public */ function output() { - - $this->debug( "output {$this->files['compiled_template']}"); if (!empty($this->options['filters']) @@ -307,15 +304,12 @@ return $this->provider['Filter']->output(); } - if ($this->options['compiler'] == 'block') { echo $this->block('get'); return true; } - - // some compilers will set element merge. // takes what was in the template and overlays it with // the contents of $this->data['elements']. @@ -336,16 +330,14 @@ $_error_reporting = false; - if (!$this->options['strict']) { + if (!empty($this->options['strict'])) { $_error_reporting = error_reporting(E_ALL ^ E_NOTICE); } - - // either extract, or put it all in $data['object'] // the engine can generate $t = &$this->data['object'] at the top anyway.. - if (isset($this->options['no_extract'])) { + if (!empty($this->options['no_extract'])) { if (!$this->data['object']) { $this->data['object'] = (object) $this->data['variables']; foreach(array_keys($this->data['byref']) as $k) { @@ -362,7 +354,7 @@ extract($this->data['variables']); foreach (array_keys($this->data['byref']) as $_k) { - $$_k = &$this->$this->data['byref'][$_k]; + $$_k = &$this->data['byref'][$_k]; } } @@ -384,8 +376,7 @@ /** * Gets the result of the template overlaid with data as a string. * - * @return string|PEAR_Error the result of template, or PEAR_Error object - * on error + * @return string|bool the result of template, or FALSE on error * * @access public */ @@ -461,7 +452,7 @@ * * @param varargs .... * - * @return bool|PEAR_Error TRUE or PEAR_Error object on error + * @return bool TRUE or FALSE on error * @access public * @see Template_Assign::setData() * @status alpha @@ -469,7 +460,9 @@ function setData() { $this->assertProvider('Assign'); - return call_user_func_array(array(&$this->provider['Assign'],'setData'),func_get_args()); + $args = func_get_args(); + return call_user_func_array(array(&$this->provider['Assign'], + 'setData'), $args); } @@ -483,7 +476,7 @@ * @param string $k name of variable * @param mixed $v value to assign * - * @return bool|PEAR_Error TRUE or PEAR_Error object on error + * @return bool TRUE or FALSE on error * @access public * @see Template_Assign::setDataByRef() */ @@ -515,7 +508,7 @@ * * @param varargs .... * - * @return bool|PEAR_Error TRUE or PEAR_Error object on error + * @return bool TRUE or FALSE on error * @access public * @see Template_Plugin * @status alpha @@ -531,7 +524,7 @@ /** * Block API support * - * An idea to support block regex/str_replace tempaltes + * An idea to support block regex/str_replace templates * useing the idea * $template->block('set','.....'); // set current block * $template->block('get','.....'); // get the parsed results of a block??? @@ -570,11 +563,10 @@ * $template->assignProvider('Compiler/Flexy'); * </code> * - * @todo Possibly return a PEAR_Error or trigger_error() on class loading - * issue... + * @todo Possibly handling class loading issue in a non-fatal way... * @param string $name name of feature. * - * @return bool|PEAR_Error TRUE or PEAR_Error object on error. + * @return bool TRUE or FALSE on error. * @access public */ function assertProvider($name) @@ -617,7 +609,7 @@ * provides the lightweight output without assigment that outputObject used to do.. * * @access public - * @return none + * @return bool TRUE or FALSE on error */ function outputData(&$data) { @@ -630,11 +622,9 @@ $this->data = &$data; return $this->output(); default: - $this->output(); + return $this->output(); // mmh what about other types!!!??? } - - } @@ -647,19 +637,19 @@ // this whole area still needs a bit more thought... /** - * Get an array of elements from the template - * - * All <form> elements (eg. <input><textarea) etc.) and anything marked as - * dynamic (eg. flexy:dynamic="yes") are converted in to elements - * (simliar to XML_Tree_Node) - * you can use this to build the default $elements array that is used by - * outputObject() - or just create them and they will be overlayed when you - * run outputObject() - * - * - * @return array of TEMPLATE_Element s - * @access public - */ + * Gets an array of elements from the template + * + * All <form> elements (eg. <input><textarea) etc.) and anything marked as + * dynamic (eg. flexy:dynamic="yes") are converted in to elements + * (simliar to XML_Tree_Node) + * you can use this to build the default $elements array that is used by + * outputObject() - or just create them and they will be overlayed when you + * run outputObject() + * + * + * @return array of TEMPLATE_Element s + * @access public + */ function getElement($name = false) { @@ -679,8 +669,8 @@ /** - * -- consider if this is necessary.. - * Set one or multiple (array) options + * -- considering if this is necessary.. + * Sets one or multiple (array) options * * @access public * @param mixed Associative array of options or name of single option
http://cvs.php.net/diff.php/pear/Template/Template.php?r1=1.17&r2=1.18&ty=u Index: pear/Template/Template.php diff -u pear/Template/Template.php:1.17 pear/Template/Template.php:1.18 --- pear/Template/Template.php:1.17 Sun Jul 4 12:41:15 2004 +++ pear/Template/Template.php Sun Jul 4 20:13:44 2004 @@ -48,7 +48,7 @@ * See example usage and in-progress documentation at {@link * http://wiki.ciaweb.net/yawiki/index.php?area=Template} * - * $Id: Template.php,v 1.17 2004/07/04 16:41:15 jausions Exp $ + * $Id: Template.php,v 1.18 2004/07/05 00:13:44 jausions Exp $ * * @package Template * @@ -115,9 +115,9 @@ * @access public */ var $files = array( - 'current_template' => '', - 'requested_template' => '', - 'compiled_template' => '', + 'current_template' => '', + 'requested_template' => '', + 'compiled_template' => '', ); @@ -203,8 +203,8 @@ * use array('string'=>$template_string) or $filepointer * for other types of source. * - * @return bool|PEAR_Error TRUE or string, if 'compiler.toString' is set), - * or PEAR_Error on failure. + * @return bool|string TRUE or string, if 'compiler.toString' is set, + * or FALSE on error. * @access public * @todo Possible alternatives : use / useTemplate */ @@ -263,10 +263,10 @@ // What type of compiler - do we need to do anything.. - switch($this->options['compiler']) { + switch ($this->options['compiler']) { case '': - $this->files['compiledTemplate'] = $this->files['current_template']; + $this->files['compiled_template'] = $this->files['current_template']; $this->debug("Using Raw Compiler"); return true; @@ -274,7 +274,6 @@ return $this->block('load'); default: // some kind of compiler specified... - $this->assertProvider('Compiler'); if (!is_bool($r = $this->provider['Compiler']->needsCompiling())) { return $r; @@ -292,13 +291,11 @@ /** * Outputs the template. * - * @return bool|PEAR_Error TRUE or PEAR_Error object on error + * @return bool TRUE or FALSE on error * @access public */ function output() { - - $this->debug( "output {$this->files['compiled_template']}"); if (!empty($this->options['filters']) @@ -307,15 +304,12 @@ return $this->provider['Filter']->output(); } - if ($this->options['compiler'] == 'block') { echo $this->block('get'); return true; } - - // some compilers will set element merge. // takes what was in the template and overlays it with // the contents of $this->data['elements']. @@ -336,16 +330,14 @@ $_error_reporting = false; - if (!$this->options['strict']) { + if (!empty($this->options['strict'])) { $_error_reporting = error_reporting(E_ALL ^ E_NOTICE); } - - // either extract, or put it all in $data['object'] // the engine can generate $t = &$this->data['object'] at the top anyway.. - if (isset($this->options['no_extract'])) { + if (!empty($this->options['no_extract'])) { if (!$this->data['object']) { $this->data['object'] = (object) $this->data['variables']; foreach(array_keys($this->data['byref']) as $k) { @@ -362,7 +354,7 @@ extract($this->data['variables']); foreach (array_keys($this->data['byref']) as $_k) { - $$_k = &$this->$this->data['byref'][$_k]; + $$_k = &$this->data['byref'][$_k]; } } @@ -384,8 +376,7 @@ /** * Gets the result of the template overlaid with data as a string. * - * @return string|PEAR_Error the result of template, or PEAR_Error object - * on error + * @return string|bool the result of template, or FALSE on error * * @access public */ @@ -461,7 +452,7 @@ * * @param varargs .... * - * @return bool|PEAR_Error TRUE or PEAR_Error object on error + * @return bool TRUE or FALSE on error * @access public * @see Template_Assign::setData() * @status alpha @@ -469,7 +460,9 @@ function setData() { $this->assertProvider('Assign'); - return call_user_func_array(array(&$this->provider['Assign'],'setData'),func_get_args()); + $args = func_get_args(); + return call_user_func_array(array(&$this->provider['Assign'], + 'setData'), $args); } @@ -483,7 +476,7 @@ * @param string $k name of variable * @param mixed $v value to assign * - * @return bool|PEAR_Error TRUE or PEAR_Error object on error + * @return bool TRUE or FALSE on error * @access public * @see Template_Assign::setDataByRef() */ @@ -515,7 +508,7 @@ * * @param varargs .... * - * @return bool|PEAR_Error TRUE or PEAR_Error object on error + * @return bool TRUE or FALSE on error * @access public * @see Template_Plugin * @status alpha @@ -531,7 +524,7 @@ /** * Block API support * - * An idea to support block regex/str_replace tempaltes + * An idea to support block regex/str_replace templates * useing the idea * $template->block('set','.....'); // set current block * $template->block('get','.....'); // get the parsed results of a block??? @@ -570,11 +563,10 @@ * $template->assignProvider('Compiler/Flexy'); * </code> * - * @todo Possibly return a PEAR_Error or trigger_error() on class loading - * issue... + * @todo Possibly handling class loading issue in a non-fatal way... * @param string $name name of feature. * - * @return bool|PEAR_Error TRUE or PEAR_Error object on error. + * @return bool TRUE or FALSE on error. * @access public */ function assertProvider($name) @@ -617,7 +609,7 @@ * provides the lightweight output without assigment that outputObject used to do.. * * @access public - * @return none + * @return bool TRUE or FALSE on error */ function outputData(&$data) { @@ -630,11 +622,9 @@ $this->data = &$data; return $this->output(); default: - $this->output(); + return $this->output(); // mmh what about other types!!!??? } - - } @@ -647,19 +637,19 @@ // this whole area still needs a bit more thought... /** - * Get an array of elements from the template - * - * All <form> elements (eg. <input><textarea) etc.) and anything marked as - * dynamic (eg. flexy:dynamic="yes") are converted in to elements - * (simliar to XML_Tree_Node) - * you can use this to build the default $elements array that is used by - * outputObject() - or just create them and they will be overlayed when you - * run outputObject() - * - * - * @return array of TEMPLATE_Element s - * @access public - */ + * Gets an array of elements from the template + * + * All <form> elements (eg. <input><textarea) etc.) and anything marked as + * dynamic (eg. flexy:dynamic="yes") are converted in to elements + * (simliar to XML_Tree_Node) + * you can use this to build the default $elements array that is used by + * outputObject() - or just create them and they will be overlayed when you + * run outputObject() + * + * + * @return array of TEMPLATE_Element s + * @access public + */ function getElement($name = false) { @@ -679,8 +669,8 @@ /** - * -- consider if this is necessary.. - * Set one or multiple (array) options + * -- considering if this is necessary.. + * Sets one or multiple (array) options * * @access public * @param mixed Associative array of options or name of single option