mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
move some code into Smarty_Internal_Debug class
where it better belongs to
This commit is contained in:
@@ -344,4 +344,35 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* handle 'URL' debugging mode
|
||||
*
|
||||
* @param Smarty_Internal_Template $_template
|
||||
*/
|
||||
public static function debugUrl(Smarty_Internal_Template $_template) {
|
||||
if (isset($_SERVER['QUERY_STRING'])) {
|
||||
$_query_string = $_SERVER['QUERY_STRING'];
|
||||
} else {
|
||||
$_query_string = '';
|
||||
}
|
||||
if (false !== strpos($_query_string, $_template->smarty->smarty_debug_id)) {
|
||||
if (false !== strpos($_query_string, $_template->smarty->smarty_debug_id . '=on')) {
|
||||
// enable debugging for this browser session
|
||||
setcookie('SMARTY_DEBUG', true);
|
||||
$_template->smarty->debugging = true;
|
||||
} elseif (false !== strpos($_query_string, $_template->smarty->smarty_debug_id . '=off')) {
|
||||
// disable debugging for this browser session
|
||||
setcookie('SMARTY_DEBUG', false);
|
||||
$_template->smarty->debugging = false;
|
||||
} else {
|
||||
// enable debugging for this page
|
||||
$_template->smarty->debugging = true;
|
||||
}
|
||||
} else {
|
||||
if (isset($_COOKIE['SMARTY_DEBUG'])) {
|
||||
$_template->smarty->debugging = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -89,39 +89,12 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
if (!isset($_template->tpl_vars['smarty'])) {
|
||||
$_template->tpl_vars['smarty'] = new Smarty_Variable;
|
||||
}
|
||||
if (isset($this->smarty->error_reporting)) {
|
||||
$_smarty_old_error_level = error_reporting($this->smarty->error_reporting);
|
||||
if (isset($_template->smarty->error_reporting)) {
|
||||
$_smarty_old_error_level = error_reporting($_template->smarty->error_reporting);
|
||||
}
|
||||
// check URL debugging control
|
||||
if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') {
|
||||
if (isset($_SERVER['QUERY_STRING'])) {
|
||||
$_query_string = $_SERVER['QUERY_STRING'];
|
||||
} else {
|
||||
$_query_string = '';
|
||||
}
|
||||
if (false !== strpos($_query_string, $this->smarty->smarty_debug_id)) {
|
||||
if (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=on')) {
|
||||
// enable debugging for this browser session
|
||||
setcookie('SMARTY_DEBUG', true);
|
||||
$this->smarty->debugging = true;
|
||||
} elseif (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=off')) {
|
||||
// disable debugging for this browser session
|
||||
setcookie('SMARTY_DEBUG', false);
|
||||
$this->smarty->debugging = false;
|
||||
} else {
|
||||
// enable debugging for this page
|
||||
$this->smarty->debugging = true;
|
||||
}
|
||||
} else {
|
||||
if (isset($_COOKIE['SMARTY_DEBUG'])) {
|
||||
$this->smarty->debugging = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// get rendered template
|
||||
// disable caching for evaluated code
|
||||
if ($_template->source->recompiled) {
|
||||
$_template->caching = false;
|
||||
if (!$_template->smarty->debugging && $_template->smarty->debugging_ctrl == 'URL') {
|
||||
Smarty_Internal_Debug::debugUrl($_template);
|
||||
}
|
||||
// checks if template exists
|
||||
if (!$_template->source->exists) {
|
||||
@@ -132,6 +105,11 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
}
|
||||
throw new SmartyException("Unable to load template {$_template->source->type} '{$_template->source->name}'{$parent_resource}");
|
||||
}
|
||||
// get rendered template
|
||||
// disable caching for evaluated code
|
||||
if ($_template->source->recompiled) {
|
||||
$_template->caching = false;
|
||||
}
|
||||
// read from cache or render
|
||||
if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || !$_template->cached->valid) {
|
||||
// render template (not loaded and not in cache)
|
||||
|
Reference in New Issue
Block a user