From 5a3fb4c7718dc321eee73921a0f4601618ed6694 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 5 Jan 2009 22:55:11 -0800 Subject: [PATCH] Do not insert the debug block automatically anymore. Created BSTemplate::get_debug_block() to get it instead. * Template.php: (BSTemplate::flush): Do not insert the debug block before anymore (BSTemplate::get_debug_block): New method to get the debug block info --- CHANGES | 1 + Template.php | 51 +++++++++++++++++++++++++++++---------------------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/CHANGES b/CHANGES index ab36048..abaf646 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,7 @@ 3.2.1 =================== - New: BSFunctions::bool_to_string() to convert a boolean value into human-readable Yes/No +- Change: BSTemplate::flush() will no longer insert debug blocks, but BSTemplate::get_debug_block() can be used to retrieve it 3.2.0 =================== diff --git a/Template.php b/Template.php index ab0a294..76b8fb3 100644 --- a/Template.php +++ b/Template.php @@ -221,34 +221,41 @@ class BSTemplate throw new Exception('There is no output to print'); } - $template = $this->template; + echo $this->template; + } + + /** + * Returns the debug block + * + * @return string + */ + public static function get_debug_block() + { + if (!BSApp::get_debug()) + { + return; + } - $debugBlock = ''; - if (BSApp::get_debug() && strpos($template, '') !== false) + $debugBlock = "\n
Executed in " . round(BSFunctions::fetch_microtime_diff('0 ' . $_SERVER['REQUEST_TIME']), 10) . ' seconds
'; + $debugBlock .= "\n
" . BSApp::get_debug_list() . "
"; + + if (BSApp::$db) { - $debugBlock .= "\n
Executed in " . round(BSFunctions::fetch_microtime_diff('0 ' . $_SERVER['REQUEST_TIME']), 10) . ' seconds
'; - $debugBlock .= "\n
" . BSApp::get_debug_list() . "
"; - - if (BSApp::$db) + $queries = BSApp::$db->getHistory(); + + $debugBlock .= "
\n" . '' . "\n\t" . ''; + + foreach ($queries as $query) { - $queries = BSApp::$db->getHistory(); - - $debugBlock .= "
\n" . '
Query Debug
' . "\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"; + $debugBlock .= "\n\t"; + $debugBlock .= "\n\t\t"; + $debugBlock .= "\n\t\t\t$query[query]\n\n\t\t\t
($query[time])
\n\n\t\t\n\t"; } - $template = str_replace('', $debugBlock . '', $template); + $debugBlock .= "\n\n\n\n"; } - - print($template); + + return $debugBlock; } /** -- 2.43.5