From 684f426067b306541308588962f9d049eb652fb2 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 18 Dec 2005 07:54:11 +0000 Subject: [PATCH] Moving the debug block at the end of compiled pages into the kernel that can be used both without code duplication --- kernel.php | 110 ++++++++++++++--------------------------- printer.php | 107 +--------------------------------------- template.php | 136 +-------------------------------------------------- 3 files changed, 42 insertions(+), 311 deletions(-) diff --git a/kernel.php b/kernel.php index 19bb2fa..a3b469f 100644 --- a/kernel.php +++ b/kernel.php @@ -824,26 +824,39 @@ class Shared_Object_Framework { $debug = ''; - if ($this->registry->debug) + if ($this->debug) { - // --- START $debug = "\n"; - $debug = "\n
\n" . $this->registry->message('Debug Information', $debug, 1, true, false); - $template = str_replace('', "\n\n\n
\n$debug\n
\n\n\n", $template); + $debug = "\n\n\n
\n\n
\n" . $this->message('Debug Information', $debug, 1, true, false) . "\n
\n\n\n"; } return $debug; diff --git a/printer.php b/printer.php index 8f4ae4d..e21b868 100644 --- a/printer.php +++ b/printer.php @@ -364,111 +364,8 @@ JS; { echo "\n\n"; } - - if ($this->registry->debug) - { - // source control - $scinfo = 'Not Under Source Control'; - $possiblescms = array('cvs', 'svn', 'cvs_information', 'svn_information', 'scm', 'sc_information', 'scm_information'); - foreach ($possiblescms AS $scm) - { - if (defined(strtoupper($scm))) - { - $scinfo = constant(strtoupper($scm)); - - $type = ''; - // CVS - if (strpos($scinfo, 'RCSfile:') !== false) - { - $type = 'cvs'; - } - else if (strpos($scinfo, ',v ') !== false) - { - $type = 'cvs'; - } - // SVN - else if (strpos($scinfo, 'URL:') !== false) - { - $type = 'svn'; - } - else if (strpos($scinfo, 'https://') !== false OR strpos($scinfo, 'http://') !== false) - { - $type= 'svn'; - } - // not found so just return it - // try a SVN ID tag as we can't really tell if we're using it - else - { - $test = preg_replace('#\$' . 'Id: (.+?) (.+?) [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(.+?) (.+?) \$#', '\\1 - SVN \\2', $scinfo); - if ($test == '$' . 'Id: $') - { - $scinfo = 'Not Under Source Control'; - } - else - { - $scinfo = $test; - } - break; - } - - if ($type == 'cvs') - { - $scinfo = preg_replace('#\$' . 'RCSfile: (.+?) \$#', '\\1', $scinfo); - $scinfo = preg_replace('#\$' . 'Revision: (.+?) \$#', 'CVS \\1', $scinfo); - $scinfo = preg_replace('#\$' . 'Id: (.+?) (.+?) [0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} (.+?) (.+?) \$#', '\\1 - CVS \\2', $scinfo); - } - else if ($type == 'svn') - { - $scinfo = preg_replace('#\$' . '(Head)?URL: (.+?) \$#e', "end(explode('/', '\\2'))", $scinfo); - $scinfo = preg_replace('#\$' . '(LastModified)?Revision: (.+?) \$#', 'SVN \\2', $scinfo); - $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); - } - else - { - $scinfo = 'Not Under Source Control'; - } - break; - } - } - $scinfo = trim($scinfo); - $debug = "\n\t
  • Source Control: $scinfo
  • "; - - // query information - if (is_object($this->registry->modules['db_mysql'])) - { - $debug .= "\n\t
  • Total Queries: " . sizeof($this->registry->modules['db_mysql']->history) . " (registry->sanitize($_SERVER['REQUEST_URI']) . ((strpos($_SERVER['REQUEST_URI'], '?') !== false) ? '&query=1' : '?query=1') . "\">?)
  • "; - } - - // total execution time - if (defined('ISSO_MT_START')) - { - $this->registry->load('functions', 'functions'); - $debug .= "\n\t
  • Total Execution Time: " . round($this->registry->modules['functions']->fetch_microtime_diff(ISSO_MT_START), 10) . "
  • "; - } - - // debug notices - $debug .= "\n\t
  • \n\t\t\n\t
  • "; - - // loaded modules - $modules = $this->registry->show_modules(true); - $debug .= "\n\t
  • \n\t\t\n\t
  • "; - - // --- END - $debug .= "\n"; - - $debug = "\n
    \n" . $this->registry->message('Debug Information', $debug, 1, true, false); - echo "\n\n\n
    \n$debug\n
    \n\n\n"; - } + + echo $this->registry->construct_debug_block(false); echo "\n\n\n"; diff --git a/template.php b/template.php index 78c8484..009bb7a 100644 --- a/template.php +++ b/template.php @@ -223,140 +223,8 @@ class Template exit; } - if ($this->registry->debug) - { - // --- START - $debug = "\n"; - - $debug = "\n
    \n" . $this->registry->message('Debug Information', $debug, 1, true, false); - $template = str_replace('', "\n\n\n
    \n$debug\n
    \n\n\n", $template); - } - + $template = str_replace('', $this->registry->construct_debug_block(true) . '', $template); + print($template); } -- 2.43.5