<?php
include "../general.inc";

function show_table ($title, $head, $list) {
   echo "<h2>$title</h2>\n";
   if (sizeof($list)) {
      echo "<table border=\"1\">\n";
      if (sizeof($head)) {
         echo "<tr>";
         while (list($key,$value) = each($head)) {
            echo "<th>$value</th>";
         }
         echo "</tr>\n";
      }
      ksort($list);
      while (list($key,$value) = each($list)) {
         if (sizeof($value) > 1) {
            echo "<tr><td>$key</td>";
            while (list($lkey,$lvalue) = each($value)) {
               echo "<td>$lvalue</td>";
            }
            echo "</tr>\n";
         } else {
            echo "<tr><td>$key</td><td>$value</td></tr>\n";
         }
      }
      echo "</table>\n";
   }
}

function show_filelist ($title, $text, $list) {
   global $PHP_SELF;
   echo "<h2>$title</h2>\n";
   if (sizeof($list)) {
      echo "$text\n";
      echo "<ul>\n";
      ksort($list);
      while (list($key,$value) = each($list)) {
         echo "<li> <a href=\"$PHP_SELF?type=file&file=$value\">$key</a>\n";
      }
      echo "</ul>\n";
   }
}

function show_info ($type) {
}

function show_file ($file) {
   if (is_readable("./".$file)) {
      include "./".$file;
      doc_header("Jabba","$file ($version)");
      echo "<center>$desc</center>\n";
      show_table("Configuration",array("Name", "Description"), $config_entry);
      show_table("Events generating",array("Name", "Arguments", "Description"), $events_generate);
      show_table("Event arguments",array("Argument", "Description"), $event_args);
      show_table("Events using",array("Event", "Description"), $events_use);
      show_table("Methods",array("Method", "Description"), $methods);
      show_table("Files",array("File", "Description"), $files);
      show_FILElist("Object dependency", "This file depends on following objects", $object_depend);
   } else {
      doc_header("Jabba","JABBA - Just another boring bot architecture");
      echo "<h3>File '$file' not found.</h3>\n";
   }
}

if (strtoupper($type) == "FILE") {
   show_file ($file);
} else {
   show_info($type);
}
doc_footer();
?>
