From cf0ee7bdd88e2a821bdea94614f8d75da79bc755 Mon Sep 17 00:00:00 2001 From: messju Date: Wed, 21 Jan 2004 17:21:26 +0000 Subject: [PATCH] added handling of resources for {config_load} --- NEWS | 1 + libs/plugins/function.config_load.php | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/NEWS b/NEWS index f32841f6..e0a255ff 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ + - add handling of resources for {config_load} (messju) - fix bug when using arrays with tr_attr and td_attr in {html_table} (messju) - add unit testing to cvs core (Monte) diff --git a/libs/plugins/function.config_load.php b/libs/plugins/function.config_load.php index 1f57b0e2..36b37c30 100644 --- a/libs/plugins/function.config_load.php +++ b/libs/plugins/function.config_load.php @@ -53,17 +53,9 @@ function smarty_function_config_load($params, &$smarty) } } - if(@is_dir($smarty->config_dir)) { - $_config_dir = $smarty->config_dir; - } else { - // config_dir not found, try include_path - $_params = array('file_path' => $smarty->config_dir); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php'); - smarty_core_get_include_path($_params, $smarty); - $_config_dir = $_params['new_file_path']; - } - - $_file_path = $_config_dir . DIRECTORY_SEPARATOR . $_file; + $_params = array('resource_name' => $_file, 'resource_base_path' => $smarty->config_dir); + $smarty->_parse_resource_name($_params); + $_file_path = $_params['resource_type'] . ':' . $_params['resource_name']; if (isset($_section)) $_compile_file = $smarty->_get_compile_path($_file_path.'|'.$_section); else @@ -76,13 +68,15 @@ function smarty_function_config_load($params, &$smarty) // compile config file if(!is_object($smarty->_conf_obj)) { require_once SMARTY_DIR . $smarty->config_class . '.class.php'; - $smarty->_conf_obj = new $smarty->config_class($_config_dir); + $smarty->_conf_obj = new $smarty->config_class(); $smarty->_conf_obj->overwrite = $smarty->config_overwrite; $smarty->_conf_obj->booleanize = $smarty->config_booleanize; $smarty->_conf_obj->read_hidden = $smarty->config_read_hidden; $smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines; } - $smarty->_conf_obj->set_path($_config_dir); + $_params = array('resource_name' => $_file, 'resource_base_path' => $smarty->config_dir); + $smarty->_fetch_resource_info($_params); + $smarty->_conf_obj->set_file_contents($_file, $_params['source_content']); $_config_vars = array_merge($smarty->_conf_obj->get($_file), $smarty->_conf_obj->get($_file, $_section)); if(function_exists('var_export')) { @@ -90,7 +84,7 @@ function smarty_function_config_load($params, &$smarty) } else { $_output = ''\\\'', '\\'=>'\\\\')) . '\'); ?>'; } - $_params = (array('compile_path' => $_compile_file, 'compiled_content' => $_output, 'resource_timestamp' => filemtime($_file_path))); + $_params = (array('compile_path' => $_compile_file, 'compiled_content' => $_output, 'resource_timestamp' => $_params['resource_timestamp'])); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_resource.php'); smarty_core_write_compiled_resource($_params, $smarty); } else {