From 04307bb5605d9613054f6b6eb7faa849292f4b10 Mon Sep 17 00:00:00 2001 From: messju Date: Wed, 14 Jan 2004 16:16:24 +0000 Subject: [PATCH] removed suggestions to use extract() from the manual --- docs/appendixes.sgml | 7 +++---- docs/programmers.sgml | 29 ++++++++++------------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/docs/appendixes.sgml b/docs/appendixes.sgml index 7f6eb533..a82585ac 100644 --- a/docs/appendixes.sgml +++ b/docs/appendixes.sgml @@ -230,12 +230,11 @@ function makeTimeStamp($year="",$month="",$day="") // be sure apache is configure for the .wml extensions! // put this function somewhere in your application, or in Smarty.addons.php -function insert_header() { +function insert_header($params) { // this function expects $content argument - extract(func_get_arg(0)); - if(empty($content)) + if(empty($params['content'])) return; - header($content); + header($params['content']); return; } diff --git a/docs/programmers.sgml b/docs/programmers.sgml index de90be90..d787ac08 100644 --- a/docs/programmers.sgml +++ b/docs/programmers.sgml @@ -1221,9 +1221,10 @@ function do_translation ($params, $content, &$smarty, &$repeat) { $smarty->register_function("date_now", "print_current_date"); function print_current_date ($params) { - extract($params); - if(empty($format)) - $format="%b %e, %Y"; + if(empty($params['format'])) + $format = "%b %e, %Y"; + else + $format = $params['format']; return strftime($format,time()); } @@ -2622,10 +2623,7 @@ require_once $smarty->_get_plugin_filepath('function', 'html_options'); All attributes passed to template functions from the template are contained in the $params as an associative - array. Either access those values directly, e.g. - $params['start'] or use - extract($params) to import them into the symbol - table. + array. The output (return value) of the function will be substituted in place of the @@ -2694,9 +2692,7 @@ Answer: {eightball}. */ function smarty_function_assign($params, &$smarty) { - extract($params); - - if (empty($var)) { + if (empty($params['var'])) { $smarty->trigger_error("assign: missing 'var' parameter"); return; } @@ -2706,7 +2702,7 @@ function smarty_function_assign($params, &$smarty) return; } - $smarty->assign($var, $value); + $smarty->assign($params['var'], $params['value']); } ?> @@ -2825,10 +2821,8 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', Only the opening tag of the block function may have attributes. All attributes passed to template functions from the template are contained in the $params as an associative array. You can - either access those values directly, e.g. - $params['start'] or use - extract($params) to import them into the symbol - table. The opening tag attributes are also accessible to your function + access those values as e.g. $params['start']. + The opening tag attributes are also accessible to your function when processing the closing tag. @@ -3221,10 +3215,7 @@ function smarty_resource_db_trusted($tpl_name, &$smarty) The first parameter to the function is an associative array of - attributes passed to the insert. Either access those values directly, - e.g. $params['start'] or use - extract($params) to import them into the symbol - table. + attributes passed to the insert. The insert function is supposed to return the result which will be