mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 09:54:27 +02:00
*** empty log message ***
This commit is contained in:
@@ -15,10 +15,10 @@
|
|||||||
function _smarty_mod_handler()
|
function _smarty_mod_handler()
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$func_name = array_shift($args);
|
list($func_name, $map_array) = array_splice($args, 0, 2);
|
||||||
$var = $args[0];
|
$var = $args[0];
|
||||||
|
|
||||||
if (is_array($var)) {
|
if ($map_array && is_array($var)) {
|
||||||
foreach ($var as $key => $val) {
|
foreach ($var as $key => $val) {
|
||||||
$args[0] = $val;
|
$args[0] = $val;
|
||||||
$var[$key] = call_user_func_array($func_name, $args);
|
$var[$key] = call_user_func_array($func_name, $args);
|
||||||
|
@@ -176,7 +176,7 @@ class Smarty
|
|||||||
function fetch($tpl_file)
|
function fetch($tpl_file)
|
||||||
{
|
{
|
||||||
ob_start();
|
ob_start();
|
||||||
$this->quip($tpl_file);
|
$this->display($tpl_file);
|
||||||
$results = ob_get_contents();
|
$results = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
return $results;
|
return $results;
|
||||||
@@ -394,9 +394,9 @@ class Smarty
|
|||||||
|
|
||||||
/* If the tag name matches a variable or section property definition,
|
/* If the tag name matches a variable or section property definition,
|
||||||
we simply process it. */
|
we simply process it. */
|
||||||
if (preg_match('!^\$(\w+/)*\w+(?>\|\w+(:[^|]+)?)*$!', $tag_command) || // if a variable
|
if (preg_match('!^\$(\w+/)*\w+(?>\|@?\w+(:[^|]+)?)*$!', $tag_command) || // if a variable
|
||||||
preg_match('!^#(\w+)#(?>\|\w+(:[^|]+)?)*$!', $tag_command) || // or a configuration variable
|
preg_match('!^#(\w+)#(?>\|@?\w+(:[^|]+)?)*$!', $tag_command) || // or a configuration variable
|
||||||
preg_match('!^%\w+\.\w+%(?>\|\w+(:[^|]+)?)*$!', $tag_command)) { // or a section property
|
preg_match('!^%\w+\.\w+%(?>\|@?\w+(:[^|]+)?)*$!', $tag_command)) { // or a section property
|
||||||
settype($tag_command, 'array');
|
settype($tag_command, 'array');
|
||||||
$this->_parse_vars_props($tag_command);
|
$this->_parse_vars_props($tag_command);
|
||||||
return "<?php print $tag_command[0]; ?>";
|
return "<?php print $tag_command[0]; ?>";
|
||||||
@@ -787,9 +787,9 @@ class Smarty
|
|||||||
|
|
||||||
function _parse_vars_props(&$tokens)
|
function _parse_vars_props(&$tokens)
|
||||||
{
|
{
|
||||||
$var_exprs = preg_grep('!^\$(\w+/)*\w+(?>\|\w+(:[^|]+)?)*$!', $tokens);
|
$var_exprs = preg_grep('!^\$(\w+/)*\w+(?>\|@?\w+(:[^|]+)?)*$!', $tokens);
|
||||||
$conf_var_exprs = preg_grep('!^#(\w+)#(?>\|\w+(:[^|]+)?)*$!', $tokens);
|
$conf_var_exprs = preg_grep('!^#(\w+)#(?>\|@?\w+(:[^|]+)?)*$!', $tokens);
|
||||||
$sect_prop_exprs = preg_grep('!^%\w+\.\w+%(?>\|\w+(:[^|]+)?)*$!', $tokens);
|
$sect_prop_exprs = preg_grep('!^%\w+\.\w+%(?>\|@?\w+(:[^|]+)?)*$!', $tokens);
|
||||||
|
|
||||||
if (count($var_exprs)) {
|
if (count($var_exprs)) {
|
||||||
foreach ($var_exprs as $expr_index => $var_expr) {
|
foreach ($var_exprs as $expr_index => $var_expr) {
|
||||||
@@ -862,6 +862,12 @@ class Smarty
|
|||||||
$modifier = explode(':', $modifier);
|
$modifier = explode(':', $modifier);
|
||||||
$modifier_name = array_shift($modifier);
|
$modifier_name = array_shift($modifier);
|
||||||
|
|
||||||
|
if ($modifier_name{0} == '@') {
|
||||||
|
$map_array = 'false';
|
||||||
|
$modifier_name = substr($modifier_name, 1);
|
||||||
|
} else
|
||||||
|
$map_array = 'true';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First we lookup the modifier function name in the registered
|
* First we lookup the modifier function name in the registered
|
||||||
* modifiers table.
|
* modifiers table.
|
||||||
@@ -883,7 +889,7 @@ class Smarty
|
|||||||
else
|
else
|
||||||
$modifier_args = '';
|
$modifier_args = '';
|
||||||
|
|
||||||
$output = "_smarty_mod_handler('$mod_func_name', $output$modifier_args)";
|
$output = "_smarty_mod_handler('$mod_func_name', $map_array, $output$modifier_args)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,3 +18,4 @@ My interests are:
|
|||||||
none
|
none
|
||||||
{/section}
|
{/section}
|
||||||
|
|
||||||
|
{$Name|@count}
|
||||||
|
@@ -176,7 +176,7 @@ class Smarty
|
|||||||
function fetch($tpl_file)
|
function fetch($tpl_file)
|
||||||
{
|
{
|
||||||
ob_start();
|
ob_start();
|
||||||
$this->quip($tpl_file);
|
$this->display($tpl_file);
|
||||||
$results = ob_get_contents();
|
$results = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
return $results;
|
return $results;
|
||||||
@@ -394,9 +394,9 @@ class Smarty
|
|||||||
|
|
||||||
/* If the tag name matches a variable or section property definition,
|
/* If the tag name matches a variable or section property definition,
|
||||||
we simply process it. */
|
we simply process it. */
|
||||||
if (preg_match('!^\$(\w+/)*\w+(?>\|\w+(:[^|]+)?)*$!', $tag_command) || // if a variable
|
if (preg_match('!^\$(\w+/)*\w+(?>\|@?\w+(:[^|]+)?)*$!', $tag_command) || // if a variable
|
||||||
preg_match('!^#(\w+)#(?>\|\w+(:[^|]+)?)*$!', $tag_command) || // or a configuration variable
|
preg_match('!^#(\w+)#(?>\|@?\w+(:[^|]+)?)*$!', $tag_command) || // or a configuration variable
|
||||||
preg_match('!^%\w+\.\w+%(?>\|\w+(:[^|]+)?)*$!', $tag_command)) { // or a section property
|
preg_match('!^%\w+\.\w+%(?>\|@?\w+(:[^|]+)?)*$!', $tag_command)) { // or a section property
|
||||||
settype($tag_command, 'array');
|
settype($tag_command, 'array');
|
||||||
$this->_parse_vars_props($tag_command);
|
$this->_parse_vars_props($tag_command);
|
||||||
return "<?php print $tag_command[0]; ?>";
|
return "<?php print $tag_command[0]; ?>";
|
||||||
@@ -787,9 +787,9 @@ class Smarty
|
|||||||
|
|
||||||
function _parse_vars_props(&$tokens)
|
function _parse_vars_props(&$tokens)
|
||||||
{
|
{
|
||||||
$var_exprs = preg_grep('!^\$(\w+/)*\w+(?>\|\w+(:[^|]+)?)*$!', $tokens);
|
$var_exprs = preg_grep('!^\$(\w+/)*\w+(?>\|@?\w+(:[^|]+)?)*$!', $tokens);
|
||||||
$conf_var_exprs = preg_grep('!^#(\w+)#(?>\|\w+(:[^|]+)?)*$!', $tokens);
|
$conf_var_exprs = preg_grep('!^#(\w+)#(?>\|@?\w+(:[^|]+)?)*$!', $tokens);
|
||||||
$sect_prop_exprs = preg_grep('!^%\w+\.\w+%(?>\|\w+(:[^|]+)?)*$!', $tokens);
|
$sect_prop_exprs = preg_grep('!^%\w+\.\w+%(?>\|@?\w+(:[^|]+)?)*$!', $tokens);
|
||||||
|
|
||||||
if (count($var_exprs)) {
|
if (count($var_exprs)) {
|
||||||
foreach ($var_exprs as $expr_index => $var_expr) {
|
foreach ($var_exprs as $expr_index => $var_expr) {
|
||||||
@@ -862,6 +862,12 @@ class Smarty
|
|||||||
$modifier = explode(':', $modifier);
|
$modifier = explode(':', $modifier);
|
||||||
$modifier_name = array_shift($modifier);
|
$modifier_name = array_shift($modifier);
|
||||||
|
|
||||||
|
if ($modifier_name{0} == '@') {
|
||||||
|
$map_array = 'false';
|
||||||
|
$modifier_name = substr($modifier_name, 1);
|
||||||
|
} else
|
||||||
|
$map_array = 'true';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First we lookup the modifier function name in the registered
|
* First we lookup the modifier function name in the registered
|
||||||
* modifiers table.
|
* modifiers table.
|
||||||
@@ -883,7 +889,7 @@ class Smarty
|
|||||||
else
|
else
|
||||||
$modifier_args = '';
|
$modifier_args = '';
|
||||||
|
|
||||||
$output = "_smarty_mod_handler('$mod_func_name', $output$modifier_args)";
|
$output = "_smarty_mod_handler('$mod_func_name', $map_array, $output$modifier_args)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,3 +18,4 @@ My interests are:
|
|||||||
none
|
none
|
||||||
{/section}
|
{/section}
|
||||||
|
|
||||||
|
{$Name|@count}
|
||||||
|
Reference in New Issue
Block a user