diff www/loc.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 7948d14d3893
children b58f261314f8
line wrap: on
line diff
--- a/www/loc.php	Mon Mar 11 15:11:16 2024 +0200
+++ b/www/loc.php	Tue Mar 12 15:47:58 2024 +0200
@@ -111,6 +111,10 @@
       $wizTable = mpReadWizInfoFiles();
       apcu_store("wizTable", $wizTable, 3600);
     }
+
+    // Correct aliases
+    if (isset($wizTable[$authorName]))
+      $authorName = $wizTable[$authorName]["name"];
   }
   else
   {
@@ -231,20 +235,30 @@
 //
 if (isset($authorName))
 {
-  if (isset($wizTable[$authorName]) && count($wizTable[$authorName]) > 1)
+  if (isset($wizTable[$authorName]))
   {
+    $entry = &$wizTable[$authorName];
+
     // Profile picture
-    //$imageURL = $wizImageURL.(qcheck($wizTable[$authorName], "imageURL", $imageName) ? $imageName : "unknown.png");
+    //$imageURL = $wizImageURL.(qcheck($entry, "imageURL", $imageName) ? $imageName : "unknown.png");
     $imageURL = $wizImageURL."unknown.png";
 
     echo
       "<div class=\"wizInfoBox\">\n".
-      "   <div class=\"wizImage\"><img src=\"".$imageURL."\" alt=\"".$authorName."\" /></div>\n".
+      "   <div class=\"wizImage\"><img src=\"".$imageURL."\" alt=\"".$entry["name"]."\" /></div>\n".
       "   <div class=\"wizInfo\">\n".
-      "    <h2>".$authorName."</h2>\n";
+      "    <h2>".$entry["name"];
+
+    if (count($entry["names"]) > 0)
+    {
+      echo " (aka ".implode(" aka ", $entry["names"]).")";
+    }
+
+    echo
+      "</h2>\n";
 
     // Description block
-    if (qcheck($wizTable[$authorName], "desc", $str))
+    if (qcheck($entry, "desc", $str))
     {
       // Handle special tags
       $str = preg_replace("/\~([A-Z][a-z]+)\~/i", "<a href=\"?a=\${1}\">\${1}</a>", $str);
@@ -258,7 +272,7 @@
     // Links, etc.
     echo "    [<a href=\"".mpFingerURL($authorName)."\">Finger</a>]\n";
 
-    if (qcheck($wizTable[$authorName], "homeURL", $s))
+    if (qcheck($entry, "homeURL", $s))
     {
       if ($s == "bat")
         $s = "https://wiz.bat.org/~".strtolower($authorName)."/";
@@ -266,7 +280,7 @@
       echo "    [<a href=\"".$s."\">Homepage</a>]\n";
     }
 
-    if (qcheck($wizTable[$authorName], "countries", $s))
+    if (qcheck($entry, "countries", $s))
     {
       echo "    [".implode(" | ", array_map(
         function ($item)