Made {config_load ..} merge globals from each config file only once per scope.

This commit is contained in:
andrey
2001-11-27 17:17:53 +00:00
parent 56dac2fa05
commit 142072888e
5 changed files with 276 additions and 251 deletions

15
NEWS
View File

@@ -1,18 +1,21 @@
- made {config_load ...} merge globals from each config file only once per
scope, thus avoiding several problems. (Andrei)
- added {foreach ...} tag that can be used to iterate through
non-sequential and associative arrays. (Andrei)
- speeded up section property access a bit. (Andrei)
- protected $smarty variable from being assigned by user. (Andrei)
- removed $smarty variable from storage used by normal template variables,
to prevent any problems. (Andrei)
- fixed a bug that could cause parse error with quotes inside literal
blocks. (Andrei, Alexander Belonosov)
- added 'field_array' attribute to html_select_time function. (Andrei,
Michael Caplan)
- added {section} "max" attribute to docs (Monte)
- fixed notice message in Smarty_Compiler.class.php (Monte)
- added {section} "max" attribute to docs. (Monte)
- fixed notice message in Smarty_Compiler.class.php. (Monte)
- fixed bug with clear_cache introduced in 1.4.6, third parameter should be
null (Monte)
- updated Config_File.class.php for "\" support in OS/2 (Monte, Francesco
null. (Monte)
- updated Config_File.class.php for "\" support in OS/2. (Monte, Francesco
Ciprianii)
- removed secure_ext setting (not used) (Monte)
- removed secure_ext setting (not used). (Monte)
- made cache reading process more efficient. (Monte)
- fixed bug, is_cached() now supports new 1.4.6 caching behavior. (Monte)
- update FAQ with mailing list Reply-To header FAQ. (Monte)

View File

