mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
add default_resource_type, ignore 1 char resource names
This commit is contained in:
2
NEWS
2
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)
|
- fix bug where config file starts with hidden section (boots, Monte)
|
||||||
- add discrete error checking pertaining to $cache_dir
|
- add discrete error checking pertaining to $cache_dir
|
||||||
and $compile_dir, their existance and writability (Monte)
|
and $compile_dir, their existance and writability (Monte)
|
||||||
|
@@ -300,6 +300,20 @@ class Smarty
|
|||||||
*/
|
*/
|
||||||
var $default_modifiers = array();
|
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.
|
* The function used for cache file handling. If not set, built-in caching is used.
|
||||||
*
|
*
|
||||||
|
@@ -25,11 +25,17 @@ function smarty_core_parse_file_path(&$params, &$this)
|
|||||||
|
|
||||||
if (count($_file_path_parts) == 1) {
|
if (count($_file_path_parts) == 1) {
|
||||||
// no resource type, treat as type "file"
|
// 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];
|
$params['resource_name'] = $_file_path_parts[0];
|
||||||
} else {
|
} else {
|
||||||
$params['resource_type'] = $_file_path_parts[0];
|
if(strlen($_file_path_parts[0]) == 1) {
|
||||||
$params['resource_name'] = $_file_path_parts[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') {
|
if ($params['resource_type'] != 'file') {
|
||||||
$_params = array('type' => $params['resource_type']);
|
$_params = array('type' => $params['resource_type']);
|
||||||
$this->_execute_core_function('load_resource_plugin', $_params);
|
$this->_execute_core_function('load_resource_plugin', $_params);
|
||||||
|
Reference in New Issue
Block a user