55 $compiler->suppressNocacheProcessing =
true;
56 $compiler->tag_nocache =
true;
57 $_smarty_tpl = $compiler->template;
63 eval(
'$_name = ' . $_attr[
'name'] .
';');
64 if (isset($_attr[
'assign'])) {
66 $_assign = $_attr[
'assign'];
68 $compiler->template->tpl_vars[trim($_attr[
'assign'],
"'")] =
new Smarty_Variable(null,
true);
70 if (isset($_attr[
'script'])) {
72 $_function =
"smarty_insert_{$_name}";
73 $_smarty_tpl = $compiler->template;
75 eval(
'$_script = ' . $_attr[
'script'] .
';');
76 if (!isset($compiler->smarty->security_policy) && file_exists($_script)) {
77 $_filepath = $_script;
79 if (isset($compiler->smarty->security_policy)) {
80 $_dir = $compiler->smarty->security_policy->trusted_dir;
82 $_dir = $compiler->smarty->trusted_dir;
85 foreach((array)$_dir as $_script_dir) {
86 $_script_dir = rtrim($_script_dir,
'/\\') . DS;
87 if (file_exists($_script_dir . $_script)) {
88 $_filepath = $_script_dir . $_script;
94 if ($_filepath ==
false) {
95 $compiler->trigger_template_error(
"{insert} missing script file '{$_script}'", $compiler->lex->taglineno);
98 $_output .=
"require_once '{$_filepath}' ;";
99 require_once $_filepath;
100 if (!is_callable($_function)) {
101 $compiler->trigger_template_error(
" {insert} function '{$_function}' is not callable in script file '{$_script}'", $compiler->lex->taglineno);
105 $_function =
"insert_{$_name}";
107 if (!is_callable($_function)) {
109 if (!$_function = $compiler->getPlugin($_name,
'insert')) {
110 $compiler->trigger_template_error(
"{insert} no function or plugin found for '{$_name}'", $compiler->lex->taglineno);
115 unset($_attr[
'name'], $_attr[
'assign'], $_attr[
'script'], $_attr[
'nocache']);
117 $_paramsArray = array();
118 foreach ($_attr as $_key => $_value) {
119 $_paramsArray[] =
"'$_key' => $_value";
121 $_params =
'array(' . implode(
", ", $_paramsArray) .
')';
123 if (isset($_assign)) {
124 if ($_smarty_tpl->caching) {
125 $_output .=
"echo Smarty_Internal_Nocache_Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_filepath}',{$_assign});?>";
127 $_output .=
"\$_smarty_tpl->assign({$_assign} , {$_function} ({$_params},\$_smarty_tpl), true);?>";
130 $compiler->has_output =
true;
131 if ($_smarty_tpl->caching) {
132 $_output .=
"echo Smarty_Internal_Nocache_Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_filepath}');?>";
134 $_output .=
"echo {$_function}({$_params},\$_smarty_tpl);?>";
getAttributes($compiler, $attributes)
This function checks if the attributes passed are valid.
compile($args, $compiler)
Compiles code for the {insert} tag.