@@ -418,7 +418,7 @@ class Smarty
\*======================================================================*/
function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null)
{
if(!empty($this->cache_handler_func) {
if (!empty($this->cache_handler_func)) {
return $$this->cache_handler_func('clear', $tpl_file, $cache_id, $compile_id);
} else {
return $this->_rm_auto($this->cache_dir, $tpl_file, $compile_id . $cache_id);
@@ -432,7 +432,7 @@ class Smarty
\*======================================================================*/
function clear_all_cache()
{
if(!empty($this->cache_handler_func) {
if (!empty($this->cache_handler_func)) {
return $$this->cache_handler_func('clear');
} else {
return $this->_rm_auto($this->cache_dir);
@@ -556,7 +556,8 @@ class Smarty
extract($this->_tpl_vars);
/* Initialize config array. */
$this->_config = array(array());
$this->_config = array(array('vars' => array(),
'files' => array()));
if ($this->show_info_header) {
$info_header = '<!-- Smarty '.$this->_version.' '.strftime("%Y-%m-%d %H:%M:%S %Z").' -->'."\n\n";
@@ -927,23 +928,33 @@ function _generate_debug_output() {
$this->_cache_info[] = array('config', $file);
}
$this->_config[0] = array_merge($this->_config[0], $this->_conf_obj->get($file));
if (!isset($this->_config[0]['files'][$file])) {
$this->_config[0]['vars'] = array_merge($this->_config[0]['vars'], $this->_conf_obj->get($file));
$this->_config[0]['files'][$file] = true;
}
if ($scope == 'parent') {
if (count($this->_config) > 0)
$this->_config[1] = array_merge($this->_config[1], $this->_conf_obj->get($file));
if (count($this->_config) > 0 && !isset($this->_config[1]['files'][$file])) {
$this->_config[1]['vars'] = array_merge($this->_config[1]['vars'], $this->_conf_obj->get($file));
$this->_config[1]['files'][$file] = true;
}
} else if ($scope == 'global')
for ($i = 1; $i < count($this->_config); $i++)
$this->_config[$i] = array_merge($this->_config[$i], $this->_conf_obj->get($file));
for ($i = 1; $i < count($this->_config); $i++) {
if (!isset($this->_config[$i]['files'][$file])) {
$this->_config[$i]['vars'] = array_merge($this->_config[$i]['vars'], $this->_conf_obj->get($file));
$this->_config[$i]['files'][$file] = true;
}
}
if (!empty($section)) {
$this->_config[0] = array_merge($this->_config[0], $this->_conf_obj->get($file, $section));
$this->_config[0]['vars'] = array_merge($this->_config[0]['vars'], $this->_conf_obj->get($file, $section));
if ($scope == 'parent') {
if (count($this->_config) > 0)
$this->_config[1] = array_merge($this->_config[1], $this->_conf_obj->get($file, $section));
$this->_config[1]['vars'] = array_merge($this->_config[1]['vars'], $this->_conf_obj->get($file, $section));
} else if ($scope == 'global')
for ($i = 1; $i < count($this->_config); $i++)
$this->_config[$i] = array_merge($this->_config[$i], $this->_conf_obj->get($file, $section));
$this->_config[$i]['vars'] = array_merge($this->_config[$i]['vars'], $this->_conf_obj->get($file, $section));
}
if ($this->debugging) {
$debug_start_time = $this->_get_microtime();
$this->_smarty_debug_info[] = array('type' => 'config',

View File

@@ -973,7 +973,7 @@ class Smarty_Compiler extends Smarty {
$var_name = substr($var_ref, 1, -1);
$output = "\$this->_config[0]['$var_name']";
$output = "\$this->_config[0]['vars']['$var_name']";
$this->_parse_modifiers($output, $modifiers);

View File

@@ -418,7 +418,7 @@ class Smarty
\*======================================================================*/
function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null)
{
if(!empty($this->cache_handler_func) {
if (!empty($this->cache_handler_func)) {
return $$this->cache_handler_func('clear', $tpl_file, $cache_id, $compile_id);
} else {
return $this->_rm_auto($this->cache_dir, $tpl_file, $compile_id . $cache_id);
@@ -432,7 +432,7 @@ class Smarty
\*======================================================================*/
function clear_all_cache()
{
if(!empty($this->cache_handler_func) {
if (!empty($this->cache_handler_func)) {
return $$this->cache_handler_func('clear');
} else {
return $this->_rm_auto($this->cache_dir);
@@ -556,7 +556,8 @@ class Smarty
extract($this->_tpl_vars);
/* Initialize config array. */
$this->_config = array(array());
$this->_config = array(array('vars' => array(),
'files' => array()));
if ($this->show_info_header) {
$info_header = '<!-- Smarty '.$this->_version.' '.strftime("%Y-%m-%d %H:%M:%S %Z").' -->'."\n\n";
@@ -927,23 +928,33 @@ function _generate_debug_output() {
$this->_cache_info[] = array('config', $file);
}
$this->_config[0] = array_merge($this->_config[0], $this->_conf_obj->get($file));
if (!isset($this->_config[0]['files'][$file])) {
$this->_config[0]['vars'] = array_merge($this->_config[0]['vars'], $this->_conf_obj->get($file));
$this->_config[0]['files'][$file] = true;
}
if ($scope == 'parent') {
if (count($this->_config) > 0)
$this->_config[1] = array_merge($this->_config[1], $this->_conf_obj->get($file));
if (count($this->_config) > 0 && !isset($this->_config[1]['files'][$file])) {
$this->_config[1]['vars'] = array_merge($this->_config[1]['vars'], $this->_conf_obj->get($file));
$this->_config[1]['files'][$file] = true;
}
} else if ($scope == 'global')
for ($i = 1; $i < count($this->_config); $i++)
$this->_config[$i] = array_merge($this->_config[$i], $this->_conf_obj->get($file));
for ($i = 1; $i < count($this->_config); $i++) {
if (!isset($this->_config[$i]['files'][$file])) {
$this->_config[$i]['vars'] = array_merge($this->_config[$i]['vars'], $this->_conf_obj->get($file));
$this->_config[$i]['files'][$file] = true;
}
}
if (!empty($section)) {
$this->_config[0] = array_merge($this->_config[0], $this->_conf_obj->get($file, $section));
$this->_config[0]['vars'] = array_merge($this->_config[0]['vars'], $this->_conf_obj->get($file, $section));
if ($scope == 'parent') {
if (count($this->_config) > 0)
$this->_config[1] = array_merge($this->_config[1], $this->_conf_obj->get($file, $section));
$this->_config[1]['vars'] = array_merge($this->_config[1]['vars'], $this->_conf_obj->get($file, $section));
} else if ($scope == 'global')
for ($i = 1; $i < count($this->_config); $i++)
$this->_config[$i] = array_merge($this->_config[$i], $this->_conf_obj->get($file, $section));
$this->_config[$i]['vars'] = array_merge($this->_config[$i]['vars'], $this->_conf_obj->get($file, $section));
}
if ($this->debugging) {
$debug_start_time = $this->_get_microtime();
$this->_smarty_debug_info[] = array('type' => 'config',

View File

@@ -973,7 +973,7 @@ class Smarty_Compiler extends Smarty {
$var_name = substr($var_ref, 1, -1);
$output = "\$this->_config[0]['$var_name']";
$output = "\$this->_config[0]['vars']['$var_name']";
$this->_parse_modifiers($output, $modifiers);