function Smarty::_fetch_resource_info in Quiz 6.6
Same name and namespace in other branches
- 6.5 includes/moodle/lib/smarty/Smarty.class.php \Smarty::_fetch_resource_info()
fetch the template info. Gets timestamp, and source if get_source is true
sets $source_content to the source of the template, and $resource_timestamp to its time stamp
Parameters
string $resource_name:
string $source_content:
integer $resource_timestamp:
boolean $get_source:
boolean $quiet:
Return value
boolean
3 calls to Smarty::_fetch_resource_info()
- Smarty::template_exists in includes/
moodle/ lib/ smarty/ Smarty.class.php - Checks whether requested template exists.
- Smarty::_compile_resource in includes/
moodle/ lib/ smarty/ Smarty.class.php - compile the template
- Smarty::_is_compiled in includes/
moodle/ lib/ smarty/ Smarty.class.php - test if resource needs compiling
File
- includes/
moodle/ lib/ smarty/ Smarty.class.php, line 1525
Class
- Smarty
- @package Smarty
Code
function _fetch_resource_info(&$params) {
if (!isset($params['get_source'])) {
$params['get_source'] = true;
}
if (!isset($params['quiet'])) {
$params['quiet'] = false;
}
$_return = false;
$_params = array(
'resource_name' => $params['resource_name'],
);
if (isset($params['resource_base_path'])) {
$_params['resource_base_path'] = $params['resource_base_path'];
}
else {
$_params['resource_base_path'] = $this->template_dir;
}
if ($this
->_parse_resource_name($_params)) {
$_resource_type = $_params['resource_type'];
$_resource_name = $_params['resource_name'];
switch ($_resource_type) {
case 'file':
if ($params['get_source']) {
$params['source_content'] = $this
->_read_file($_resource_name);
}
$params['resource_timestamp'] = filemtime($_resource_name);
$_return = is_file($_resource_name);
break;
default:
// call resource functions to fetch the template source and timestamp
if ($params['get_source']) {
$_source_return = isset($this->_plugins['resource'][$_resource_type]) && call_user_func_array($this->_plugins['resource'][$_resource_type][0][0], array(
$_resource_name,
&$params['source_content'],
&$this,
));
}
else {
$_source_return = true;
}
$_timestamp_return = isset($this->_plugins['resource'][$_resource_type]) && call_user_func_array($this->_plugins['resource'][$_resource_type][0][1], array(
$_resource_name,
&$params['resource_timestamp'],
&$this,
));
$_return = $_source_return && $_timestamp_return;
break;
}
}
if (!$_return) {
// see if we can get a template with the default template handler
if (!empty($this->default_template_handler_func)) {
if (!is_callable($this->default_template_handler_func)) {
$this
->trigger_error("default template handler function \"{$this->default_template_handler_func}\" doesn't exist.");
}
else {
$_return = call_user_func_array($this->default_template_handler_func, array(
$_params['resource_type'],
$_params['resource_name'],
&$params['source_content'],
&$params['resource_timestamp'],
&$this,
));
}
}
}
if (!$_return) {
if (!$params['quiet']) {
$this
->trigger_error('unable to read resource: "' . $params['resource_name'] . '"');
}
}
else {
if ($_return && $this->security) {
require_once SMARTY_CORE_DIR . 'core.is_secure.php';
if (!smarty_core_is_secure($_params, $this)) {
if (!$params['quiet']) {
$this
->trigger_error('(secure mode) accessing "' . $params['resource_name'] . '" is not allowed');
}
$params['source_content'] = null;
$params['resource_timestamp'] = null;
return false;
}
}
}
return $_return;
}