diff www/info.php @ 2763:78ad0e51b7b5

Improve wizards.txt parser, add functionality for specifying alternative / additional names as some wizards have used more than one. Also other improvements in wizard data handling.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 12 Mar 2024 15:47:58 +0200
parents 164aa519640d
children
line wrap: on
line diff
--- a/www/info.php	Mon Mar 11 15:11:16 2024 +0200
+++ b/www/info.php	Tue Mar 12 15:47:58 2024 +0200
@@ -53,71 +53,65 @@
 }
 
 
-/* Print table of wizards
- */
+// Get area counts
 foreach ($locTable as $location)
 {
   foreach ($location["authors"] as $wiz)
   {
     $name = $wiz["name"];
+
+    // Many wizards do not have an entry in wizard info table
     if (!isset($wizTable[$name]))
-      $wizTable[$name] = array("name" => $name, "areas" => 0);
+    {
+      $wizTable[$name] = [
+        "name" => $name,
+        "names" => [],
+        "areas" => 0,
+      ];
+    }
+
     $wizTable[$name]["areas"]++;
   }
 }
 
-if (count($wizTable) > 0)
-{
-  /* Make alphabetically sorted table of wizards
-   */
-  foreach ($wizTable as $alpha => $data)
-    $alphaTable[$alpha[0]][] = $data;
+// Make alphabetically sorted table of wizards
+foreach ($wizTable as $name => $data)
+  $alphaTable[$name[0]][$name] = $data;
 
-  ksort($alphaTable, SORT_STRING);
+ksort($alphaTable, SORT_STRING);
 
-
-  /* Print wizards alphabetically per first character of name
-   */
-  $totalWiz = 0;
-  $maxRow = 6;
-  foreach ($alphaTable as $alpha => $data)
-  if (count($data) > 0)
-  {
-    usort($data, "wizardSort");
+// Print wizards alphabetically per first character of name
+foreach ($alphaTable as $alpha => $data)
+if (count($data) > 0)
+{
+  usort($data, "wizardSort");
 
-    $letter = strtoupper($alpha);
-    echo "<h3><a id=\"ch".$letter."\"></a>".$letter."</h3>\n";
-    echo "<div class=\"locTable\">\n";
-    $n = 0;
-
-    foreach ($data as $wizard)
-    {
-      $totalWiz++;
+  $letter = strtoupper($alpha);
+  echo "<h3><a id=\"ch".$letter."\"></a>".$letter."</h3>\n";
+  echo "<div class=\"locTable\">\n";
 
-      echo
-        "  <div class=\"locWizard ".((count($wizard) > 2 || isset($wizard["desc"])) ? "locWizHasDesc" : "locWizHasNoDesc")."\">".
-        "<a href=\"loc.php?a=".$wizard["name"]."\">".$wizard["name"]."</a>";
+  foreach ($data as $name => $wizard)
+  {
+    echo
+      "  <div class=\"locWizard ".
+      (isset($wizard["desc"]) ? "locWizHasDesc" : "locWizHasNoDesc")."\">".
+      "<a href=\"loc.php?a=".$wizard["name"]."\">".$wizard["name"]."</a>";
 
-      if ($wizard["areas"] > 0)
-        echo " <span class=\"locWizNumAreas\">(".$wizard["areas"].")</span>";
-
-      echo "</div>\n";
-    }
+    if ($wizard["areas"] > 0)
+      echo " <span class=\"locWizNumAreas\">(".$wizard["areas"].")</span>";
 
     echo "</div>\n";
   }
 
-  echo "<p><b>".$totalWiz."</b> wizards.</p>\n".
-    "</div>\n"; // end of contents div
-
-  // Print out the alpha link index
-  mpPrintExtraBoxAlphaList("ch", $alphaTable);
+  echo "</div>\n";
 }
-else
-{
-  echo "<p><b>No wizards known!</b></p>\n".
-    "</div>\n"; // end of contents div
-}
+
+echo
+  "<p><b>".count($wizTable)."</b> wizards.</p>\n".
+  "</div>\n"; // end of contents div
+
+// Print out the alpha link index
+mpPrintExtraBoxAlphaList("ch", $alphaTable);
 
 mpPrintPageFooter(FALSE);
 ?>
\ No newline at end of file