cvs: pear /Template/Template Assign.php Filter.php Plugin.php Source.php

From: Date: Sun, 04 Jul 2004 18:23:09 +0000
Subject: cvs: pear /Template/Template Assign.php Filter.php Plugin.php Source.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-21499@lists.php.net to get a copy of this message
jausions Sun Jul 4 14:23:09 2004 EDT Modified files: /pear/Template/Template Assign.php Filter.php Plugin.php Source.php Log: Some phpDoc fixes

http://cvs.php.net/diff.php/pear/Template/Template/Assign.php?r1=1.5&r2=1.6&ty=u Index: pear/Template/Template/Assign.php diff -u pear/Template/Template/Assign.php:1.5 pear/Template/Template/Assign.php:1.6 --- pear/Template/Template/Assign.php:1.5 Wed Jun 16 20:36:21 2004 +++ pear/Template/Template/Assign.php Sun Jul 4 14:23:09 2004 @@ -16,34 +16,37 @@ // | Authors: many... // +----------------------------------------------------------------------+ // -// $Id: Assign.php,v 1.5 2004/06/17 00:36:21 jausions Exp $ +// $Id: Assign.php,v 1.6 2004/07/04 18:23:09 jausions Exp $ // // Provider for Assign API // define('TEMPLATE_ASSIGN_ERROR_INVALIDARGS', -100); +/** + * @package Template + * @subpackage Template_Assign + */ class Template_Assign { /** - * A reference to the instantated template. - * - * @var object Template - * @access public - */ + * Reference to the instantated template. + * + * @var Template + * @access public + */ var $template = null; /** - * initialize the Provider. - * - * @param object Template The instantated template. - * - * @return boolean (it may return a PEAR::Error) - * @access public - * @see Template_Provider - */ - + * Initializes the Provider. + * + * @param object Template The instantated template. + * + * @return boolean (it may return a PEAR::Error) + * @access public + * @see Template_Provider + */ function initProvider(&$template) { // if you need to access template variables (Eg. options/data/providers) @@ -63,63 +66,56 @@ /** - * Normally a reference to the template->data array, however the class can be used - * standalone.. - * - * @var array - * @access public - */ + * Normally a reference to the template->data array, however + * the class can be used standalone.. + * + * @var array + * @access public + */ var $data = array(); /** - * - * Assigns a token-name and value to $this->_token_vars for use in a - * template. - * - * There are three valid ways to assign values to a template. - * - * Form 1: $args[0] is a string and $args[1] is mixed. This means - * $args[0] is a token name and $args[1] is the token value (which - * allows objects, arrays, strings, numbers, or anything else). - * $args[1] can be null, which means the corresponding token value in - * the template will also be null. - * - * Form 2: $args[0] is an array and $args[1] is not set. Assign a - * series of tokens where the key is the token name, and the value is - * token value. - * - * Form 3: $args[0] is an object and $args[1] is not set. Assigns - * copies of all object variables (properties) to tokens; the token - * name and value is a copy of each object property and value. - * - * @access public - * - * @param string|array|object $args[0] This param can be a string, an - * array, or an object. If $args[0] is a string, it is the name of a - * variable in the template. If $args[0] is an array, it must be an - * associative array of key-value pairs where the key is a variable - * name in the template and the value is the value for that variable - * in the template. If $args[0] is an object, copies of its - * properties will be assigned to the template. - * - * @param mixed $args[1] If $args[0] is an array or object, $args[1] - * should not be set. Otherwise, a copy of $args[1] is assigned to a - * template variable named after $args[0]. - * - * @return bool|PEAR_Error Boolean true if all assignments were - * committed, or a PEAR_Error object if there was an error. - * - * @throws SAVANT_ERROR_ASSIGN Unknown reason for error, probably - * because you passed $args[1] when $args[0] is an array or object. - * - * @author Paul M. Jones <pmjones@ciaweb.net> - * @see assignRef() - * - * @see assignObject() - * - */ - + * Assigns a token-name and value to $this->_token_vars for use in a + * template. + * + * There are three valid ways to assign values to a template. + * + * Form 1: $args[0] is a string and $args[1] is mixed. This means + * $args[0] is a token name and $args[1] is the token value (which + * allows objects, arrays, strings, numbers, or anything else). + * $args[1] can be null, which means the corresponding token value in + * the template will also be null. + * + * Form 2: $args[0] is an array and $args[1] is not set. Assign a + * series of tokens where the key is the token name, and the value is + * token value. + * + * Form 3: $args[0] is an object and $args[1] is not set. Assigns + * copies of all object variables (properties) to tokens; the token + * name and value is a copy of each object property and value. + * + * @param string|array|object $args[0] This param can be a string, an + * array, or an object. If $args[0] is a string, it is the name of a + * variable in the template. If $args[0] is an array, it must be an + * associative array of key-value pairs where the key is a variable + * name in the template and the value is the value for that variable + * in the template. If $args[0] is an object, copies of its + * properties will be assigned to the template. + * + * @param mixed $args[1] If $args[0] is an array or object, $args[1] + * should not be set. Otherwise, a copy of $args[1] is assigned to a + * template variable named after $args[0]. + * + * @return bool|PEAR_Error TRUE or a PEAR_Error object on error. + * + * @throws SAVANT_ERROR_ASSIGN Unknown reason for error, probably + * because you passed $args[1] when $args[0] is an array or object. + * + * @access public + * @author Paul M. Jones <pmjones@ciaweb.net> + * @see setDataByRef() + */ function setData() { // in Form 1, $args[0] is a string name and $args[1] is mixed. @@ -187,28 +183,20 @@ /** - * - * Assign a token by reference. This allows you change variable - * values within the template and have those changes reflected back - * at the calling logic script. Works as with form 2 of assign(). - * - * @access public - * - * @param string $name The template token-name for the reference. - * - * @param mixed &$ref The variable passed by-reference. - * - * @return bool|PEAR_Error Boolean true on success, or a PEAR_Error - * on failure. - * - * @throws SAVANT_ERROR_ASSIGN_REF Unknown reason for error. - * - * @see assign() - * @author Paul M. Jones <pmjones@ciaweb.net> - * @see assignObject() - * - */ - + * Assigns a token by reference. This allows you change variable + * values within the template and have those changes reflected back + * at the calling logic script. Works as with form 2 of assign(). + * + * @param string $name the template token-name for the reference. + * + * @param mixed &$ref the variable passed by-reference. + * + * @return bool|PEAR_Error TRUE or a PEAR_Error object on error + * + * @access public + * @author Paul M. Jones <pmjones@ciaweb.net> + * @see setData() + */ function setDataByRef($name, &$ref) { // look for the proper case: name and variable @@ -232,9 +220,6 @@ array(print_r($name,true),print_r($ref,true)) ); } - - - } ?> http://cvs.php.net/diff.php/pear/Template/Template/Filter.php?r1=1.5&r2=1.6&ty=u Index: pear/Template/Template/Filter.php diff -u pear/Template/Template/Filter.php:1.5 pear/Template/Template/Filter.php:1.6 --- pear/Template/Template/Filter.php:1.5 Sun Jul 4 12:48:31 2004 +++ pear/Template/Template/Filter.php Sun Jul 4 14:23:09 2004 @@ -16,14 +16,17 @@ // | Authors: Philippe Jausions <Philippe.Jausions -@- 11abacus.com> | // +----------------------------------------------------------------------+ // -// $Id: Filter.php,v 1.5 2004/07/04 16:48:31 jausions Exp $ +// $Id: Filter.php,v 1.6 2004/07/04 18:23:09 jausions Exp $ // // Filter provider. // +/** + * @package Template + * @subpackage Template_Filter + **/ class Template_Filter { - /** * Reference to the instantated template. * @@ -33,7 +36,9 @@ var $template = null; - + /** + * Wouldn't that belong to Template's options instead??? + */ var $options = array( 'filter.enabled' => false, // flag to prevent recursive filtering 'filter.sources' => array( http://cvs.php.net/diff.php/pear/Template/Template/Plugin.php?r1=1.1&r2=1.2&ty=u Index: pear/Template/Template/Plugin.php diff -u pear/Template/Template/Plugin.php:1.1 pear/Template/Template/Plugin.php:1.2 --- pear/Template/Template/Plugin.php:1.1 Fri Jun 25 06:35:41 2004 +++ pear/Template/Template/Plugin.php Sun Jul 4 14:23:09 2004 @@ -16,24 +16,28 @@ // | Authors: nobody <nobody@localhost> | // +----------------------------------------------------------------------+ // -// $Id: Plugin.php,v 1.1 2004/06/25 10:35:41 alan_k Exp $ +// $Id: Plugin.php,v 1.2 2004/07/04 18:23:09 jausions Exp $ // // Plugin API provides support for < ? = $this->plugin(".....",.....); ? > // or {this.plugin(#xxxxx#,#xxxx#):h} // // BASICALLY THIS IS SAVANT'S PLUGIN PROVIDER. // @author Paul M. Jones <pmjones@ciaweb.net> - - + + +/** + * @package Template + * @subpackage Template_Plugin + **/ class Template_Plugin { - + /** * reference to main engine.. * - * @var object Template + * @var object Template * @access public */ - var $template; + var $template; var $pluginCache = array(); // store of instanced plugins.. /** * Options used by the Plugin Provider @@ -46,7 +50,7 @@ * @var array * @access public */ - + var $options = array( 'plugin.sources' => array( 'Savant', // default to using savant plugin Provider @@ -56,14 +60,14 @@ /** * instances of plugin objects. * - * @var array Template_Plugin's + * @var array Template_Plugin's * @access public */ - var $plugins = array(); - - - - + var $plugins = array(); + + + + function initProvider(&$template) { // if you need to access template variables (Eg. options/data/providers) @@ -80,46 +84,46 @@ * Call a Plugin method. * * Look up in all the plugins to see if the method exists, if it does, call it. - * - * + * + * * @param array name of method, arguments. - * + * * * @return string hopefully * @access public */ function call($args) { - + $method = $args[0]; // attempt to load the plugin on-the-fly $class = $this->_loadPlugins($method); - + if (is_a($class,'PEAR_Error')) { //echo $class->toString(); return $class; } - - + + // first argument is always the plugin name; shift the first // argument off the front of the array and reduce the number of // array elements. array_shift($args); - + return call_user_func_array(array(&$this->plugins[$class],$method), $args); } - + /** - * Load the plugins, and lookup which one provides the required method + * Load the plugins, and lookup which one provides the required method + * * - * * @param string Name * * @return string|PEAR_Error the class that provides it. * @access private */ - - function _findPlugin($name) + + function _findPlugin($name) { // name can be: // ahref = maps to {class_prefix}_ahref::ahref @@ -129,7 +133,7 @@ return $class; } } - + if (empty($this->plugins)) { foreach ($this->template->options['plugin.sources'] as $className=>$file) { if (!is_int($className)) { @@ -151,9 +155,9 @@ } } } - + return Template::raiseError('could not find plugin with method '. $name); } - - + + } http://cvs.php.net/diff.php/pear/Template/Template/Source.php?r1=1.2&r2=1.3&ty=u Index: pear/Template/Template/Source.php diff -u pear/Template/Template/Source.php:1.2 pear/Template/Template/Source.php:1.3 --- pear/Template/Template/Source.php:1.2 Wed Jun 16 20:36:21 2004 +++ pear/Template/Template/Source.php Sun Jul 4 14:23:09 2004 @@ -16,22 +16,26 @@ // | Authors: alan@akkbhome.com | // +----------------------------------------------------------------------+ // -// $Id: Source.php,v 1.2 2004/06/17 00:36:21 jausions Exp $ -// -// Source Provider - deals with -// a) mulitple paths for the source of a template -// b) different source types (eg. file handles, template source, object providers?) +// $Id: Source.php,v 1.3 2004/07/04 18:23:09 jausions Exp $ // +/** + * Source Provider - deals with + * a) multiple paths for the source of a template + * b) different source types (eg. file handles, template source, object providers?) + * + * @package Template + * @subpackage Template_Source + **/ class Template_Source { /** - * Default options related to this provider. - * - * @var array - * @access public - */ + * Default options related to this provider. + * + * @var array + * @access public + */ var $options = array( 'source.muliple_order' => null, // use 'reverse' - to sort backwards.. 'source.muliple_allow' => false, // set to true to allow the same @@ -40,23 +44,22 @@ ); /** - * A reference to the instantated template. - * - * @var object Template - * @access public - */ + * A reference to the instantated template. + * + * @var object Template + * @access public + */ var $template = null; /** - * initialize the Provider. - * - * @param object Template The instantated template. - * - * @return boolean (it may return a PEAR::Error) - * @access public - * @see Template_Provider - */ - + * Initializes this provider. + * + * @param object Template The instantated template. + * + * @return boolean (it may return a PEAR::Error) + * @access public + * @see Template_Provider + */ function initProvider(&$template) { // if you need to access template variables (Eg. options/data/providers) @@ -73,23 +76,20 @@ /** - * Find the location of the requested file. - * - * Looks in : - * a) {options[template_dir][*]}/templatename.{locale}.{ext} - * b) {options[template_dir][*]}/templatename - * - * - * @param string name of file. - * - * @return boolean true || pear error on failure. - * @access public - */ - - - function open($file) { - - + * Finds the location of the requested file. + * + * Looks in : + * a) {options[template_dir][*]}/templatename.{locale}.{ext} + * b) {options[template_dir][*]}/templatename + * + * + * @param string name of file. + * + * @return boolean true || pear error on failure. + * @access public + */ + function open($file) + { switch (get_type($file)) { case 'string':
« previous php.pear.cvs (#21499) next »