X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=class%2Ftemplate%2FPHP_Template.class.php;h=15ee4b427cc68b8f43ca149c56af462bd9e74eb7;hp=7bc8ad62dd7ec097da254d025fea39a6581aad2e;hb=caf0ab1de11a5cafc878e424ef0d55dbc0350dd1;hpb=de4d58cb7fdcda16e5129a26db1a6a3d46d6594f diff --git a/class/template/PHP_Template.class.php b/class/template/PHP_Template.class.php index 7bc8ad62..15ee4b42 100644 --- a/class/template/PHP_Template.class.php +++ b/class/template/PHP_Template.class.php @@ -9,7 +9,7 @@ * The SquirrelMail (Foowd) template implementation. * Derived from the foowd template implementation and adapted * for squirrelmail - * @copyright © 2005-2006 The SquirrelMail Project Team + * @copyright 2005-2019 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package squirrelmail @@ -23,7 +23,7 @@ * @author Paul James * @author Monte Ohrt * @author Andrei Zmievski - * @author Paul Lesniewski + * @author Paul Lesniewski * @package squirrelmail * */ @@ -65,7 +65,7 @@ class PHP_Template extends Template * @param mixed $value the value to assign FIXME: Proposed idea to add a parameter here that turns variable encoding on, so that we can make sure output is always - run through something like htmlspecialchars() (maybe even nl2br()?) + run through something like sm_encode_html_special_chars() (maybe even nl2br()?) * */ function assign($tpl_var, $value = NULL) { @@ -93,7 +93,7 @@ FIXME: Proposed idea to add a parameter here that turns variable * @param mixed $value the referenced value to assign FIXME: Proposed idea to add a parameter here that turns variable encoding on, so that we can make sure output is always - run through something like htmlspecialchars() (maybe even nl2br()?) + run through something like sm_encode_html_special_chars() (maybe even nl2br()?) * */ function assign_by_ref($tpl_var, &$value) { @@ -103,6 +103,48 @@ FIXME: Proposed idea to add a parameter here that turns variable } + /** + * Clears the values of all assigned varaiables. + * + */ + function clear_all_assign() { + + $this->values = array(); + + } + + /** + * Returns assigned variable value(s). + * + * @param string $varname If given, the value of that variable + * is returned, assuming it has been + * previously assigned. If not specified + * an array of all assigned variables is + * returned. (optional) + * + * @return mixed Desired single variable value or list of all + * assigned variable values. + * + */ + function get_template_vars($varname=NULL) { + + // just looking for one value + // + if (!empty($varname)) { + if (!empty($this->values[$varname])) + return $this->values[$varname]; + else +// FIXME: this OK? What does Smarty do? + return NULL; + } + + + // return all variable values + // + return $this->values; + + } + /** * Appends values to template variables * @@ -117,7 +159,7 @@ FIXME: Proposed idea to add a parameter here that turns variable * variable values FIXME: Proposed idea to add a parameter here that turns variable encoding on, so that we can make sure output is always - run through something like htmlspecialchars() (maybe even nl2br()?) + run through something like sm_encode_html_special_chars() (maybe even nl2br()?) * */ function append($tpl_var, $value = NULL, $merge = FALSE) @@ -178,7 +220,7 @@ FIXME: Proposed idea to add a parameter here that turns variable * variable values FIXME: Proposed idea to add a parameter here that turns variable encoding on, so that we can make sure output is always - run through something like htmlspecialchars() (maybe even nl2br()?) + run through something like sm_encode_html_special_chars() (maybe even nl2br()?) * */ function append_by_ref($tpl_var, &$value, $merge = FALSE)