Deprecated: Assigning the return value of new by reference is deprecated in /home/bluestat/public_html/source/index.php on line 477
ISSO - Commitdiff - ViewGit - Blue Static

Do not insert the debug block automatically anymore. Created BSTemplate::get_debug_block() to get it instead.

Robert Sesek [2009-01-06 06:55]
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 </body> anymore
(BSTemplate::get_debug_block): New method to get the debug block info
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, '</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;
 	}

 	/**