Added the debug output to the Printer system
[isso.git] / PrinterRootElementPage.php
1 <?php
2 /*=====================================================================*
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright ©2002-[#]year[#] Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 /**
23 * Printer Root Element: Page (PrinterRootElementPage.php)
24 *
25 * @package ISSO
26 */
27
28 require_once('ISSO/PrinterRootElement.php');
29
30 /**
31 * Printer Root Element: Page
32 *
33 * This root element represents the entire page and is usually used for all
34 * printer applications
35 *
36 * @author Blue Static
37 * @copyright Copyright (c)2002 - [#]year[#], Blue Static
38 * @version $Revision$
39 * @package ISSO
40 *
41 */
42 class BSPrinterRootElementPage extends BSPrinterRootElement
43 {
44 /**
45 * The page title
46 * @var string
47 */
48 private $title;
49
50 /**
51 * Language information array: ('langcode' =>, 'direction' =>, 'charset' =>)
52 * @var array
53 */
54 private $language = array('langcode' => 'en_US', 'direction' => 'ltr', 'charset' => 'utf-8');
55
56 /**
57 * The CSS stylesheet
58 * @var string
59 */
60 private $stylesheet;
61
62 // ###################################################################
63 /**
64 * Constructor
65 *
66 * @param string Page title
67 */
68 function __construct($title)
69 {
70 $this->title = $title;
71 }
72
73 // ###################################################################
74 /**
75 * Sets the language array information
76 *
77 * @param array Language array
78 */
79 public function setLanguageInformation($lang)
80 {
81 $this->language = $lang;
82 }
83
84 // ###################################################################
85 /**
86 * Sets the path to the CSS style sheet
87 *
88 * @param string Path
89 */
90 public function setStylesheet($stylesheet)
91 {
92 $this->stylesheet = $stylesheet;
93 }
94
95 // ###################################################################
96 /**
97 * Returns the HTML for all printed children elements
98 *
99 * @return string Printed HTML
100 */
101 protected function _paintChildren()
102 {
103 $builder = '';
104
105 foreach ($this->children AS $child)
106 {
107 $this->builder .= "\n" . $child->paint() . "\n";
108 }
109
110 return $this->builder;
111 }
112
113 // ###################################################################
114 /**
115 * Tells the element to paint itself (and any children)
116 */
117 public function paint()
118 {
119 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
120 echo "<html xml:lang=\"" . $this->language['langcode'] . "\" lang=\"" . $this->language['langcode'] . "\" dir=\"" . $this->language['direction'] . "\">\n<head>";
121 echo "\n\t<title>" . sprintf(_('%1$s - %2$s'), BSRegister::GetApplication(), $this->title) . "</title>";
122 echo "\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . $this->language['charset'] . "\" />";
123 echo "\n\t<link rel=\"stylesheet\" href=\"" . $this->stylesheet . "\" />";
124 echo "\n</head>\n<body>\n";
125
126 if (BSRegister::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR !constant('ISSO_PRINTER_NO_NAVIGATION')))
127 {
128 echo BSRegister::GetType('PrinterNavigation')->generate_header_html();
129 }
130
131 echo $this->_paintChildren();
132
133 if (BSRegister::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR !constant('ISSO_PRINTER_NO_NAVIGATION')))
134 {
135 echo BSRegister::GetType('PrinterNavigation')->generate_footer_html();
136 }
137
138 $copyright = "\n<br />\n<p align=\"center\" class=\"copyright\">\n\t<a href=\"http://www.bluestatic.org\" target=\"_blank\">" . BSRegister::GetApplication() . ' ' . BSRegister::GetAppVersion() . ", &copy;2002 - " . gmdate('Y') . " Blue Static</a>\n</p>";
139
140 if (!defined('ISSO_PRINTER_HIDE_SETUP'))
141 {
142 echo "\n$copyright";
143
144 echo "\n\n\n";
145
146 if (BSRegister::GetDebug())
147 {
148 if (defined('SVN') AND preg_match('#^\$Id:?#', constant('SVN')))
149 {
150 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'));
151 }
152
153 if (defined('ISSO_MT_START'))
154 {
155 echo "\n<div align=\"center\">Executed in " . round(BSFunctions::FetchMicrotimeDiff(ISSO_MT_START), 10) . ' seconds</div>';
156 }
157
158 echo "\n<br /><div align=\"center\">" . BSRegister::GetDebugList() . "</div>\n";
159
160 if (BSRegister::GetType('Db'))
161 {
162 $queries = BSRegister::GetType('Db')->getHistory();
163
164 $table = new BSPrinterRootElementTable();
165 $head = new BSPrinterTableElement();
166 $head->addChild(new BSPrinterLabelElement('Query Debug'));
167 $head->setCssClass('thead');
168 $table->addHeadingChild($head);
169
170 foreach ($queries AS $query)
171 {
172 $tr = new BSPrinterTableElement();
173 $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"));
174 $table->addChild($tr);
175 }
176
177 $table->setWidth('30%');
178
179 echo $table->paint();
180 }
181 }
182 }
183
184 echo("\n\n</body>\n</html>");
185 }
186 }
187
188 /*=====================================================================*
189 || ###################################################################
190 || # $HeadURL$
191 || # $Id$
192 || ###################################################################
193 \*=====================================================================*/
194 ?>