diff --git a/NEWS b/NEWS index 4edf4f38..646732cc 100644 --- a/NEWS +++ b/NEWS @@ -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) diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 11df9a52..5185981e 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -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. * diff --git a/libs/plugins/core.parse_file_path.php b/libs/plugins/core.parse_file_path.php index 4108fdad..6fdbcb69 100644 --- a/libs/plugins/core.parse_file_path.php +++ b/libs/plugins/core.parse_file_path.php @@ -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 { - $params['resource_type'] = $_file_path_parts[0]; - $params['resource_name'] = $_file_path_parts[1]; + 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);