Extensions/miniville
Implement a miniville XML status parser
- Requires libexpat to be compiled into PHP
Usage: <miniville>[villename]</miniville>
Optionally add a 'style=""' parameter to the tag, so it can style the table.
<?php
$wgExtensionFunctions[] = "wfMiniville";
function wfMiniville() {
  global $wgParser;
  $wgParser->setHook( "miniville", "render_miniville_xml" );
}
function render_miniville_xml ( $ville_name , $argv, $parser ) {
  $style="";
  if(isset($argv["style"])) {
    $style="style=\"".$argv["style"]."\"";
  }
  $c = file_get_contents("http://$ville_name.miniville.fr/xml",FALSE,NULL,0,1024);
  if(strstr($c,"<html>")!=FALSE) {
    return("<p>$ville_name not found</p>\n");
  }
  $p = xml_parser_create();
  xml_parse_into_struct($p, $c, $vals, $index);
  xml_parser_free($p);
  $htmltxt = "<table $style class=\"diff\">\n";
  for ($i=0; $i < count($vals); $i+=1) {
    if($vals[$i]["level"]==2) {
      $htmltxt .= "<tr><td>".ucfirst(strtolower($vals[$i]["tag"]))."</td><td>".$vals[$i]["value"]."</td></tr>\n";
    }
  }
  $htmltxt .= "</table>\n";
  return $htmltxt;
}
?>

