- bugfix dynamic configuration of $debugging_crtl did not work

- bugfix default value of $config_read_hidden changed to false
- bugfix format of attribute array on compiler plugins
- bugfix getTemplateVars() could return value from wrong scope
This commit is contained in:
uwe.tews@googlemail.com
2010-12-31 13:47:12 +00:00
parent 015f817259
commit 9630a99a82
4 changed files with 45 additions and 29 deletions

View File

@@ -1,4 +1,10 @@
===== SVN trunk =====
31/12/2010
- bugfix dynamic configuration of $debugging_crtl did not work
- bugfix default value of $config_read_hidden changed to false
- bugfix format of attribute array on compiler plugins
- bugfix getTemplateVars() could return value from wrong scope
28/12/2010
- bugfix multiple {append} tags failed to compile.

View File

@@ -181,7 +181,7 @@ class Smarty extends Smarty_Internal_Data {
// config var settings
public $config_overwrite = true; //Controls whether variables with the same name overwrite each other.
public $config_booleanize = true; //Controls whether config values of on/true/yes and off/false/no get converted to boolean
public $config_read_hidden = true; //Controls whether hidden config sections/vars are read from the file.
public $config_read_hidden = false; //Controls whether hidden config sections/vars are read from the file.
// config vars
public $config_vars = array();
// assigned tpl vars
@@ -259,31 +259,6 @@ class Smarty extends Smarty_Internal_Data {
$this->cache_dir = '.' . DS . 'cache' . DS;
$this->config_dir = '.' . DS . 'configs' . DS;
$this->debug_tpl = SMARTY_DIR . 'debug.tpl';
if (!$this->debugging && $this->debugging_ctrl == 'URL') {
if (isset($_SERVER['QUERY_STRING'])) {
$_query_string = $_SERVER['QUERY_STRING'];
} else {
$_query_string = '';
}
if (false !== strpos($_query_string, $this->smarty_debug_id)) {
if (false !== strpos($_query_string, $this->smarty_debug_id . '=on')) {
// enable debugging for this browser session
setcookie('SMARTY_DEBUG', true);
$this->debugging = true;
} elseif (false !== strpos($_query_string, $this->smarty_debug_id . '=off')) {
// disable debugging for this browser session
setcookie('SMARTY_DEBUG', false);
$this->debugging = false;
} else {
// enable debugging for this page
$this->debugging = true;
}
} else {
if (isset($_COOKIE['SMARTY_DEBUG'])) {
$this->debugging = true;
}
}
}
if (isset($_SERVER['SCRIPT_NAME'])) {
$this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
}
@@ -321,6 +296,32 @@ class Smarty extends Smarty_Internal_Data {
if (isset($this->error_reporting)) {
$_smarty_old_error_level = error_reporting($this->error_reporting);
}
// check URL debugging control
if (!$this->debugging && $this->debugging_ctrl == 'URL') {
if (isset($_SERVER['QUERY_STRING'])) {
$_query_string = $_SERVER['QUERY_STRING'];
} else {
$_query_string = '';
}
if (false !== strpos($_query_string, $this->smarty_debug_id)) {
if (false !== strpos($_query_string, $this->smarty_debug_id . '=on')) {
// enable debugging for this browser session
setcookie('SMARTY_DEBUG', true);
$this->debugging = true;
} elseif (false !== strpos($_query_string, $this->smarty_debug_id . '=off')) {
// disable debugging for this browser session
setcookie('SMARTY_DEBUG', false);
$this->debugging = false;
} else {
// enable debugging for this page
$this->debugging = true;
}
} else {
if (isset($_COOKIE['SMARTY_DEBUG'])) {
$this->debugging = true;
}
}
}
// obtain data for cache modified check
if ($this->cache_modified_check && $this->caching && $display) {
$_isCached = $_template->isCached() && !$_template->has_nocache_code;

View File

@@ -196,8 +196,10 @@ class Smarty_Internal_Data {
$_ptr = $this;
} while ($_ptr !== null) {
foreach ($_ptr->tpl_vars AS $key => $var) {
if (!array_key_exists($key, $_result)) {
$_result[$key] = $var->value;
}
}
// not found, try at parent
if ($search_parents) {
$_ptr = $_ptr->parent;
@@ -207,9 +209,11 @@ class Smarty_Internal_Data {
}
if ($search_parents && isset(Smarty::$global_tpl_vars)) {
foreach (Smarty::$global_tpl_vars AS $key => $var) {
if (!array_key_exists($key, $_result)) {
$_result[$key] = $var->value;
}
}
}
return $_result;
}
}

View File

@@ -196,7 +196,12 @@ class Smarty_Internal_TemplateCompilerBase {
if ($plugin_type == Smarty::PLUGIN_BLOCK && $this->smarty->loadPlugin('smarty_compiler_' . $tag)) {
$plugin = 'smarty_compiler_' . $tag;
if (is_callable($plugin)) {
return $plugin($args, $this->smarty);
// convert arguments format for old compiler plugins
$new_args = array();
foreach ($args as $mixed) {
$new_args = array_merge($new_args, $mixed);
}
return $plugin($new_args, $this->smarty);
}
if (class_exists($plugin, false)) {
$plugin_object = new $plugin;