diff --git a/ecrire/inc/sax.php b/ecrire/inc/sax.php index 23a6911785ccb757a0d3c7c00f5a02417930035d..5e65f34f3a47950f07d72422ee08425e84361f0f 100644 --- a/ecrire/inc/sax.php +++ b/ecrire/inc/sax.php @@ -171,9 +171,9 @@ function xml_parsestring($phraseur, $data) list($nom, $ligne, $col) = $idref; if (!isset($phraseur_xml->ids[$nom])) $phraseur_xml->err[]= " <p><b>$nom</b>" - . _L(" ID inconnu ligne ") + . _L(" ID inconnu ") . $ligne - . _L(" colonne ") + . " " . $col; } if ($phraseur_xml->err) @@ -235,9 +235,9 @@ function inc_sax_dist($page, $apply=false) { function coordonnees_erreur($xml_parser) { return - _L(" ligne ") . + ' ' . xml_get_current_line_number($xml_parser) . - _L(" colonne ") . + ' ' . xml_get_current_column_number($xml_parser); } diff --git a/ecrire/inc/validateur.php b/ecrire/inc/validateur.php index fe7836ba004dd84b2e0cc343781a3e8d5523a8d6..aee7e1b9640a81c3c37c4b3026c99dcb46013730 100644 --- a/ecrire/inc/validateur.php +++ b/ecrire/inc/validateur.php @@ -139,9 +139,12 @@ function validerAttribut($parser, $name, $val, $bal) { global $phraseur_xml; - $a = @$phraseur_xml->attributs[$bal]; // vide ou absent, pareil. + // Si la balise est inconnue, eviter d'insister + if (!isset($phraseur_xml->attributs[$bal])) + return ; + + $a = $phraseur_xml->attributs[$bal]; if (!isset($a[$name])) - $phraseur_xml->err[]= " <b>$name</b>" . _L(' attribut inconnu de ') . "<b>$bal</b>" @@ -170,9 +173,9 @@ function validerAttribut($parser, $name, $val, $bal) . coordonnees_erreur($parser); list($l,$c) = $phraseur_xml->ids[$val]; $phraseur_xml->err[]= " <p><b>$val</b>" - . _L(" vu auparavant ligne ") + . _L(" vu auparavant ") . $l - . _L(" colonne ") + . " " . $c; } else $phraseur_xml->ids[$val] = array(xml_get_current_line_number($parser), xml_get_current_column_number($parser)); } elseif ($type == 'IDREF') { diff --git a/ecrire/public/debug.php b/ecrire/public/debug.php index bc778a3d621d2e161a5ef9f59c757f4b2f8be333..1148e4c3f20e6332197abd9cb4a720a291d6eea2 100644 --- a/ecrire/public/debug.php +++ b/ecrire/public/debug.php @@ -314,7 +314,7 @@ function ancre_texte($texte, $fautifs=array()) $ancre = md5($texte); $n = strlen(count($tableau)); - $format = "<a href='#T$ancre'><span id='L%d' style='text-align: right;color: black;'>%0" + $format = "<a href='#T%s'><span id='L%d' style='text-align: right;color: black;'>%0" . strval($n) . "d </span></a>\n"; @@ -324,23 +324,26 @@ function ancre_texte($texte, $fautifs=array()) $flignes = array(); + $loc = array(0,0); foreach ($fautifs as $lc) - if (is_array($lc)) - $flignes[$lc[0]] = $lc[1]; - else $flignes[$lc] = 0; + if (is_array($lc)) { + $l = array_shift($lc); + $flignes[$l] = $lc; + } else $flignes[$lc] = $loc; foreach ($tableau as $ligne) { if (isset($flignes[$i])) { $ligne = str_replace(' ',' ', $ligne); + $indexmesg = $flignes[$i][1]; // tentative de pointer sur la colonne fautive; // marche pas car highlight_string rajoute des entites. A revoir. - // $m = $flignes[$i]; + // $m = $flignes[$i][0]; // $ligne = substr($ligne, 0, $m-1) . // sprintf($formaterr, substr($ligne,$m)); $ligne = sprintf($formaterr, $ligne); - } + } else $indexmesg = $ancre; $res .= "<br />\n" - . sprintf((($i%10) ? $format :$format10), $i, $i) + . sprintf((($i%10) ? $format :$format10), $indexmesg, $i, $i) . $ligne; $i++; } @@ -531,18 +534,44 @@ function emboite_texte($texte, $fonc='',$self='') $eregs)) return array(ancre_texte($texte, array('', '')), true); if (!isset($GLOBALS['debug_objets'])) { - preg_match_all(",([^0-9]* )([0-9]+)(.*?(\d*)<br />),", + preg_match_all(",(.*?)(\d+)(\D+(\d+)<br />),", $GLOBALS['xhtml_error'], $regs, PREG_SET_ORDER); - $err = ''; + $err = '<tr><th>#</th><th>Occ.</th><th>Msg</th><th>L</th><th>Col</th></tr>'; $fautifs = array(); + $i = 0; + $encore = array(); + foreach($regs as $r) { + if (isset($encore[$r[1]])) + $encore[$r[1]]++; + else $encore[$r[1]] = 1; + } + $encore2 = array(); + $colors = array('#e0e0f0', '#f8f8ff'); foreach($regs as $r) { - $err .= $r[1] . - "<a href='#L" . $r[2] . "'>$r[2]</a>$r[3]"; - $fautifs[]= array($r[2], $r[4]); + $i++; + list(,$msg, $ligne, $fin, $col) = $r; + if (isset($encore2[$msg])) + $ref = $encore2[$msg]++; + else $encore2[$msg] = $ref = 1; + $err .= "<tr style='background-color: " + . $colors[$i%2] + . "'><td style='text-align: right'>" + . $i + . "</td><td style='text-align: right'>" + . "$ref/$encore[$msg]</td><td>$msg</td>" + . "<td style='text-align: right'><a href='#L" + . $ligne + . "' id='T$i'>" + . $ligne + . "</a></td><td style='text-align: right'>" + . $fin + . "</td></tr>\n"; + $fautifs[]= array($ligne, $col, $i); } - return array(ancre_texte($texte, $fautifs), $err); + return array(ancre_texte($texte, $fautifs), + "<table>$err</table>"); } else { $fermant = $eregs[2]; $ouvrant = $eregs[4];