add default_resource_type, ignore 1 char resource names

This commit is contained in:
mohrt
2003-06-06 15:49:29 +00:00
parent e51af36e66
commit a569bd39dc
3 changed files with 25 additions and 3 deletions

2
NEWS
View File

@@ -1,3 +1,5 @@
- ignore one char resource names like c:foo.tpl (Monte)
- added default_resource_type feature (Monte)
- fix bug where config file starts with hidden section (boots, Monte)
- add discrete error checking pertaining to $cache_dir
and $compile_dir, their existance and writability (Monte)

View File

@@ -300,6 +300,20 @@ class Smarty
*/
var $default_modifiers = array();
/**
* This is the resource type to be used when not specified
* at the beginning of the resource path. examples:
* $smarty->display('file:index.tpl');
* $smarty->display('db:index.tpl');
* $smarty->display('index.tpl'); // will use default resource type
* {include file="file:index.tpl"}
* {include file="db:index.tpl"}
* {include file="index.tpl"} {* will use default resource type *}
*
* @var array
*/
var $default_resource_type = 'file';
/**
* The function used for cache file handling. If not set, built-in caching is used.
*

View File

@@ -25,11 +25,17 @@ function smarty_core_parse_file_path(&$params, &$this)
if (count($_file_path_parts) == 1) {
// no resource type, treat as type "file"
$params['resource_type'] = 'file';
$params['resource_type'] = $this->default_resource_type;
$params['resource_name'] = $_file_path_parts[0];
} else {
if(strlen($_file_path_parts[0]) == 1) {
// 1 char is not resource type, but part of filepath
$params['resource_type'] = $this->default_resource_type;
$params['resource_name'] = $params['file_path'];
} else {
$params['resource_type'] = $_file_path_parts[0];
$params['resource_name'] = $_file_path_parts[1];
}
if ($params['resource_type'] != 'file') {
$_params = array('type' => $params['resource_type']);
$this->_execute_core_function('load_resource_plugin', $_params);