aboutsummaryrefslogtreecommitdiffstats
path: root/library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2015-12-06 21:09:58 +0100
committerMario Vavti <mario@mariovavti.com>2015-12-06 21:09:58 +0100
commit26c465ad0c1d5b6801507ed190430f44ac92c672 (patch)
tree9e80c34da1235e6dd55942c23bf9511fac31344d /library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php
parentf2d70831838b0738e6895296f3e8ce02f86fec2f (diff)
downloadvolse-hubzilla-26c465ad0c1d5b6801507ed190430f44ac92c672.tar.gz
volse-hubzilla-26c465ad0c1d5b6801507ed190430f44ac92c672.tar.bz2
volse-hubzilla-26c465ad0c1d5b6801507ed190430f44ac92c672.zip
update smarty to 3.1.28-dev which fixes a bug where changes in a template are only visible on the second pageload which is annoying for developing
Diffstat (limited to 'library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php')
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php28
1 files changed, 16 insertions, 12 deletions
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php
index 76f506c52..e7e62997c 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php
@@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $required_attributes = array('file');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -30,6 +31,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $shorttag_order = array('file');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -41,13 +43,14 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
/**
* Compiles code for the {include_php} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
*
- * @throws SmartyException
- * @return string compiled code
+ * @return string
+ * @throws \SmartyCompilerException
+ * @throws \SmartyException
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
if (!($compiler->smarty instanceof SmartyBC)) {
throw new SmartyException("{include_php} is deprecated, use SmartyBC class to enable");
@@ -60,9 +63,10 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
*/
$_smarty_tpl = $compiler->template;
$_filepath = false;
- eval('$_file = ' . $_attr['file'] . ';');
+ $_file = null;
+ eval('$_file = @' . $_attr['file'] . ';');
if (!isset($compiler->smarty->security_policy) && file_exists($_file)) {
- $_filepath = $_file;
+ $_filepath = $compiler->smarty->_realpath($_file, true);
} else {
if (isset($compiler->smarty->security_policy)) {
$_dir = $compiler->smarty->security_policy->trusted_dir;
@@ -71,16 +75,16 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
}
if (!empty($_dir)) {
foreach ((array) $_dir as $_script_dir) {
- $_script_dir = rtrim($_script_dir, '/\\') . DS;
- if (file_exists($_script_dir . $_file)) {
- $_filepath = $_script_dir . $_file;
+ $_path = $compiler->smarty->_realpath($_script_dir . DS . $_file, true);
+ if (file_exists($_path)) {
+ $_filepath = $_path;
break;
}
}
}
}
if ($_filepath == false) {
- $compiler->trigger_template_error("{include_php} file '{$_file}' is not readable", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("{include_php} file '{$_file}' is not readable", null, true);
}
if (isset($compiler->smarty->security_policy)) {
@@ -99,7 +103,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
}
if (isset($_assign)) {
- return "<?php ob_start(); include{$_once} ('{$_filepath}'); \$_smarty_tpl->assign({$_assign},ob_get_contents()); ob_end_clean();?>";
+ return "<?php ob_start();\ninclude{$_once} ('{$_filepath}');\n\$_smarty_tpl->assign({$_assign},ob_get_clean());\n?>";
} else {
return "<?php include{$_once} ('{$_filepath}');?>\n";
}