add $smarty.config.foo var, handle embedded smarty var correctly

This commit is contained in:
mohrt
2003-02-24 14:51:47 +00:00
parent 52f15b67b2
commit 3e755114a3
2 changed files with 12 additions and 1 deletions

3
NEWS
View File

@@ -1,3 +1,6 @@
- handle embedded "$smarty.config.foo.tpl" correctly (Monte)
- add $smarty.config.varname variable for accessing config vars (Paul
Lockaby, Monte)
- silence PHP warnings in function.fetch.php (Eduardo,
Monte)
- added get_config_vars(), same basic functionality as

View File

@@ -1446,7 +1446,7 @@ class Smarty_Compiler extends Smarty {
function _expand_quoted_text($var_expr)
{
// if contains unescaped $, expand it
if(preg_match_all('%(?<!\\\\)\$(?:smarty(?:\.\w+)+|\w+(?:' . $this->_var_bracket_regexp . ')*)%', $var_expr, $match)) {
if(preg_match_all('%(?<!\\\\)\$(?:smarty(?:\.\w+){1,2}|\w+(?:' . $this->_var_bracket_regexp . ')*)%', $var_expr, $match)) {
rsort($match[0]);
reset($match[0]);
foreach($match[0] as $var) {
@@ -1770,6 +1770,14 @@ class Smarty_Compiler extends Smarty {
$compiled_ref = '(defined("' . substr($indexes[0],1) . '") ? ' . substr($indexes[0],1) . ' : null)';
break;
case 'config':
array_shift($indexes);
$name = substr($indexes[0], 1);
$compiled_ref = "\$this->_config[0]['vars']";
if ($name = substr($indexes[0], 1))
$compiled_ref .= "['$name']";
break;
default:
$this->_syntax_error('$smarty.' . $ref . ' is an unknown reference', E_USER_ERROR, __FILE__, __LINE__);
break;