$this->registry is a no-no in construct_debug_block()
[isso.git] / kernel.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Iris Studios Shared Object Framework [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
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 * Iris Studios Shared Object Framework Kernel
24 * kernel.php
25 *
26 * @package ISSO
27 */
28
29 if (!function_exists('version_compare'))
30 {
31 trigger_error('You need PHP version 4.1.0 or newer to run ISSO', E_USER_ERROR);
32 exit;
33 }
34
35 if (version_compare(PHP_VERSION, '5.0.0', '>='))
36 {
37 if (ini_get('error_reporting') & E_NOTICE)
38 {
39 error_reporting(ini_get('error_reporting') - E_NOTICE);
40 }
41 if (ini_get('error_reporting') & E_USER_NOTICE)
42 {
43 error_reporting(ini_get('error_reporting') - E_USER_NOTICE);
44 }
45 }
46
47 $oldlevel = ini_get('error_reporting');
48 $newlevel = $oldlevel;
49 $levels = array(E_ERROR => E_USER_ERROR, E_WARNING => E_USER_WARNING, E_NOTICE => E_USER_NOTICE);
50 foreach ($levels AS $php => $isso)
51 {
52 if ($oldlevel & $php)
53 {
54 if (!($oldlevel & $isso))
55 {
56 $newlevel += $isso;
57 }
58 }
59 else
60 {
61 if ($oldlevel & $isso)
62 {
63 $newlevel -= $isso;
64 }
65 }
66 }
67 error_reporting($newlevel);
68
69 if ((bool)ini_get('register_globals') === true)
70 {
71 $superglobals = array('_GET', '_COOKIE', '_FILES', '_POST', '_SERVER', '_ENV');
72 foreach ($superglobals AS $global)
73 {
74 if (is_array(${$global}))
75 {
76 foreach (${$global} AS $_key => $_val)
77 {
78 if (isset(${$_key}))
79 {
80 unset(${$_key});
81 }
82 }
83 }
84 }
85 }
86
87 /**#@+
88 * Input cleaning type constant
89 */
90 /**
91 * Integer type
92 */
93 define('TYPE_INT', 1);
94
95 /**
96 * Unsigned integer
97 */
98 define('TYPE_UINT', 2);
99
100 /**
101 * Float type
102 */
103 define('TYPE_FLOAT', 4);
104
105 /**
106 * Boolean type
107 */
108 define('TYPE_BOOL', 8);
109
110 /**
111 * String - cleaned
112 */
113 define('TYPE_STR', 16);
114
115 /**
116 * String - deliberate unclean
117 */
118 define('TYPE_STRUN', 32);
119
120 /**
121 * No cleaning - here for use in API
122 */
123 define('TYPE_NOCLEAN', 64);
124 /**#@-*/
125
126 /**
127 * Iris Studios Shared Object Framework (ISSO)
128 *
129 * This framework allows a common backend to be used amongst all Iris
130 * Studios applications and is built to be abstract and flexible.
131 * The base framework handles all loading and module management.
132 *
133 * @author Iris Studios, Inc.
134 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
135 * @version $Revision$
136 * @package ISSO
137 *
138 */
139 class Shared_Object_Framework
140 {
141 /**
142 * ISSO version
143 * @var string
144 */
145 var $version = '[#]version[#]';
146
147 /**
148 * Location of ISSO, used for internal linking
149 * @var string
150 */
151 var $sourcepath = '';
152
153 /**
154 * Path of the current application
155 * @var string
156 */
157 var $apppath = '';
158
159 /**
160 * Web path used to get the web location of the installation of ISSO; only used for Printer module
161 * @var string
162 */
163 var $webpath = '';
164
165 /**
166 * Name of the current application
167 * @var string
168 */
169 var $application = '';
170
171 /**
172 * Version of the current application
173 * @var string
174 */
175 var $appversion = '';
176
177 /**
178 * Whether debug mode is on or off
179 * @var bool
180 */
181 var $debug = false;
182
183 /**
184 * List of all active debug messages
185 * @var array
186 */
187 var $debuginfo = array();
188
189 /**
190 * List of loaded modules
191 * @var array
192 */
193 var $modules = array();
194
195 /**
196 * An array of sanitized variables that have been cleaned for HTML tag openers and double quotes
197 * @var array
198 */
199 var $in = array();
200
201 /**
202 * If we are running with magic_quotes_gpc on or off
203 * @var int
204 */
205 var $magicquotes = 0;
206
207 // ###################################################################
208 /**
209 * Constructor
210 */
211 function __construct()
212 {
213 // error reporting
214 set_error_handler(array(&$this, '_error_handler'));
215
216 // magic quotes
217 $this->magicquotes = get_magic_quotes_gpc();
218 set_magic_quotes_runtime(0);
219
220 // start input sanitize using variable_order GPC
221 if (!defined('ISSO_NO_INPUT_SANITIZE'))
222 {
223 $this->exec_sanitize_data();
224 }
225
226 if (defined('ISSO_CHECK_POST_REFERER'))
227 {
228 $this->exec_referer_check();
229 }
230
231 $GLOBALS['isso:null-framework'] = null;
232 }
233
234 // ###################################################################
235 /**
236 * (PHP 4) Constructor
237 */
238 function Shared_Object_Framework()
239 {
240 $this->__construct();
241 }
242
243 // ###################################################################
244 /**
245 * Prepares a path for being set as the sourcepath
246 *
247 * @access public
248 *
249 * @param string Source path or URL
250 *
251 * @return string Prepared source path
252 */
253 function fetch_sourcepath($source)
254 {
255 if (substr($source, strlen($source) - 1) != DIRECTORY_SEPARATOR)
256 {
257 $source .= DIRECTORY_SEPARATOR;
258 }
259 return $source;
260 }
261
262 // ###################################################################
263 /**
264 * Loads a framework module
265 *
266 * @access public
267 *
268 * @param string Name of the framework file to load
269 * @param string Internal variable to initialize as; to not instantiate (just require) leave it as NULL
270 * @param bool Globalize the internal variable?
271 *
272 * @return object Instantiated instance
273 */
274 function &load($framework, $asobject, $globalize = false)
275 {
276 // set the object interlock
277 if (!method_exists($GLOBALS['isso:null-framework'], 'load'))
278 {
279 $GLOBALS['isso:null-framework'] =& $this;
280 }
281
282 if ($this->is_loaded($framework))
283 {
284 return $this->modules["$framework"];
285 }
286
287 if ($this->sourcepath == '')
288 {
289 trigger_error('Invalid sourcepath specified', E_USER_ERROR);
290 }
291
292 if (file_exists($this->sourcepath . $framework . '.php'))
293 {
294 require_once($this->sourcepath . $framework . '.php');
295 }
296 else
297 {
298 trigger_error('Could not find the framework ' . $this->sourcepath . $framework . '.php', E_USER_ERROR);
299 }
300
301 if ($asobject === null)
302 {
303 return;
304 }
305
306 if (isset($this->$asobject))
307 {
308 trigger_error('Cannot instantiate framework `' . $framework . '` into `' . $asobject . '`', E_USER_ERROR);
309 }
310
311 $this->$asobject = new $framework($this);
312
313 $this->modules["$framework"] =& $this->$asobject;
314
315 if ($globalize)
316 {
317 $GLOBALS["$asobject"] =& $this->$asobject;
318 }
319
320 return $this->$asobject;
321 }
322
323 // ###################################################################
324 /**
325 * Prints a list of all currently loaded framework modules
326 *
327 * @access public
328 *
329 * @param bool Return the data as an array?
330 *
331 * @return mixed HTML output or an array of loaded modules
332 */
333 function show_modules($return = false)
334 {
335 foreach ($this->modules AS $object)
336 {
337 $modules[] = get_class($object);
338 }
339
340 if ($return)
341 {
342 return $modules;
343 }
344 else
345 {
346 $output = "\n\n<ul>\n\t<li>";
347 $output .= implode("</li>\n\t<li>", $modules);
348 $output .= "</li>\n</ul>\n\n";
349 $this->message('Loaded Modules', $output, 1);
350 }
351 }
352
353 // ###################################################################
354 /**
355 * Verifies to see if a framework has been loaded
356 *
357 * @access public
358 *
359 * @param string Framework name
360 *
361 * @return bool Whether or not the framework has been loaded
362 */
363 function is_loaded($framework)
364 {
365 if (isset($this->modules["$framework"]))
366 {
367 return true;
368 }
369 else
370 {
371 return false;
372 }
373 }
374
375 // ###################################################################
376 /**
377 * Prints an ISSO message
378 *
379 * @access public
380 *
381 * @param string The title of the message
382 * @param string The content of the message
383 * @param integer Type of message to be printed
384 * @param bool Return the output?
385 * @param bool Show the debug stack?
386 *
387 * @return mixed Output or null
388 */
389 function message($title, $message, $type, $return = false, $stack = true)
390 {
391 switch ($type)
392 {
393 // Message
394 case 1:
395 $prefix = 'Message';
396 $color = '#669900';
397 $font = '#000000';
398 break;
399
400 // Warning
401 case 2:
402 $prefix = 'Warning';
403 $color = '#003399';
404 $font = '#FFFFFF';
405 break;
406
407 case 3:
408 $prefix = 'Error';
409 $color = '#990000';
410 $font = '#EFEFEF';
411 break;
412 }
413
414 $backtrace = debug_backtrace();
415 unset($backtrace[0]);
416
417 $output = "\n<br />\n<table cellpadding=\"4\" cellspacing=\"1\" border=\"0\" width=\"500\" style=\"background-color: $color; color: black; font-family: Verdana, sans-serif; font-size: 12px;\">";
418 $output .= "\n<tr style=\"color: $font; text-align: left\">\n\t<td><strong>$prefix: $title</strong></td>\n</tr>";
419 $output .= "\n<tr style=\"background-color: #FFFFFF; text-align: left\">\n\t<td>$message</td>\n</tr>";
420 $output .= (($stack AND $GLOBALS['isso:null-framework']->debug) ? "\n<tr style=\"background-color: #FFFFFF; text-align: left\">\n\t<td><strong>Debug Stack:</strong> <pre>" . print_r($backtrace, true) . "</pre></td>\n</tr>" : '');
421 $output .= "\n</table>\n<br />\n";
422
423 if ($return)
424 {
425 return $output;
426 }
427 else
428 {
429 print($output);
430 }
431 }
432
433 // ###################################################################
434 /**
435 * Custom error handler for ISSO; only handle E_WARNING, E_NOTICE,
436 * E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE
437 *
438 * @access private
439 *
440 * @param integer Error number
441 * @param string Error message string
442 * @param string File that contains the error
443 * @param string The line number of the error
444 * @param string The active symbol table at which point the error occurred
445 */
446 function _error_handler($errno, $errstr, $errfile, $errline)
447 {
448 switch ($errno)
449 {
450 // Fatal
451 case E_USER_ERROR:
452 $title = 'Fatal';
453 $level = 3;
454 if (!(ini_get('error_reporting') & E_USER_ERROR))
455 {
456 return;
457 }
458 break;
459
460 // Error
461 case E_USER_WARNING:
462 $title = 'Warning';
463 $level = 2;
464 if (!(ini_get('error_reporting') & E_USER_WARNING) AND !(ini_get('error_reporting') & E_WARNING))
465 {
466 return;
467 }
468 break;
469
470 // Warning
471 case E_USER_NOTICE:
472 default:
473 $title = 'Notice';
474 $level = 1;
475 if (!(ini_get('error_reporting') & E_USER_NOTICE) AND !(ini_get('error_reporting') & E_NOTICE))
476 {
477 return;
478 }
479 break;
480 }
481
482 $errfile = str_replace(array(getcwd(), dirname(getcwd())), '', $errfile);
483
484 $errstr .= " in <strong>$errfile</strong> on line <strong>$errline</strong>";
485
486 $this->message($title, $errstr, $level);
487
488 if ($errno == E_USER_ERROR)
489 {
490 exit;
491 }
492 }
493
494 // ###################################################################
495 /**
496 * Creates a table that explains the error reporting levels and their
497 * state
498 *
499 * @access public
500 */
501 function explain_error_reporting()
502 {
503 $levels = array(
504 'E_ERROR' => E_ERROR,
505 'E_WARNING' => E_WARNING,
506 'E_PARSE' => E_PARSE,
507 'E_NOTICE' => E_NOTICE,
508 'E_CORE_ERROR' => E_CORE_ERROR,
509 'E_CORE_WARNING' => E_CORE_WARNING,
510 'E_COMPILE_ERROR' => 64,
511 'E_COMPILE_WARNING' => 128,
512 'E_USER_ERROR' => E_USER_ERROR,
513 'E_USER_WARNING' => E_USER_WARNING,
514 'E_USER_NOTICE' => E_USER_NOTICE,
515 'E_ALL' => E_ALL,
516 'E_STRICT' => 2048
517 );
518
519 $table = '<table cellspacing="0" cellpadding="2" border="0">';
520
521 foreach ($levels AS $name => $value)
522 {
523 $table .= '
524 <tr>
525 <td>' . $name . '</td>
526 <td>' . (ini_get('error_reporting') & $value) . '</td>
527 </tr>';
528 }
529
530 $table .= '
531 </table>';
532
533 $this->message('Error Reporting', $table, 1);
534 }
535
536 // ###################################################################
537 /**
538 * Logs a debug message for verbose output
539 *
540 * @access public
541 *
542 * @param string Message
543 */
544 function debug($message)
545 {
546 $this->debuginfo[] = $message;
547 }
548
549 // ###################################################################
550 /**
551 * Recursive XSS cleaner
552 *
553 * @access private
554 *
555 * @param mixed Unsanitized REQUEST data
556 *
557 * @return mixed Sanitized data
558 */
559 function _sanitize_input_recursive($data)
560 {
561 foreach ($data AS $key => $value)
562 {
563 if (is_array($value))
564 {
565 $data["$key"] = $this->_sanitize_input_recursive($value);
566 }
567 else
568 {
569 $data["$key"] = $this->sanitize($value);
570 }
571 }
572 return $data;
573 }
574
575 // ###################################################################
576 /**
577 * Simple way to protect against HTML attacks with Unicode support
578 *
579 * @access public
580 *
581 * @param string Unsanitzed text
582 *
583 * @return string Properly protected text that only encodes potential threats
584 */
585 function sanitize($text)
586 {
587 if ($this->magicquotes)
588 {
589 return str_replace(array('<', '>', '\"', '"'), array('&lt;', '&gt;', '&quot;', '&quot;'), $text);
590 }
591 else
592 {
593 return str_replace(array('<', '>', '"'), array('&lt;', '&gt;', '&quot;'), $text);
594 }
595 }
596
597 // ###################################################################
598 /**
599 * Unicode-safe entity encoding system; similar to sanitize()
600 *
601 * @access public
602 *
603 * @param string Unsanitized text
604 *
605 * @return string Unicode-safe sanitized text with entities preserved
606 */
607 function entity_encode($text)
608 {
609 $text = str_replace('&', '&amp;', $text);
610 $text = $this->sanitize($text);
611 return $text;
612 }
613
614 // ###################################################################
615 /**
616 * Takes text that has been processed for HTML and unsanitizes it
617 *
618 * @access public
619 *
620 * @param string Text that needs to be turned back into HTML
621 *
622 * @return string Unsanitized text
623 */
624 function unsanitize($text)
625 {
626 return str_replace(array('&lt;', '&gt;', '&quot;'), array('<', '>', '"'), $text);
627 }
628
629 // ###################################################################
630 /**
631 * Smart addslashes() that only applies itself it the Magic Quotes GPC
632 * is off. This should only be run on database query values.
633 *
634 * @access public
635 *
636 * @param string Some string
637 * @param bool If the data is binary; if so it'll be run through DB::escape_stringing()
638 * @param bool Force magic quotes to be off
639 *
640 * @return string String that has slashes added
641 */
642 function escape($str, $binary = false, $force = true)
643 {
644 if ($this->magicquotes AND !$force)
645 {
646 if (isset($this->db) AND $binary)
647 {
648 if (is_resource($this->db->link_id))
649 {
650 return $this->db->escape_string(str_replace(array("\'", '\"'), array("'", '"'), $str));
651 }
652 }
653 return $str;
654 }
655 else
656 {
657 if (isset($this->db) AND $binary)
658 {
659 if (is_resource($this->db->link_id))
660 {
661 return $this->db->escape_string($str);
662 }
663 }
664 return addslashes($str);
665 }
666 }
667
668 // ###################################################################
669 /**
670 * Runs through all of the input data and sanitizes it.
671 *
672 * @access public
673 */
674 function exec_sanitize_data()
675 {
676 $this->in = $this->_sanitize_input_recursive(array_merge($_GET, $_POST, $_COOKIE));
677 }
678
679 // ###################################################################
680 /**
681 * Sanitize function for something other than a string (which
682 * everything is sanitized for if you use exec_sanitize_data(). Cleaned
683 * data is placed back into $isso->in; this makes it so you don't have
684 * to constantly intval() [etc.] data.
685 *
686 * @access public
687 *
688 * @param array Array of elements to clean as varname => type
689 */
690 function input_clean_array($vars)
691 {
692 foreach ($vars AS $varname => $type)
693 {
694 $this->input_clean($varname, $type);
695 }
696 }
697
698 // ###################################################################
699 /**
700 * Sanitize function that does a single variable as oppoesd to an array
701 * (see input_clean_array() for more details)
702 *
703 * @access public
704 *
705 * @param string Variable name in $isso->in[]
706 * @param integer Sanitization type constant
707 */
708 function input_clean($varname, $type)
709 {
710 if (isset($this->in["$varname"]))
711 {
712 $this->in["$varname"] = $this->clean($this->in["$varname"], $type);
713 }
714 else
715 {
716 $this->in["$varname"] = null;
717 }
718
719 return $this->in["$varname"];
720 }
721
722 // ###################################################################
723 /**
724 * Cleaning function that does the work for input_clean(); this is
725 * moved here so it can be used to clean things that aren't in
726 * $isso->in[]
727 *
728 * @access public
729 *
730 * @param mixed Data
731 * @param integer Sanitization type constant
732 *
733 * @return mixed Cleaned data
734 */
735 function clean($value, $type)
736 {
737 if ($type == TYPE_INT)
738 {
739 $value = intval($value);
740 }
741 else if ($type == TYPE_UINT)
742 {
743 $value = abs(intval($value));
744 }
745 else if ($type == TYPE_FLOAT)
746 {
747 $value = floatval($value);
748 }
749 else if ($type == TYPE_BOOL)
750 {
751 $value = (bool)$value;
752 }
753 else if ($type == TYPE_STR)
754 {
755 $value = $value;
756 }
757 else if ($type == TYPE_STRUN)
758 {
759 $value = $this->unsanitize($value);
760 }
761 else if ($type == TYPE_NOCLEAN)
762 {
763 $value = $value;
764 }
765 else
766 {
767 trigger_error('Invalid clean type `' . $type . '` specified', E_USER_ERROR);
768 }
769
770 return $value;
771 }
772
773 // ###################################################################
774 /**
775 * Checks to see if a POST refer is actually from us
776 *
777 * @access public
778 */
779 function exec_referer_check()
780 {
781 if ($_SERVER['REQUEST_METHOD'] == 'POST')
782 {
783 $host = ($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_ENV['HTTP_HOST'];
784
785 if ($host AND $_SERVER['HTTP_REFERER'])
786 {
787 $parts = parse_url($_SERVER['HTTP_REFERER']);
788 $ourhost = $parts['host'] . (($parts['port']) ? ":$parts[port]" : '');
789
790 if ($ourhost != $host)
791 {
792 trigger_error('No external hosts are allowed to POST to this application', E_USER_ERROR);
793 }
794 $this->debug('remote post check = ok');
795 }
796 else
797 {
798 $this->debug('remote post check = FAILED');
799 }
800 }
801 }
802
803 // ###################################################################
804 /**
805 * Constructs a debug information box that contains various debugging
806 * information points
807 *
808 * @access public
809 *
810 * @param bool Show template information?
811 *
812 * @return string Debugging block
813 */
814 function construct_debug_block($dotemplates)
815 {
816 $debug = '';
817
818 if ($this->debug)
819 {
820 $debug = "\n<ul>";
821
822 // templates
823 if ($dotemplates)
824 {
825 // both template and template_fs are viable, so we need to determine the right one
826 if ($this->is_loaded('template'))
827 {
828 $tpl_obj =& $this->modules['template'];
829 }
830 else if ($this->is_loaded('template_fs'))
831 {
832 $tpl_obj =& $this->modules['template_fs'];
833 }
834 else
835 {
836 $tpl_obj = null;
837 }
838
839 $optlist = array();
840 $usage = array();
841 foreach ($tpl_obj->usage AS $name => $count)
842 {
843 if (in_array($name, $tpl_obj->uncached))
844 {
845 $optlist[] = $name . '[' . $count . ']';
846 }
847 $usage[] = $name . " ($count)";
848 }
849
850 $sizeof = sizeof($tpl_obj->uncached);
851 if ($sizeof > 0)
852 {
853 $debug .= "\n\t<li><strong style=\"color: red\">Uncached Template(s):</strong> $sizeof ( " . implode(' &nbsp; ', $optlist) . " )</li>";
854 }
855 }
856
857 // source control
858 $scinfo = 'Not Under Source Control';
859 if (defined('SVN'))
860 {
861 $scinfo = constant('SVN');
862
863 if ($test == '$' . 'Id: $')
864 {
865 $scinfo = 'Not Under Source Control';
866 }
867 else
868 {
869 $scinfo = preg_replace('#\$' . '(Head)?URL: (.+?) \$#e', "end(explode('/', '\\2'))", $scinfo);
870 $scinfo = preg_replace('#\$' . '(LastModified)?Revision: (.+?) \$#', 'SVN \\2', $scinfo);
871 $scinfo = 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', $scinfo);
872 }
873 }
874
875 $scinfo = trim($scinfo);
876 $debug .= "\n\t<li><strong>Source Control:</strong> $scinfo</li>";
877
878 // query information
879 if (is_object($this->modules['db_mysql']))
880 {
881 $debug .= "\n\t<li><strong>Total Queries:</strong> " . sizeof($this->modules['db_mysql']->history) . " (<a href=\"" . $this->sanitize($_SERVER['REQUEST_URI']) . ((strpos($_SERVER['REQUEST_URI'], '?') !== false) ? '&amp;query=1' : '?query=1') . "\">?</a>)</li>";
882 }
883
884 // total execution time
885 if (defined('ISSO_MT_START'))
886 {
887 $this->load('functions', 'functions');
888 $debug .= "\n\t<li><strong>Total Execution Time:</strong> " . round($this->modules['functions']->fetch_microtime_diff(ISSO_MT_START), 10) . "</li>";
889 }
890
891 // debug notices
892 $debug .= "\n\t<li>\n\t\t<select>\n\t\t\t<option>Debug Notices (" . sizeof($this->debuginfo) . ")</option>";
893 foreach ((array)$this->debuginfo AS $msg)
894 {
895 $debug .= "\n\t\t\t<option>--- $msg</option>";
896 }
897 $debug .= "\n\t\t</select>\n\t</li>";
898
899 // loaded modules
900 $modules = $this->show_modules(true);
901 $debug .= "\n\t<li>\n\t\t<select>\n\t\t\t<option>Loaded Modules (" . sizeof($modules) . ")</option>";
902 foreach ($modules AS $mod)
903 {
904 $debug .= "\n\t\t\t<option>--- $mod</option>";
905 }
906 $debug .= "\n\t\t</select>\n\t</li>";
907
908 // template usage
909 if ($dotemplates)
910 {
911 $debug .= "\n\t<li>\n\t\t<select>\n\t\t\t<option>Template Usage (" . array_sum($tpl_obj->usage) . ")</option>";
912 foreach ($usage AS $tpl)
913 {
914 $debug .= "\n\t\t\t<option>--- $tpl</option>";
915 }
916 $debug .= "\n\t\t</select>\n\t</li>";
917 }
918
919 $debug .= "\n</ul>";
920
921 $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";
922 }
923
924 return $debug;
925 }
926 }
927
928 /*=====================================================================*\
929 || ###################################################################
930 || # $HeadURL$
931 || # $Id$
932 || ###################################################################
933 \*=====================================================================*/
934 ?>