mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
Made {config_load ..} merge globals from each config file only once per scope.
This commit is contained in:
15
NEWS
15
NEWS
@@ -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
|
- added {foreach ...} tag that can be used to iterate through
|
||||||
non-sequential and associative arrays. (Andrei)
|
non-sequential and associative arrays. (Andrei)
|
||||||
- speeded up section property access a bit. (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
|
- fixed a bug that could cause parse error with quotes inside literal
|
||||||
blocks. (Andrei, Alexander Belonosov)
|
blocks. (Andrei, Alexander Belonosov)
|
||||||
- added 'field_array' attribute to html_select_time function. (Andrei,
|
- added 'field_array' attribute to html_select_time function. (Andrei,
|
||||||
Michael Caplan)
|
Michael Caplan)
|
||||||
- added {section} "max" attribute to docs (Monte)
|
- added {section} "max" attribute to docs. (Monte)
|
||||||
- fixed notice message in Smarty_Compiler.class.php (Monte)
|
- fixed notice message in Smarty_Compiler.class.php. (Monte)
|
||||||
- fixed bug with clear_cache introduced in 1.4.6, third parameter should be
|
- fixed bug with clear_cache introduced in 1.4.6, third parameter should be
|
||||||
null (Monte)
|
null. (Monte)
|
||||||
- updated Config_File.class.php for "\" support in OS/2 (Monte, Francesco
|
- updated Config_File.class.php for "\" support in OS/2. (Monte, Francesco
|
||||||
Ciprianii)
|
Ciprianii)
|
||||||
- removed secure_ext setting (not used) (Monte)
|
- removed secure_ext setting (not used). (Monte)
|
||||||
- made cache reading process more efficient. (Monte)
|
- made cache reading process more efficient. (Monte)
|
||||||
- fixed bug, is_cached() now supports new 1.4.6 caching behavior. (Monte)
|
- fixed bug, is_cached() now supports new 1.4.6 caching behavior. (Monte)
|
||||||
- update FAQ with mailing list Reply-To header FAQ. (Monte)
|
- update FAQ with mailing list Reply-To header FAQ. (Monte)
|
||||||
|
@@ -418,7 +418,7 @@ class Smarty
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null)
|
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);
|
return $$this->cache_handler_func('clear', $tpl_file, $cache_id, $compile_id);
|
||||||
} else {
|
} else {
|
||||||
return $this->_rm_auto($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
return $this->_rm_auto($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
||||||
@@ -432,7 +432,7 @@ class Smarty
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function clear_all_cache()
|
function clear_all_cache()
|
||||||
{
|
{
|
||||||
if(!empty($this->cache_handler_func) {
|
if (!empty($this->cache_handler_func)) {
|
||||||
return $$this->cache_handler_func('clear');
|
return $$this->cache_handler_func('clear');
|
||||||
} else {
|
} else {
|
||||||
return $this->_rm_auto($this->cache_dir);
|
return $this->_rm_auto($this->cache_dir);
|
||||||
@@ -556,7 +556,8 @@ class Smarty
|
|||||||
extract($this->_tpl_vars);
|
extract($this->_tpl_vars);
|
||||||
|
|
||||||
/* Initialize config array. */
|
/* Initialize config array. */
|
||||||
$this->_config = array(array());
|
$this->_config = array(array('vars' => array(),
|
||||||
|
'files' => array()));
|
||||||
|
|
||||||
if ($this->show_info_header) {
|
if ($this->show_info_header) {
|
||||||
$info_header = '<!-- Smarty '.$this->_version.' '.strftime("%Y-%m-%d %H:%M:%S %Z").' -->'."\n\n";
|
$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->_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 ($scope == 'parent') {
|
||||||
if (count($this->_config) > 0)
|
if (count($this->_config) > 0 && !isset($this->_config[1]['files'][$file])) {
|
||||||
$this->_config[1] = array_merge($this->_config[1], $this->_conf_obj->get($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')
|
} else if ($scope == 'global')
|
||||||
for ($i = 1; $i < count($this->_config); $i++)
|
for ($i = 1; $i < count($this->_config); $i++) {
|
||||||
$this->_config[$i] = array_merge($this->_config[$i], $this->_conf_obj->get($file));
|
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)) {
|
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 ($scope == 'parent') {
|
||||||
if (count($this->_config) > 0)
|
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')
|
} else if ($scope == 'global')
|
||||||
for ($i = 1; $i < count($this->_config); $i++)
|
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) {
|
if ($this->debugging) {
|
||||||
$debug_start_time = $this->_get_microtime();
|
$debug_start_time = $this->_get_microtime();
|
||||||
$this->_smarty_debug_info[] = array('type' => 'config',
|
$this->_smarty_debug_info[] = array('type' => 'config',
|
||||||
|
@@ -973,7 +973,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
|
|
||||||
$var_name = substr($var_ref, 1, -1);
|
$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);
|
$this->_parse_modifiers($output, $modifiers);
|
||||||
|
|
||||||
|
@@ -418,7 +418,7 @@ class Smarty
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null)
|
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);
|
return $$this->cache_handler_func('clear', $tpl_file, $cache_id, $compile_id);
|
||||||
} else {
|
} else {
|
||||||
return $this->_rm_auto($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
return $this->_rm_auto($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
||||||
@@ -432,7 +432,7 @@ class Smarty
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function clear_all_cache()
|
function clear_all_cache()
|
||||||
{
|
{
|
||||||
if(!empty($this->cache_handler_func) {
|
if (!empty($this->cache_handler_func)) {
|
||||||
return $$this->cache_handler_func('clear');
|
return $$this->cache_handler_func('clear');
|
||||||
} else {
|
} else {
|
||||||
return $this->_rm_auto($this->cache_dir);
|
return $this->_rm_auto($this->cache_dir);
|
||||||
@@ -556,7 +556,8 @@ class Smarty
|
|||||||
extract($this->_tpl_vars);
|
extract($this->_tpl_vars);
|
||||||
|
|
||||||
/* Initialize config array. */
|
/* Initialize config array. */
|
||||||
$this->_config = array(array());
|
$this->_config = array(array('vars' => array(),
|
||||||
|
'files' => array()));
|
||||||
|
|
||||||
if ($this->show_info_header) {
|
if ($this->show_info_header) {
|
||||||
$info_header = '<!-- Smarty '.$this->_version.' '.strftime("%Y-%m-%d %H:%M:%S %Z").' -->'."\n\n";
|
$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->_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 ($scope == 'parent') {
|
||||||
if (count($this->_config) > 0)
|
if (count($this->_config) > 0 && !isset($this->_config[1]['files'][$file])) {
|
||||||
$this->_config[1] = array_merge($this->_config[1], $this->_conf_obj->get($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')
|
} else if ($scope == 'global')
|
||||||
for ($i = 1; $i < count($this->_config); $i++)
|
for ($i = 1; $i < count($this->_config); $i++) {
|
||||||
$this->_config[$i] = array_merge($this->_config[$i], $this->_conf_obj->get($file));
|
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)) {
|
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 ($scope == 'parent') {
|
||||||
if (count($this->_config) > 0)
|
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')
|
} else if ($scope == 'global')
|
||||||
for ($i = 1; $i < count($this->_config); $i++)
|
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) {
|
if ($this->debugging) {
|
||||||
$debug_start_time = $this->_get_microtime();
|
$debug_start_time = $this->_get_microtime();
|
||||||
$this->_smarty_debug_info[] = array('type' => 'config',
|
$this->_smarty_debug_info[] = array('type' => 'config',
|
||||||
|
@@ -973,7 +973,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
|
|
||||||
$var_name = substr($var_ref, 1, -1);
|
$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);
|
$this->_parse_modifiers($output, $modifiers);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user