5 * @subpackage plugins
\r
9 * Retrieves PHP script resource
\r
11 * sets $php_resource to the returned resource
\r
12 * @param string $resource
\r
13 * @param string $resource_type
\r
14 * @param $php_resource
\r
18 function smarty_core_get_php_resource(&$params, &$smarty)
\r
21 $params['resource_base_path'] = $smarty->trusted_dir;
\r
22 $smarty->_parse_resource_name($params, $smarty);
\r
25 * Find out if the resource exists.
\r
28 if ($params['resource_type'] == 'file') {
\r
30 if(file_exists($params['resource_name']) && is_readable($params['resource_name'])) {
\r
33 // test for file in include_path
\r
34 $_params = array('file_path' => $params['resource_name']);
\r
35 require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php');
\r
36 if(smarty_core_get_include_path($_params, $smarty)) {
\r
37 $_include_path = $_params['new_file_path'];
\r
41 } else if ($params['resource_type'] != 'file') {
\r
42 $_template_source = null;
\r
43 $_readable = is_callable($smarty->_plugins['resource'][$params['resource_type']][0][0])
\r
44 && call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0],
\r
45 array($params['resource_name'], &$_template_source, &$smarty));
\r
49 * Set the error function, depending on which class calls us.
\r
51 if (method_exists($smarty, '_syntax_error')) {
\r
52 $_error_funcc = '_syntax_error';
\r
54 $_error_funcc = 'trigger_error';
\r
58 if ($smarty->security) {
\r
59 require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_trusted.php');
\r
60 if (!smarty_core_is_trusted($params, $smarty)) {
\r
61 $smarty->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted');
\r
66 $smarty->$_error_funcc($params['resource_type'] . ':' . $params['resource_name'] . ' is not readable');
\r
70 if ($params['resource_type'] == 'file') {
\r
71 $params['php_resource'] = $params['resource_name'];
\r
73 $params['php_resource'] = $_template_source;
\r
78 /* vim: set expandtab: */
\r