debug has bits : 1 stands for db debug, 2 for html validation
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Tue, 11 Jan 2005 21:23:40 +0000 (21:23 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:28 +0000 (23:27 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-296

include/xorg.globals.inc.php.in
include/xorg/page.inc.php
templates/skin/common.devel.tpl

index f00cd91..8a71162 100644 (file)
@@ -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;
index 5b77edf..ca419e7 100644 (file)
@@ -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<br />', microtime_float() - $TIME_BEGIN);
+            $replc  = "<span class='erreur'>VALIDATION HTML INACTIVE</span><br />";
+
+            if ($globals->debug & 2) {
 
-               $result = $this->fetch('skin/'.Session::get('skin'));
-               $total_time = sprintf('Temps total: %.02fs<br />', 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<span class='erreur'><a href='http://validator.w3.org/check?uri="
-                                .$globals->baseurl."/valid.html&amp;ss=1#result'>{$m[1]} ERREUR(S) !!!</a></span><br />",
-                                $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 .= "<span class='erreur'><a href='http://validator.w3.org/check?uri={$globals->baseurl}"
+                                ."/valid.html&amp;ss=1#result'>{$m[1]} ERREUR(S) !!!</a></span><br />";
+                        }
+                        break;
+                    }
                 }
-            } else {
-                $this->display('skin/'.Session::get('skin'));
             }
+
+            echo str_replace("@HOOK@", $ttime.$replc, $result);
+            exit;
         }
+
+        $this->display('skin/'.Session::get('skin'));
         exit;
     }
 
index 3fa0acd..35a1ed9 100644 (file)
@@ -19,7 +19,7 @@
  ***************************************************************************}
 
 {if #globals.debug#}
-{if $db_trace neq "\n\n"}
+{if $db_trace && $db_trace neq "\n\n"}
   <div id="db-trace">
     <h1>
       Trace de l'exĂ©cution de cette page sur mysql (hover me)