diff --git a/Smarty.addons.php b/Smarty.addons.php index f90e04ad..d5eee926 100644 --- a/Smarty.addons.php +++ b/Smarty.addons.php @@ -24,8 +24,9 @@ function _smarty_mod_handler() $var[$key] = call_user_func_array($func_name, $args); } return $var; - } else + } else { return call_user_func_array($func_name, $args); + } } @@ -91,6 +92,13 @@ function smarty_mod_replace($string, $search, $replace) return str_replace($search, $replace, $string); } +function smarty_mod_strip_tags($string, $replace_with_space = false) +{ + if ($replace_with_space) + return preg_replace('!<[^>]*?>!', ' ', $string); + else + return strip_tags($string); +} /*============================================*\ Custom tag functions diff --git a/Smarty.class.php b/Smarty.class.php index f447944d..447aa714 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -53,7 +53,8 @@ class Smarty 'spacify' => 'smarty_mod_spacify', 'date_format' => 'smarty_mod_date_format', 'string_format' => 'smarty_mod_string_format', - 'replace' => 'smarty_mod_replace' + 'replace' => 'smarty_mod_replace', + 'strip_tags' => 'smarty_mod_strip_tags' ); var $global_assign = array( 'SCRIPT_NAME' ); @@ -541,13 +542,13 @@ class Smarty } return "_tpl_vars, array(".implode(',', (array)$arg_list)."));\n?>\n"; + "$include_func_name(\"$include_file_name\", get_defined_vars(), array(".implode(',', (array)$arg_list)."));\n?>\n"; } else return 'template_dir.$this->compile_dir_ext.'/'.$attrs['file'].'"; ?>'; } @@ -599,6 +600,7 @@ class Smarty for ({$section_props}['index'] = 0; {$section_props}['index'] < {$section_props}['loop']; {$section_props}['index']++):\n"; + $output .= "{$section_props}['rownum'] = {$section_props}['index'] + 1;\n"; $output .= "?>\n"; diff --git a/demo/templates/header.tpl b/demo/templates/header.tpl index 5c4c868d..018d027d 100644 --- a/demo/templates/header.tpl +++ b/demo/templates/header.tpl @@ -1,3 +1,3 @@ -{$title} - {$section} +{$title} - {$Name} diff --git a/demo/templates/index.tpl b/demo/templates/index.tpl index e11c356d..460aabe3 100644 --- a/demo/templates/index.tpl +++ b/demo/templates/index.tpl @@ -1,4 +1,5 @@ {config_load file=test.conf section="my foo"} +{include file=header.tpl title=foo} Title: {#title#|capitalize} diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index f447944d..447aa714 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -53,7 +53,8 @@ class Smarty 'spacify' => 'smarty_mod_spacify', 'date_format' => 'smarty_mod_date_format', 'string_format' => 'smarty_mod_string_format', - 'replace' => 'smarty_mod_replace' + 'replace' => 'smarty_mod_replace', + 'strip_tags' => 'smarty_mod_strip_tags' ); var $global_assign = array( 'SCRIPT_NAME' ); @@ -541,13 +542,13 @@ class Smarty } return "_tpl_vars, array(".implode(',', (array)$arg_list)."));\n?>\n"; + "$include_func_name(\"$include_file_name\", get_defined_vars(), array(".implode(',', (array)$arg_list)."));\n?>\n"; } else return 'template_dir.$this->compile_dir_ext.'/'.$attrs['file'].'"; ?>'; } @@ -599,6 +600,7 @@ class Smarty for ({$section_props}['index'] = 0; {$section_props}['index'] < {$section_props}['loop']; {$section_props}['index']++):\n"; + $output .= "{$section_props}['rownum'] = {$section_props}['index'] + 1;\n"; $output .= "?>\n"; diff --git a/templates/header.tpl b/templates/header.tpl index 5c4c868d..018d027d 100644 --- a/templates/header.tpl +++ b/templates/header.tpl @@ -1,3 +1,3 @@ -{$title} - {$section} +{$title} - {$Name} diff --git a/templates/index.tpl b/templates/index.tpl index e11c356d..460aabe3 100644 --- a/templates/index.tpl +++ b/templates/index.tpl @@ -1,4 +1,5 @@ {config_load file=test.conf section="my foo"} +{include file=header.tpl title=foo} Title: {#title#|capitalize}