function Smarty_Compiler::_compile_custom_tag in Quiz 6.5
Same name and namespace in other branches
- 6.6 includes/moodle/lib/smarty/Smarty_Compiler.class.php \Smarty_Compiler::_compile_custom_tag()
compile custom function tag
Parameters
string $tag_command:
string $tag_args:
string $tag_modifier:
Return value
string
1 call to Smarty_Compiler::_compile_custom_tag()
- Smarty_Compiler::_compile_tag in includes/
moodle/ lib/ smarty/ Smarty_Compiler.class.php - Compile a template tag
File
- includes/
moodle/ lib/ smarty/ Smarty_Compiler.class.php, line 754
Class
- Smarty_Compiler
- Template compiling class @package Smarty
Code
function _compile_custom_tag($tag_command, $tag_args, $tag_modifier, &$output) {
$found = false;
$have_function = true;
/*
* First we check if the custom function has already been registered
* or loaded from a plugin file.
*/
if (isset($this->_plugins['function'][$tag_command])) {
$found = true;
$plugin_func = $this->_plugins['function'][$tag_command][0];
if (!is_callable($plugin_func)) {
$message = "custom function '{$tag_command}' is not implemented";
$have_function = false;
}
}
else {
if ($plugin_file = $this
->_get_plugin_filepath('function', $tag_command)) {
$found = true;
include_once $plugin_file;
$plugin_func = 'smarty_function_' . $tag_command;
if (!function_exists($plugin_func)) {
$message = "plugin function {$plugin_func}() not found in {$plugin_file}\n";
$have_function = false;
}
else {
$this->_plugins['function'][$tag_command] = array(
$plugin_func,
null,
null,
null,
true,
);
}
}
}
if (!$found) {
return false;
}
else {
if (!$have_function) {
$this
->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
return true;
}
}
/* declare plugin to be loaded on display of the template that
we compile right now */
$this
->_add_plugin('function', $tag_command);
$_cacheable_state = $this
->_push_cacheable_state('function', $tag_command);
$attrs = $this
->_parse_attrs($tag_args);
$arg_list = $this
->_compile_arg_list('function', $tag_command, $attrs, $_cache_attrs = '');
$output = $this
->_compile_plugin_call('function', $tag_command) . '(array(' . implode(',', $arg_list) . "), \$this)";
if ($tag_modifier != '') {
$this
->_parse_modifiers($output, $tag_modifier);
}
if ($output != '') {
$output = '<?php ' . $_cacheable_state . $_cache_attrs . 'echo ' . $output . ';' . $this
->_pop_cacheable_state('function', $tag_command) . "?>" . $this->_additional_newline;
}
return true;
}