From b28e73038621072dea0b1e73e39c3faa206011cd Mon Sep 17 00:00:00 2001 From: pdontthink Date: Tue, 19 Sep 2006 13:26:08 +0000 Subject: [PATCH 1/1] Clarifications, questions, proposals git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11719 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- class/template/template.class.php | 33 ++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/class/template/template.class.php b/class/template/template.class.php index 238b8ac1..6bc25cca 100755 --- a/class/template/template.class.php +++ b/class/template/template.class.php @@ -67,9 +67,8 @@ class Template /** * Additional stylesheets provided by the template. This allows template - * authors (namely me to begin with :p) to provide additional CSS sheets - * to templates while using the default template set stylesheet for other - * definitions. + * authors to provide additional CSS sheets to templates while using the + * default template set stylesheet for other definitions. */ var $additional_css_sheets = array(); @@ -133,11 +132,20 @@ class Template * * @param array|string $tpl_var the template variable name(s) * @param mixed $value the value to append + * @param boolean $merge when $value is given as an array, + * this indicates whether or not that + * array itself should be appended as + * a new template variable value or if + * that array's values should be merged + * into the existing array of template + * variable values */ function append($tpl_var, $value = NULL, $merge = FALSE) { if (is_array($tpl_var)) { + //FIXME: $tpl_var is supposed to be a list of template var names, + // so we should be looking at the values NOT the keys! foreach ($tpl_var as $_key => $_val) { if ($_key != '') @@ -145,6 +153,18 @@ class Template if(isset($this->values[$_key]) && !is_array($this->values[$_key])) settype($this->values[$_key],'array'); + //FIXME: we should be iterating the $value array here not the values of the + // list of template variable names! I think this is totally broken + // This might just be a matter of needing to clarify the method's API; + // values may have been meant to be passed in $tpl_var in the case that + // $tpl_var is an array. Ugly and non-intuitive. + // PROPOSAL: API should be as such: + // if (is_string($tpl_var)) then $values are added/merged as already done + // if (is_array($tpl_var)) then $values is required to be an array whose + // keys must match up with $tpl_var keys and + // whose values are then what is added to + // each template variable value (array or + // strings, doesn't matter) if($merge && is_array($_val)) { foreach($_val as $_mkey => $_mval) @@ -178,6 +198,13 @@ class Template * * @param string $tpl_var the template variable name * @param mixed $value the referenced value to append + * @param boolean $merge when $value is given as an array, + * this indicates whether or not that + * array itself should be appended as + * a new template variable value or if + * that array's values should be merged + * into the existing array of template + * variable values */ function append_by_ref($tpl_var, &$value, $merge = FALSE) { -- 2.25.1