Cleaning up construct_debug_block() a little
[isso.git] / kernel.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework [#]issoversion[#]
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 * Blue Static ISSO Framework Kernel
24 * kernel.php
25 *
26 * @package ISSO
27 */
28
29 /**
30 * Yes, required
31 */
32 define('REQ_YES', 1);
33
34 /**
35 * No, not required
36 */
37 define('REQ_NO', 0);
38
39 /**
40 * Blue Static ISSO Framework (ISSO)
41 *
42 * This framework allows a common backend to be used amongst all Blue
43 * Static applications and is built to be abstract and flexible.
44 * The base framework handles all loading and module management.
45 *
46 * Constants:
47 * ISSO_MT_START - Define the microtime() value at the top of your
48 * script and this will calculate the total execution
49 * time
50 * SVN - Place SVN $Id keyword to get SVN revision information on output
51 *
52 * @author Blue Static
53 * @copyright Copyright ©2002 - [#]year[#], Blue Static
54 * @version $Revision$
55 * @package ISSO
56 *
57 */
58 class ISSO
59 {
60 // ###################################################################
61 /**
62 * Constructs a debug information box that contains various debugging
63 * information points
64 *
65 * @param bool Show template information?
66 *
67 * @return string Debugging block
68 */
69 public function construct_debug_block($dotemplates)
70 {
71 $debug = '';
72
73 if ($this->debug)
74 {
75 $debug = "\n<ul>";
76
77 // templates
78 if ($dotemplates)
79 {
80 $optlist = array();
81 $usage = array();
82 foreach ($this->modules['template']->usage AS $name => $count)
83 {
84 if (in_array($name, $this->modules['template']->uncached))
85 {
86 $optlist[] = $name . '[' . $count . ']';
87 }
88 $usage[] = $name . " ($count)";
89 }
90
91 $sizeof = sizeof($this->modules['template']->uncached);
92 if ($sizeof > 0)
93 {
94 $debug .= "\n\t<li><strong style=\"color: red\">Uncached Template(s):</strong> $sizeof ( " . implode(' &nbsp; ', $optlist) . " )</li>";
95 }
96 }
97
98 // source control
99 if (defined('SVN') AND preg_match('#\$Id:?\s*\$#', constant('SVN')))
100 {
101 $debug .= "\n\t<li><strong>Source Control:</strong> " . preg_replace('#\$' . 'Id: (.+?) ([0-9].+?) [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(.+?) (.+?) \$#', '\\1 - SVN \\2', constant('SVN')) . "</li>";
102 }
103
104 // query information
105 if (is_object($this->modules[ISSO_DB_LAYER]))
106 {
107 $debug .= "\n\t<li><strong>Total Queries:</strong> " . sizeof($this->modules[ISSO_DB_LAYER]->history) . " (<a href=\"" . $this->sanitize($_SERVER['REQUEST_URI']) . ((strpos($_SERVER['REQUEST_URI'], '?') !== false) ? '&amp;query=1' : '?query=1') . "\">?</a>)</li>";
108 }
109
110 // total execution time
111 if (defined('ISSO_MT_START'))
112 {
113 $this->load('functions', 'functions');
114 $debug .= "\n\t<li><strong>Total Execution Time:</strong> " . round($this->modules['functions']->fetch_microtime_diff(ISSO_MT_START), 10) . "</li>";
115 }
116
117 // debug notices
118 $debug .= "\n\t<li>\n\t\t<select>\n\t\t\t<option>Debug Notices (" . sizeof($this->debuginfo) . ")</option>";
119 foreach ((array)$this->debuginfo AS $msg)
120 {
121 $debug .= "\n\t\t\t<option>--- $msg</option>";
122 }
123 $debug .= "\n\t\t</select>\n\t</li>";
124
125 // template usage
126 if ($dotemplates)
127 {
128 $debug .= "\n\t<li>\n\t\t<select>\n\t\t\t<option>Template Usage (" . array_sum($this->modules['template']->usage) . ")</option>";
129 foreach ($usage AS $tpl)
130 {
131 $debug .= "\n\t\t\t<option>--- $tpl</option>";
132 }
133 $debug .= "\n\t\t</select>\n\t</li>";
134 }
135
136 $debug .= "\n</ul>";
137
138 $debug = "\n\n<!-- dev debug -->\n<div align=\"center\">\n\n<hr />\n" . $this->message('Debug Information', $debug, 1, true, false) . "\n</div>\n<!-- / dev debug -->\n\n";
139 }
140
141 return $debug;
142 }
143 }
144
145 /*=====================================================================*\
146 || ###################################################################
147 || # $HeadURL$
148 || # $Id$
149 || ###################################################################
150 \*=====================================================================*/
151 ?>