From 69e3ee81bf34ed2ca85fbd973edb89b3b85b16d0 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 20 Dec 2006 03:51:19 +0000 Subject: [PATCH] - Fixed some access modifiers so that the template system works - We now have a working debug block for the template module --- Template.php | 79 ++++++++++++++++++++++++++++++++++++++------------ TemplateFs.php | 2 +- 2 files changed, 62 insertions(+), 19 deletions(-) diff --git a/Template.php b/Template.php index 21b7e43..dfa87be 100644 --- a/Template.php +++ b/Template.php @@ -85,19 +85,19 @@ class BSTemplate * Array of pre-compiled templates that are stored to decrease server load * @var array */ - private $cache = array(); + protected $cache = array(); /** * A list of the number of times each template has been used * @var array */ - private $usage = array(); + protected $usage = array(); /** * A list of templates that weren't cached, but are still used * @var array */ - private $uncached = array(); + protected $uncached = array(); /** * Whether or not the page has been flush()'d already @@ -200,7 +200,7 @@ class BSTemplate else { $this->uncached[] = $name; - BSRegister::Debug("Manually loading template `$name`"); + BSRegister::Debug("Manually loading template '$name'"); $template = $this->_loadTemplate($name); $template = $this->_parseTemplate($template); } @@ -231,25 +231,68 @@ class BSTemplate exit; } - if (BSRegister::GetDebug() AND isset($_GET['query'])) + if ($this->doneflush) { - if (is_array($this->registry->modules[ISSO_DB_LAYER]->history)) - { - foreach ($this->registry->modules[ISSO_DB_LAYER]->history AS $query) - { - echo $this->registry->modules[ISSO_DB_LAYER]->construct_query_debug($query); - } - } + trigger_error('A template has already been sent to the output buffer'); exit; } - if ($this->doneflush) + $debugBlock = ''; + if (BSRegister::GetDebug()) { - trigger_error('A template has already been sent to the output buffer'); - exit; + if (defined('SVN') AND preg_match('#^\$Id:?#', constant('SVN'))) + { + $debugBlock .= preg_replace('#\$' . 'Id: (.+?) ([0-9].+?) [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(.+?) (.+?) \$#', "\n
\n" . '
\1 — r\2
', constant('SVN')); + } + + if (defined('ISSO_MT_START')) + { + $debugBlock .= "\n
Executed in " . round(BSFunctions::FetchMicrotimeDiff(ISSO_MT_START), 10) . ' seconds
'; + } + + $debugBlock .= "\n
" . BSRegister::GetDebugList() . "
"; + + $optlist = array(); + $usage = array(); + foreach ($this->usage AS $name => $count) + { + if (in_array($name, $this->uncached)) + { + $optlist[] = $name . '[' . $count . ']'; + } + $usage[] = $name . " ($count)"; + } + $sizeof = sizeof($this->uncached); + if ($sizeof > 0) + { + $debugBlock .= "
Uncached Template(s): $sizeof ( " . implode('   ', $optlist) . " )
\n"; + } + + $debugBlock .= (sizeof($this->uncached) < 1 ? "
\n" : '') . "
\n"; + + if (BSRegister::GetType('Db')) + { + $queries = BSRegister::GetType('Db')->getHistory(); + + $debugBlock .= "
\n" . '' . "\n\t" . ''; + + foreach ($queries AS $query) + { + $debugBlock .= "\n\t"; + $debugBlock .= "\n\t\t\n\t"; + } + + $debugBlock .= "\n
Query Debug
"; + $debugBlock .= "\n\t\t\t$query[query]\n\n\t\t\t
($query[time])
\n\n\t\t
\n\n\n"; + } } - $template = str_replace('', $this->registry->construct_debug_block(true) . '', $template); + $template = str_replace('', $debugBlock . '', $template); print($template); } @@ -262,9 +305,9 @@ class BSTemplate * * @return string Template data from the database */ - private function _loadTemplate($name) + protected function _loadTemplate($name) { - if ($template = $this->db->query_first("SELECT * FROM " . $this->tableName . " WHERE " . $this->nameColumn . " = '$name'" . ($this->extrawhere ? ' ' . $this->extrawhere : ''))) + if ($template = $this->db->queryFirst("SELECT * FROM " . $this->tableName . " WHERE " . $this->nameColumn . " = '$name'" . ($this->extrawhere ? ' ' . $this->extrawhere : ''))) { return $template[ $this->dataColumn ]; } diff --git a/TemplateFs.php b/TemplateFs.php index de060e1..71e5a9b 100644 --- a/TemplateFs.php +++ b/TemplateFs.php @@ -108,7 +108,7 @@ class BSTemplateFs extends BSTemplate * * @param string The name of the template call */ - private function _loadTemplate($name) + protected function _loadTemplate($name) { $path = BSRegister::GetAppPath() . $this->templateDir . $name . '.' . $this->extension; if (is_file($path)) -- 2.43.5