comparison 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
comparison
equal deleted inserted replaced
2762:4caa26c12052 2763:78ad0e51b7b5
109 if (empty($wizTable)) 109 if (empty($wizTable))
110 { 110 {
111 $wizTable = mpReadWizInfoFiles(); 111 $wizTable = mpReadWizInfoFiles();
112 apcu_store("wizTable", $wizTable, 3600); 112 apcu_store("wizTable", $wizTable, 3600);
113 } 113 }
114
115 // Correct aliases
116 if (isset($wizTable[$authorName]))
117 $authorName = $wizTable[$authorName]["name"];
114 } 118 }
115 else 119 else
116 { 120 {
117 $authorName = "???"; 121 $authorName = "???";
118 mpError("Invalid wizard name."); 122 mpError("Invalid wizard name.");
229 // 233 //
230 // Wizard/author/creator information box 234 // Wizard/author/creator information box
231 // 235 //
232 if (isset($authorName)) 236 if (isset($authorName))
233 { 237 {
234 if (isset($wizTable[$authorName]) && count($wizTable[$authorName]) > 1) 238 if (isset($wizTable[$authorName]))
235 { 239 {
240 $entry = &$wizTable[$authorName];
241
236 // Profile picture 242 // Profile picture
237 //$imageURL = $wizImageURL.(qcheck($wizTable[$authorName], "imageURL", $imageName) ? $imageName : "unknown.png"); 243 //$imageURL = $wizImageURL.(qcheck($entry, "imageURL", $imageName) ? $imageName : "unknown.png");
238 $imageURL = $wizImageURL."unknown.png"; 244 $imageURL = $wizImageURL."unknown.png";
239 245
240 echo 246 echo
241 "<div class=\"wizInfoBox\">\n". 247 "<div class=\"wizInfoBox\">\n".
242 " <div class=\"wizImage\"><img src=\"".$imageURL."\" alt=\"".$authorName."\" /></div>\n". 248 " <div class=\"wizImage\"><img src=\"".$imageURL."\" alt=\"".$entry["name"]."\" /></div>\n".
243 " <div class=\"wizInfo\">\n". 249 " <div class=\"wizInfo\">\n".
244 " <h2>".$authorName."</h2>\n"; 250 " <h2>".$entry["name"];
251
252 if (count($entry["names"]) > 0)
253 {
254 echo " (aka ".implode(" aka ", $entry["names"]).")";
255 }
256
257 echo
258 "</h2>\n";
245 259
246 // Description block 260 // Description block
247 if (qcheck($wizTable[$authorName], "desc", $str)) 261 if (qcheck($entry, "desc", $str))
248 { 262 {
249 // Handle special tags 263 // Handle special tags
250 $str = preg_replace("/\~([A-Z][a-z]+)\~/i", "<a href=\"?a=\${1}\">\${1}</a>", $str); 264 $str = preg_replace("/\~([A-Z][a-z]+)\~/i", "<a href=\"?a=\${1}\">\${1}</a>", $str);
251 265
252 foreach ($specTags as $tag => $rep) 266 foreach ($specTags as $tag => $rep)
256 } 270 }
257 271
258 // Links, etc. 272 // Links, etc.
259 echo " [<a href=\"".mpFingerURL($authorName)."\">Finger</a>]\n"; 273 echo " [<a href=\"".mpFingerURL($authorName)."\">Finger</a>]\n";
260 274
261 if (qcheck($wizTable[$authorName], "homeURL", $s)) 275 if (qcheck($entry, "homeURL", $s))
262 { 276 {
263 if ($s == "bat") 277 if ($s == "bat")
264 $s = "https://wiz.bat.org/~".strtolower($authorName)."/"; 278 $s = "https://wiz.bat.org/~".strtolower($authorName)."/";
265 279
266 echo " [<a href=\"".$s."\">Homepage</a>]\n"; 280 echo " [<a href=\"".$s."\">Homepage</a>]\n";
267 } 281 }
268 282
269 if (qcheck($wizTable[$authorName], "countries", $s)) 283 if (qcheck($entry, "countries", $s))
270 { 284 {
271 echo " [".implode(" | ", array_map( 285 echo " [".implode(" | ", array_map(
272 function ($item) 286 function ($item)
273 { 287 {
274 return strtoupper($item); 288 return strtoupper($item);