some cookie here : automatic html validation --> now a red link appears with the...
authorx2000habouzit <x2000habouzit>
Wed, 25 Aug 2004 08:59:17 +0000 (08:59 +0000)
committerx2000habouzit <x2000habouzit>
Wed, 25 Aug 2004 08:59:17 +0000 (08:59 +0000)
include/xorg.page.inc.php
scripts/xhtml/validate.pl [new file with mode: 0755]
templates/skin/common.devel.tpl

index 7e1ea18..e305ef6 100644 (file)
@@ -75,11 +75,23 @@ class XorgPage extends DiogenesCorePage {
             if($site_dev) {
                 $this->assign('db_trace', $globals->db->trace_format($this, 'database-debug.tpl'));
                 $this->assign('validate', urlencode($baseurl.'/valid.html'));
-                $result = $this->fetch('skin/'.$_SESSION['skin'], $id);
+
+               $result = $this->fetch('skin/'.$_SESSION['skin'], $id);
                 $fd = fopen($this->cache_dir."valid.html","w");
                 fwrite($fd, $result);
                 fclose($fd);
-                echo $result;
+               
+               exec($globals->spoolroot."/scripts/xhtml/validate.pl ".$this->cache_dir."valid.html", $val);
+               foreach($val as $h)
+                   if(preg_match("/^X-W3C-Validator-Errors: (\d+)$/", $h, $m)) {
+                       if($m[1]) {
+                           echo str_replace("@NB_ERR@",
+                               "<span class='erreur'><a href='http://validator.w3.org/check?uri=$baseurl/valid.html&amp;ss=1#result'>{$m[1]} ERREUR(S) !!!</a></span><br />", $result);
+                       } else {
+                           echo str_replace("@NB_ERR@", "", $result);
+                       }
+                       exit;
+                   }
             } else
                 parent::display('skin/'.$_SESSION['skin'], $id);
         }
diff --git a/scripts/xhtml/validate.pl b/scripts/xhtml/validate.pl
new file mode 100755 (executable)
index 0000000..cf1ba0a
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+
+use LWP::UserAgent;
+use HTTP::Request::Common 'POST';
+
+print LWP::UserAgent
+  ->new
+  ->request(
+            POST 'http://amaretto.inria.fr:8080/w3c-markup-validator/check',
+            Content_Type => 'form-data',
+            Content      => [
+                             output => 'xml',
+                             uploaded_file => [$ARGV[0]],
+                            ]
+           )->as_string;
+
index 8f39576..e393f8e 100644 (file)
@@ -1,10 +1,10 @@
-{* $Id: common.devel.tpl,v 1.2 2004-08-24 20:05:35 x2000habouzit Exp $ *}
+{* $Id: common.devel.tpl,v 1.3 2004-08-25 08:59:18 x2000habouzit Exp $ *}
 
 {if $validate}
   <div id="dev">
     <div class="title">Outils de dev</div>
     <div>
-      <a href="http://validator.w3.org/check?uri={$validate}">VALIDER XHTML 1.1</a><br />
+      @NB_ERR@
       <a href="http://jigsaw.w3.org/css-validator/validator?uri={$validate}">VALIDER CSS</a>
     </div>
     <div>