- bugfix Smarty version was not filled in header comment of compiled and cached files

- optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR (reverted from commit 1e787d08f1)
This commit is contained in:
Uwe Tews
2017-10-26 04:18:28 +02:00
parent 1e787d08f1
commit 42a292d56a
10 changed files with 348 additions and 309 deletions
@@ -1,4 +1,5 @@
<?php
/**
* Smarty Internal Plugin Compile Insert
* Compiles the {insert} tag
@@ -23,6 +24,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $required_attributes = array('name');
/**
* Attribute definition: Overwrites base class.
*
@@ -30,6 +32,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $shorttag_order = array('name');
/**
* Attribute definition: Overwrites base class.
*
@@ -53,6 +56,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
$_attr = $this->getAttributes($compiler, $args);
//Does tag create output
$compiler->has_output = isset($_attr[ 'assign' ]) ? false : true;
$nocacheParam = $compiler->template->caching && ($compiler->tag_nocache || $compiler->nocache);
if (!$nocacheParam) {
// do not compile as nocache code
@@ -62,6 +66,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
$_smarty_tpl = $compiler->template;
$_name = null;
$_script = null;
$_output = '<?php ';
// save possible attributes
eval('$_name = @' . $_attr[ 'name' ] . ';');
@@ -91,8 +96,8 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
$_dir = $compiler->smarty instanceof SmartyBC ? $compiler->smarty->trusted_dir : null;
}
if (!empty($_dir)) {
foreach ((array)$_dir as $_script_dir) {
$_script_dir = rtrim($_script_dir, '/\\') . DIRECTORY_SEPARATOR;
foreach ((array) $_dir as $_script_dir) {
$_script_dir = rtrim($_script_dir, '/\\') . $compiler->smarty->ds;
if (file_exists($_script_dir . $_script)) {
$_filepath = $_script_dir . $_script;
break;
@@ -108,8 +113,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
require_once $_filepath;
if (!is_callable($_function)) {
$compiler->trigger_template_error(" {insert} function '{$_function}' is not callable in script file '{$_script}'",
null,
true);
null, true);
}
} else {
$_filepath = 'null';
@@ -118,8 +122,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
if (!is_callable($_function)) {
// try plugin
if (!$_function = $compiler->getPlugin($_name, 'insert')) {
$compiler->trigger_template_error("{insert} no function or plugin found for '{$_name}'",
null,
$compiler->trigger_template_error("{insert} no function or plugin found for '{$_name}'", null,
true);
}
}
@@ -146,6 +149,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
$_output .= "echo {$_function}({$_params},\$_smarty_tpl);?>";
}
}
return $_output;
}
}