Mercurial > hg > batmud > maputils
changeset 1392:ae493885b68e
More cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 23 Dec 2013 17:34:06 +0200 |
parents | 7fcea2fce0be |
children | 68429429c265 |
files | www/loc.php |
diffstat | 1 files changed, 112 insertions(+), 80 deletions(-) [+] |
line wrap: on
line diff
--- a/www/loc.php Mon Dec 23 17:08:10 2013 +0200 +++ b/www/loc.php Mon Dec 23 17:34:06 2013 +0200 @@ -38,8 +38,25 @@ } -/* Initialization - */ +function qcheck($arr, $key, &$result) +{ + if (isset($key) && isset($arr[$key])) + { + $result = $arr[$key]; + return TRUE; + } + else + { + unset($result); + return FALSE; + } +} + + + +// +// Initialization +// if (isset($_GET["c"])) { $filter = "C"; @@ -89,7 +106,7 @@ if (isset($_GET["n"])) { $locTable = array(); - $setName = strtolower(basename($_GET["n"])); + $setName = strtolower(trim(basename($_GET["n"]))); if (file_exists($setName.".loc")) { $locTable = apc_fetch("loc_".$setName); @@ -105,14 +122,18 @@ stError("No such continent ID!"); unset($setName); } -} else { +} +else +{ $locTable = apc_fetch("loc_locTable"); - if (empty($locTable)) { + if (empty($locTable)) + { $locTable = stReadLocationFiles($applyFilter, $filter); apc_store("loc_locTable", $locTable, 3600); } } + /* Start of the page */ printPageHeader($pageTitle." - Locations", @@ -130,7 +151,7 @@ if (array_key_exists($filter, $locationTypes)) echo $locationTypes[$filter][2]; else - echo "Filter '$filter'"; + echo "Filter '".$filter."'"; } else echo "Locations"; @@ -142,63 +163,47 @@ echo $continentList[$setName][0]. ($continentList[$setName][3] ? " in " : " continent in "); } -echo "BatMUD"; -if (isset($coderName)) - echo " by ".chentities($coderName); -echo "</h1>\n"; + +echo + "BatMUD".(isset($coderName) ? " by ".chentities($coderName) : ""). + "</h1>\n"; -if ($errorSet) -{ - echo "<div style=\"color: red;\">Errors: "; - echo "</div>\n"; -} +echo + "<div class=\"selbar\">\n". + " <form action=\"".$_SERVER["PHP_SELF"]."\" method=\"get\">\n"; -?> -<div class="selbar"> - <form action="<? echo $_SERVER["PHP_SELF"]; ?>" method="get"> -<? if (isset($setName)) echo "<input type=\"hidden\" name=\"n\" value=\"".chentities($setName)."\" />\n"; -?> - <select class="dropdown" name="f"> -<? -foreach ($locationTypes as $id => $type) { - echo " <option value=\"".$id."\""; - if ($applyFilter && $filter == $id) - echo " selected=\"selected\""; - echo ">".$type[3]."</option>\n"; + +echo "<select class=\"dropdown\" name=\"f\">\n"; +foreach ($locationTypes as $id => $type) +{ + echo + " <option value=\"".$id."\"". + (($applyFilter && $filter == $id) ? " selected=\"selected\"" : ""). + ">".$type[3]."</option>\n"; } -?> - </select> - <input type="submit" value=" Update " class="submit" /> -<? +echo + "</select>\n". + "<input type=\"submit\" value=\" Update \" class=\"submit\" />\n"; + + printTitleLink($applyFilter, $filter, $showCoders, "All continents", "", "all"); -foreach ($continentList as $continent => $data) { +foreach ($continentList as $continent => $data) +{ if ($data[4]) printTitleLink($applyFilter, $filter, $showCoders, $data[0], $continent, $continent); } printTitleLink($applyFilter, $filter, $showCoders, "Special", "special", "special"); -?> - </form> -</div> + +echo + "</form>\n". + "</div>\n"; -<? -function qcheck($arr, $key, &$result) -{ - if (isset($key) && isset($arr[$key])) - { - $result = $arr[$key]; - return TRUE; - } - else - { - unset($result); - return FALSE; - } -} -/* Wizard/coder/creator information box - */ +// +// Wizard/coder/creator information box +// if (isset($coderName)) { if (isset($wizTable[$coderName]) && count($wizTable[$coderName]) > 1) @@ -249,12 +254,30 @@ } -/* Print list of locations - */ -if (count($locTable) > 0) +// +// Print out errors +// +if ($errorSet) { - /* Make alphabetically sorted table of locations - */ + echo + "<div style=\"color: red;\">\n". + " <ul>\n"; + + foreach ($errorMsgs as $msg) + echo " <li>".$msg."</li>\n"; + + echo + " </ul>\n". + "</div>\n"; +} + + +// +// Print list of locations +// +if (!$errorSet && count($locTable) > 0) +{ + // Make alphabetically sorted table of locations $alphaTable = array(); foreach ($locTable as $id => $data) if (isset($data["name"])) @@ -282,8 +305,9 @@ ksort($alphaTable, SORT_STRING); - /* Print locations per first character - */ + // + // Print locations per first character + // $locationTips = array(); $totalLoc = 0; $maxRow = 6; @@ -319,18 +343,22 @@ $desc = isset($iv["freeform"]) ? chentities($iv["freeform"]) : ""; // Add URL information, chopped, if any - if (isset($iv["url"])) { + if (isset($iv["url"])) + { $urlEnt = $iv["url"]; $urlBegin = "<a href=\"".chentities($urlEnt)."\" target=\"_blank\">"; $urlEnd = "</a>"; if (strlen($iv["url"]) > 40) $urlEnt = substr($urlEnt, 0, 40)."..."; $desc .= "<br /><br /><b>".chentities($urlEnt)."</b>"; - } else { + } + else + { $urlBegin = $urlEnd = ""; } - echo " ".$urlBegin."<img class=\"noborder\" src=\"question.png\" onmouseover=\"stt(".$totalLoc. + echo + " ".$urlBegin."<img class=\"noborder\" src=\"question.png\" onmouseover=\"stt(".$totalLoc. ");\" onmouseout=\"htt();\" alt=\"(?)\" />".$urlEnd."\n"; $locationTips[$totalLoc] = array( @@ -340,28 +368,32 @@ } // Alternative names - $nnames = count($iv["names"]); - if ($nnames > 1) { - echo "<br />"; - for ($nname = 1; $nname < $nnames; $nname++) { - if ($iv["names"][$nname]["flags"] & NAME_ORIG) - echo "<b>"; - echo chentities($iv["names"][$nname]["name"]); - if ($iv["names"][$nname]["flags"] & NAME_ORIG) - echo "</b>"; - if ($nname < $nnames - 1) echo " | "; + if (($nnames = count($iv["names"])) > 1) + { + $fs = array(); + for ($nname = 1; $nname < $nnames; $nname++) + { + $norig = $iv["names"][$nname]["flags"] & NAME_ORIG; + $fs[] = + ($norig ? "<b>" : ""). + chentities($iv["names"][$nname]["name"]). + ($norig ? "</b>" : ""); } + echo "<br />".implode(" | ", $fs); } // Coder / society names - if (count($iv["coders"]) > 0 && $showCoders) { + if (count($iv["coders"]) > 0 && $showCoders) + { $isSG = preg_match("/[SG]/", $iv["flags"]); - if ((!isset($coderName) && !$isSG) || isset($coderName)) { - $fs = ""; - foreach ($iv["coders"] as $name) { - if ($fs != "") $fs .= ", "; + if ((!isset($coderName) && !$isSG) || isset($coderName)) + { + $fs = array(); + foreach ($iv["coders"] as $name) + { // Tags/flags of this coder in relation to the area - switch ($name["flags"]) { + switch ($name["flags"]) + { case NAME_ORIG: $qs = "title=\"Original creator\" class=\"wizorig\""; break; case NAME_RECODER: $qs = "title=\"Converter, recoder\" class=\"wizrecoder\""; break; case NAME_MAINTAINER: $qs = "title=\"Maintainer\" class=\"wizmaintainer\""; break; @@ -369,11 +401,11 @@ default: $qs = ""; } if ($filter != "C" || !$applyFilter) - $fs .= "<a ".$qs." href=\"".$_SERVER["PHP_SELF"]."?a=".$name["name"]."\">".$name["name"]."</a>"; + $fs[] = "<a ".$qs." href=\"".$_SERVER["PHP_SELF"]."?a=".$name["name"]."\">".$name["name"]."</a>"; else - $fs .= $name["name"]; + $fs[] = $name["name"]; } - echo "<br />[".$fs."]"; + echo "<br />[".implode(", ", $fs)."]"; } }