added handling of resources for {config_load}

This commit is contained in:
messju
2004-01-21 17:21:26 +00:00
parent 64a67e5d58
commit cf0ee7bdd8
2 changed files with 9 additions and 14 deletions

1
NEWS
View File

@@ -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)

View File

@@ -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 = '<?php $_config_vars = unserialize(\'' . strtr(serialize($_config_vars),array('\''=>'\\\'', '\\'=>'\\\\')) . '\'); ?>';
}
$_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 {