diff --git a/Smarty.addons.php b/Smarty.addons.php index 3d91233c..8fc6a3c8 100644 --- a/Smarty.addons.php +++ b/Smarty.addons.php @@ -201,6 +201,30 @@ function smarty_mod_default($string, $default="") return $string; } +/*======================================================================*\ + Function: smarty_func_assign + Purpose: assign a value to a template variable +\*======================================================================*/ +function smarty_func_assign($vars,&$smarty_obj) +{ + extract($vars); + $smarty_obj->assign($var,$val); + $smarty_obj->_extract = true; + return true; +} + +/*======================================================================*\ + Function: smarty_func_unassign + Purpose: unassign a template variable +\*======================================================================*/ +function smarty_func_unassign($vars,&$smarty_obj) +{ + extract($vars); + $smarty_obj->clear_assign($var); + $smarty_obj->_extract = true; + return true; +} + /*============================================*\ Custom tag functions \*============================================*/ diff --git a/Smarty.class.php b/Smarty.class.php index 59523ba9..8381e71a 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -120,7 +120,9 @@ class Smarty 'html_select_time' => 'smarty_func_html_select_time', 'math' => 'smarty_func_math', 'fetch' => 'smarty_func_fetch', - 'counter' => 'smarty_func_counter' + 'counter' => 'smarty_func_counter', + 'assign' => 'smarty_func_assign', + 'unassign' => 'smarty_func_unassign' ); var $custom_mods = array( 'lower' => 'strtolower', @@ -159,9 +161,9 @@ class Smarty var $_sections = array(); // keeps track of sections var $_conf_obj = null; // configuration object var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty' - var $_version = '1.4.2'; // Smarty version number - - + var $_version = '1.4.2'; // Smarty version number + var $_extract = false; // flag for custom functions + /*======================================================================*\ Function: Smarty Purpose: Constructor diff --git a/Smarty_Compiler.class.php b/Smarty_Compiler.class.php index ce7c3470..6e89bbf9 100644 --- a/Smarty_Compiler.class.php +++ b/Smarty_Compiler.class.php @@ -309,7 +309,7 @@ class Smarty_Compiler extends Smarty { $arg_list[] = "'$arg_name' => $arg_value"; } - return ""; + return "_extract) { extract(\$this->_tpl_vars); \$this->_extract=false; } ?>"; } diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 59523ba9..8381e71a 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -120,7 +120,9 @@ class Smarty 'html_select_time' => 'smarty_func_html_select_time', 'math' => 'smarty_func_math', 'fetch' => 'smarty_func_fetch', - 'counter' => 'smarty_func_counter' + 'counter' => 'smarty_func_counter', + 'assign' => 'smarty_func_assign', + 'unassign' => 'smarty_func_unassign' ); var $custom_mods = array( 'lower' => 'strtolower', @@ -159,9 +161,9 @@ class Smarty var $_sections = array(); // keeps track of sections var $_conf_obj = null; // configuration object var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty' - var $_version = '1.4.2'; // Smarty version number - - + var $_version = '1.4.2'; // Smarty version number + var $_extract = false; // flag for custom functions + /*======================================================================*\ Function: Smarty Purpose: Constructor diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index ce7c3470..6e89bbf9 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -309,7 +309,7 @@ class Smarty_Compiler extends Smarty { $arg_list[] = "'$arg_name' => $arg_value"; } - return ""; + return "_extract) { extract(\$this->_tpl_vars); \$this->_extract=false; } ?>"; }