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;
}
/**