Do not insert the debug block automatically anymore. Created BSTemplate::get_debug_bl...
authorRobert Sesek <rsesek@bluestatic.org>
Tue, 6 Jan 2009 06:55:11 +0000 (22:55 -0800)
committerRobert Sesek <rsesek@bluestatic.org>
Tue, 6 Jan 2009 06:55:11 +0000 (22:55 -0800)
* Template.php:
(BSTemplate::flush): Do not insert the debug block before </body> anymore
(BSTemplate::get_debug_block): New method to get the debug block info

CHANGES
Template.php

diff --git a/CHANGES b/CHANGES
index ab36048b1482ae1f8a3aa7fc33bab74bd6a83fcb..abaf646f98b959983d58e05d988c3ebafc73cca4 100644 (file)
--- 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
 ===================
index ab0a2944b4932578bcecfd6f5402a71b198a98db..76b8fb35471ccb35fc8327973ebd1b1e5dfa8995 100644 (file)
@@ -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, '</body>') !== false)
+               $debugBlock = "\n<div align=\"center\">Executed in " . round(BSFunctions::fetch_microtime_diff('0 ' . $_SERVER['REQUEST_TIME']), 10) . ' seconds</div>';
+               $debugBlock .= "\n<br /><div align=\"center\">" . BSApp::get_debug_list() . "</div>";
+                                       
+               if (BSApp::$db)
                {
-                       $debugBlock .= "\n<div align=\"center\">Executed in " . round(BSFunctions::fetch_microtime_diff('0 ' . $_SERVER['REQUEST_TIME']), 10) . ' seconds</div>';
-                       $debugBlock .= "\n<br /><div align=\"center\">" . BSApp::get_debug_list() . "</div>";
-                                               
-                       if (BSApp::$db)
+                       $queries = BSApp::$db->getHistory();
+                       
+                       $debugBlock .= "<br />\n" . '<table cellpadding="4" cellspacing="1" border="0" align="center" width="30%" style="background-color: rgb(60, 60, 60); color: white">' . "\n\t" . '<tr><td><strong>Query Debug</strong></td></tr>';
+                       
+                       foreach ($queries as $query)
                        {
-                               $queries = BSApp::$db->getHistory();
-                               
-                               $debugBlock .= "<br />\n" . '<table cellpadding="4" cellspacing="1" border="0" align="center" width="30%" style="background-color: rgb(60, 60, 60); color: white">' . "\n\t" . '<tr><td><strong>Query Debug</strong></td></tr>';
-                               
-                               foreach ($queries as $query)
-                               {
-                                       $debugBlock .= "\n\t<tr style=\"background-color: rgb(230, 230, 230); color: black\">";
-                                       $debugBlock .= "\n\t\t<td>";
-                                       $debugBlock .= "\n\t\t\t$query[query]\n\n\t\t\t<div style=\"font-size: 9px;\">($query[time])</div>\n<!--\n$query[trace]\n-->\n\t\t</td>\n\t</tr>";
-                               }
-                               
-                               $debugBlock .= "\n</table>\n\n\n";
+                               $debugBlock .= "\n\t<tr style=\"background-color: rgb(230, 230, 230); color: black\">";
+                               $debugBlock .= "\n\t\t<td>";
+                               $debugBlock .= "\n\t\t\t$query[query]\n\n\t\t\t<div style=\"font-size: 9px;\">($query[time])</div>\n<!--\n$query[trace]\n-->\n\t\t</td>\n\t</tr>";
                        }
                        
-                       $template = str_replace('</body>', $debugBlock . '</body>', $template);
+                       $debugBlock .= "\n</table>\n\n\n";
                }
-
-               print($template);
+               
+               return $debugBlock;
        }
        
        /**