From 5864c9154f51ab5c66c70e3f5f250cc29e8aada6 Mon Sep 17 00:00:00 2001 From: "Pierre Habouzit (MadCoder" Date: Tue, 11 Jan 2005 21:23:40 +0000 Subject: [PATCH] debug has bits : 1 stands for db debug, 2 for html validation git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-296 --- include/xorg.globals.inc.php.in | 8 +++--- include/xorg/page.inc.php | 54 ++++++++++++++++++++++++----------------- templates/skin/common.devel.tpl | 2 +- 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/include/xorg.globals.inc.php.in b/include/xorg.globals.inc.php.in index f00cd91..8a71162 100644 --- a/include/xorg.globals.inc.php.in +++ b/include/xorg.globals.inc.php.in @@ -19,8 +19,8 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -require_once('diogenes.core.globals.inc.php'); -require_once('diogenes.database.inc.php'); +require_once('diogenes/diogenes.core.globals.inc.php'); +require_once('diogenes/diogenes.database.inc.php'); require_once('xorg/iterator.inc.php'); require_once('xorg/database.inc.php'); @@ -44,7 +44,7 @@ class XorgGlobals extends DiogenesCoreGlobals /** The x.org version */ var $version = '@VERSION@'; - var $debug = false; + var $debug = 0; /** db params */ var $dbdb = 'x4dat'; @@ -99,7 +99,7 @@ class XorgGlobals extends DiogenesCoreGlobals $globals->hook->menu(null); $globals->dbconnect(); - if ($globals->debug) { + if ($globals->debug & 1) { $globals->db->trace_on(); } $globals->xdb =& new XOrgDB; diff --git a/include/xorg/page.inc.php b/include/xorg/page.inc.php index 5b77edf..ca419e7 100644 --- a/include/xorg/page.inc.php +++ b/include/xorg/page.inc.php @@ -104,36 +104,46 @@ class XorgPage extends DiogenesCorePage if ($this->_page_type == NO_SKIN) { $this->display($this->_tpl); - } else { - $this->assign('menu', $globals->menu->menu()); - if ($globals->debug) { + exit; + } + + $this->assign('menu', $globals->menu->menu()); + + if ($globals->debug) { + + if ($globals->debug & 1) { $this->assign('db_trace', $globals->db->trace_format($this, 'database-debug.tpl')); - $this->assign('validate', urlencode($globals->baseurl.'/valid.html')); + } + + $this->assign('validate', urlencode($globals->baseurl.'/valid.html')); + $result = $this->fetch('skin/'.Session::get('skin')); + $ttime = sprintf('Temps total: %.02fs
', microtime_float() - $TIME_BEGIN); + $replc = "VALIDATION HTML INACTIVE
"; + + if ($globals->debug & 2) { - $result = $this->fetch('skin/'.Session::get('skin')); - $total_time = sprintf('Temps total: %.02fs
', microtime_float() - $TIME_BEGIN); $fd = fopen($this->compile_dir."/valid.html","w"); fwrite($fd, $result); fclose($fd); - - exec($globals->spoolroot."/bin/devel/xhtml.validate.pl ".$this->compile_dir."/valid.html", $val); - foreach ($val as $h) { - if (preg_match("/^X-W3C-Validator-Errors: (\d+)$/", $h, $m)) { - if ($m[1]) { - echo str_replace("@HOOK@", - "$total_time{$m[1]} ERREUR(S) !!!
", - $result); - } else { - echo str_replace("@HOOK@", "$total_time", $result); - } - exit; - } + + exec($globals->spoolroot."/bin/devel/xhtml.validate.pl ".$this->compile_dir."/valid.html", $val); + foreach ($val as $h) { + if (preg_match("/^X-W3C-Validator-Errors: (\d+)$/", $h, $m)) { + $replc = ''; + if ($m[1]) { + $replc .= "{$m[1]} ERREUR(S) !!!
"; + } + break; + } } - } else { - $this->display('skin/'.Session::get('skin')); } + + echo str_replace("@HOOK@", $ttime.$replc, $result); + exit; } + + $this->display('skin/'.Session::get('skin')); exit; } diff --git a/templates/skin/common.devel.tpl b/templates/skin/common.devel.tpl index 3fa0acd..35a1ed9 100644 --- a/templates/skin/common.devel.tpl +++ b/templates/skin/common.devel.tpl @@ -19,7 +19,7 @@ ***************************************************************************} {if #globals.debug#} -{if $db_trace neq "\n\n"} +{if $db_trace && $db_trace neq "\n\n"}

Trace de l'exécution de cette page sur mysql (hover me) -- 2.1.4