From 770566783b17f9fbaed1f6204c25256f6a6715fe Mon Sep 17 00:00:00 2001
From: Robert Sesek <rsesek@bluestatic.org>
Date: Wed, 20 Dec 2006 01:45:21 +0000
Subject: [PATCH] Added the debug output to the Printer system

---
 PrinterRootElementPage.php | 78 ++++++++++++++++++++++++--------------
 1 file changed, 49 insertions(+), 29 deletions(-)

diff --git a/PrinterRootElementPage.php b/PrinterRootElementPage.php
index a576754..a3c85a8 100644
--- a/PrinterRootElementPage.php
+++ b/PrinterRootElementPage.php
@@ -116,37 +116,21 @@ class BSPrinterRootElementPage extends BSPrinterRootElement
 	*/
 	public function paint()
 	{		
-		echo("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
-		echo("<html xml:lang=\"" . $this->language['langcode'] . "\" lang=\"" . $this->language['langcode'] . "\" dir=\"" . $this->language['direction'] . "\">\n<head>");
-		echo("\n\t<title>" . sprintf(_('%1$s - %2$s'), BSRegister::GetApplication(), $this->title) . "</title>");
-		echo("\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . $this->language['charset'] . "\" />");
-		echo("\n\t<link rel=\"stylesheet\" href=\"" . $this->stylesheet . "\" />");
-		// echo $this->code;
-		echo("\n</head>\n<body>\n");
+		echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
+		echo "<html xml:lang=\"" . $this->language['langcode'] . "\" lang=\"" . $this->language['langcode'] . "\" dir=\"" . $this->language['direction'] . "\">\n<head>";
+		echo "\n\t<title>" . sprintf(_('%1$s - %2$s'), BSRegister::GetApplication(), $this->title) . "</title>";
+		echo "\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . $this->language['charset'] . "\" />";
+		echo "\n\t<link rel=\"stylesheet\" href=\"" . $this->stylesheet . "\" />";
+		echo "\n</head>\n<body>\n";
 		
-		if (BSRegister::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR (defined('ISSO_PRINTER_NO_NAVIGATION') AND constant('ISSO_PRINTER_NO_NAVIGATION') != true)))
+		if (BSRegister::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR !constant('ISSO_PRINTER_NO_NAVIGATION')))
 		{
 			echo BSRegister::GetType('PrinterNavigation')->generate_header_html();
 		}
 		
-		echo($this->_paintChildren());
+		echo $this->_paintChildren();
 		
-		if (BSRegister::GetDebug() AND isset($_GET['query']))
-		{
-			ob_clean();
-			ob_end_clean();
-			
-			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);
-				}
-			}
-			exit;
-		}
-		
-		if (BSRegister::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR (defined('ISSO_PRINTER_NO_NAVIGATION') AND constant('ISSO_PRINTER_NO_NAVIGATION') != true)))
+		if (BSRegister::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR !constant('ISSO_PRINTER_NO_NAVIGATION')))
 		{
 			echo BSRegister::GetType('PrinterNavigation')->generate_footer_html();
 		}
@@ -155,13 +139,49 @@ class BSPrinterRootElementPage extends BSPrinterRootElement
 				
 		if (!defined('ISSO_PRINTER_HIDE_SETUP'))
 		{
-			echo("\n$copyright");
-			//echo $this->registry->construct_debug_block(false);
+			echo "\n$copyright";
+			
+			echo "\n\n\n";
+			
+			if (BSRegister::GetDebug())
+			{
+				if (defined('SVN') AND preg_match('#^\$Id:?#', constant('SVN')))
+				{
+					echo preg_replace('#\$' . 'Id: (.+?) ([0-9].+?) [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(.+?) (.+?) \$#', "\n<br />\n" . '<div align="center"><strong>\1</strong> &mdash; r\2</div>', constant('SVN'));
+				}
+				
+				if (defined('ISSO_MT_START'))
+				{
+					echo "\n<div align=\"center\">Executed in " . round(BSFunctions::FetchMicrotimeDiff(ISSO_MT_START), 10) . ' seconds</div>';
+				}
+				
+				echo "\n<br /><div align=\"center\">" . BSRegister::GetDebugList() . "</div>\n";
+				
+				if (BSRegister::GetType('Db'))
+				{
+					$queries = BSRegister::GetType('Db')->getHistory();
+					
+					$table = new BSPrinterRootElementTable();
+					$head = new BSPrinterTableElement();
+					$head->addChild(new BSPrinterLabelElement('Query Debug'));
+					$head->setCssClass('thead');
+					$table->addHeadingChild($head);
+					
+					foreach ($queries AS $query)
+					{
+						$tr = new BSPrinterTableElement();
+						$tr->addChild(new BSPrinterLabelElement("\n\t\t\t" . $query['query'] . "\n\n\t\t\t<div class=\"smallfont\">(" . $query['time'] . ")</div>\n<!--\n" . $query['trace'] . "\n-->\n\t\t"));
+						$table->addChild($tr);
+					}
+					
+					$table->setWidth('30%');
+					
+					echo $table->paint();
+				}
+			}
 		}
 		
 		echo("\n\n</body>\n</html>");
-		
-		// exit;
 	}
 }
 
-- 
2.43.5