function Smarty_Compiler::_compile_compiler_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_compiler_tag()
compile the custom compiler tag
sets $output to the compiled custom compiler tag
Parameters
string $tag_command:
string $tag_args:
string $output:
Return value
boolean
1 call to Smarty_Compiler::_compile_compiler_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 595
Class
- Smarty_Compiler
- Template compiling class @package Smarty
Code
function _compile_compiler_tag($tag_command, $tag_args, &$output) {
$found = false;
$have_function = true;
/*
* First we check if the compiler function has already been registered
* or loaded from a plugin file.
*/
if (isset($this->_plugins['compiler'][$tag_command])) {
$found = true;
$plugin_func = $this->_plugins['compiler'][$tag_command][0];
if (!is_callable($plugin_func)) {
$message = "compiler function '{$tag_command}' is not implemented";
$have_function = false;
}
}
else {
if ($plugin_file = $this
->_get_plugin_filepath('compiler', $tag_command)) {
$found = true;
include_once $plugin_file;
$plugin_func = 'smarty_compiler_' . $tag_command;
if (!is_callable($plugin_func)) {
$message = "plugin function {$plugin_func}() not found in {$plugin_file}\n";
$have_function = false;
}
else {
$this->_plugins['compiler'][$tag_command] = array(
$plugin_func,
null,
null,
null,
true,
);
}
}
}
/*
* True return value means that we either found a plugin or a
* dynamically registered function. False means that we didn't and the
* compiler should now emit code to load custom function plugin for this
* tag.
*/
if ($found) {
if ($have_function) {
$output = call_user_func_array($plugin_func, array(
$tag_args,
&$this,
));
if ($output != '') {
$output = '<?php ' . $this
->_push_cacheable_state('compiler', $tag_command) . $output . $this
->_pop_cacheable_state('compiler', $tag_command) . ' ?>';
}
}
else {
$this
->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
}
return true;
}
else {
return false;
}
}