aboutsummaryrefslogtreecommitdiffstats
path: root/library/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php')
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php42
1 files changed, 27 insertions, 15 deletions
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php
index 0b7958197..584f70b0e 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php
@@ -42,10 +42,12 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
$compiler->has_code = false;
if ($_attr['type'] == 'xml') {
$compiler->tag_nocache = true;
- $save = $compiler->template->has_nocache_code;
+ $save = $compiler->template->compiled->has_nocache_code;
$output = addcslashes($_attr['code'], "'\\");
- $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $compiler->processNocacheCode("<?php echo '" . $output . "';?>", $compiler, true)));
- $compiler->template->has_nocache_code = $save;
+ $compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $compiler->processNocacheCode("<?php echo '" .
+ $output .
+ "';?>", $compiler, true)));
+ $compiler->template->compiled->has_nocache_code = $save;
return '';
}
if ($_attr['type'] != 'tag') {
@@ -53,29 +55,31 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
return '';
} elseif ($compiler->php_handling == Smarty::PHP_QUOTE) {
$output = preg_replace_callback('#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i', array($this,
- 'quote'), $_attr['code']);
- $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Text($compiler->parser, $output));
+ 'quote'), $_attr['code']);
+ $compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Text($output));
return '';
} elseif ($compiler->php_handling == Smarty::PHP_PASSTHRU || $_attr['type'] == 'unmatched') {
$compiler->tag_nocache = true;
- $save = $compiler->template->has_nocache_code;
+ $save = $compiler->template->compiled->has_nocache_code;
$output = addcslashes($_attr['code'], "'\\");
- $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $compiler->processNocacheCode("<?php echo '" . $output . "';?>", $compiler, true)));
- $compiler->template->has_nocache_code = $save;
+ $compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $compiler->processNocacheCode("<?php echo '" .
+ $output .
+ "';?>", $compiler, true)));
+ $compiler->template->compiled->has_nocache_code = $save;
return '';
} elseif ($compiler->php_handling == Smarty::PHP_ALLOW) {
if (!($compiler->smarty instanceof SmartyBC)) {
- $compiler->trigger_template_error('$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it', $compiler->lex->taglineno);
+ $compiler->trigger_template_error('$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it', null, true);
}
$compiler->has_code = true;
return $_attr['code'];
} else {
- $compiler->trigger_template_error('Illegal $smarty->php_handling value', $compiler->lex->taglineno);
+ $compiler->trigger_template_error('Illegal $smarty->php_handling value', null, true);
}
} else {
$compiler->has_code = true;
if (!($compiler->smarty instanceof SmartyBC)) {
- $compiler->trigger_template_error('{php}[/php} tags not allowed. Use SmartyBC to enable them', $compiler->lex->taglineno);
+ $compiler->trigger_template_error('{php}[/php} tags not allowed. Use SmartyBC to enable them', null, true);
}
$ldel = preg_quote($compiler->smarty->left_delimiter, '#');
$rdel = preg_quote($compiler->smarty->right_delimiter, '#');
@@ -84,11 +88,11 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
if ('nocache' == trim($match[2])) {
$compiler->tag_nocache = true;
} else {
- $compiler->trigger_template_error("illegal value of option flag \"{$match[2]}\"", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("illegal value of option flag \"{$match[2]}\"", null, true);
}
}
return preg_replace(array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#",
- "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"), array('<?php ', '?>'), $_attr['code']);
+ "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"), array('<?php ', '?>'), $_attr['code']);
}
}
@@ -140,7 +144,9 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
if ($lex->phpType == 'unmatched') {
return;
}
- if (($lex->phpType == 'php' || $lex->phpType == 'asp') && ($lex->compiler->php_handling == Smarty::PHP_PASSTHRU || $lex->compiler->php_handling == Smarty::PHP_QUOTE)) {
+ if (($lex->phpType == 'php' || $lex->phpType == 'asp') &&
+ ($lex->compiler->php_handling == Smarty::PHP_PASSTHRU || $lex->compiler->php_handling == Smarty::PHP_QUOTE)
+ ) {
return;
}
$start = $lex->counter + strlen($lex->value);
@@ -167,7 +173,8 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
}
}
while ($close > $pos && $close < $start) {
- if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $from)) {
+ if (preg_match('~' . preg_quote($closeTag, '~') .
+ '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $from)) {
$close = $match[0][1];
$from = $close + strlen($match[0][0]);
} else {
@@ -190,6 +197,11 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
* Call back function for $php_handling = PHP_QUOTE
*
*/
+ /**
+ * @param $match
+ *
+ * @return string
+ */
private function quote($match)
{
return htmlspecialchars($match[0], ENT_QUOTES);