Mercurial > hg > batmud > maputils
diff www/loc.php @ 1979:3c03ca974e6a
Fix issue with "area" selection in location display not actually showing all
areas, also refactor few things. This breaks some backward compatibility as
the "filter" option can no longer be used by user for filtering via a direct
regexp. But I doubt anyone used that feature anyway.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 19 Nov 2017 21:41:10 +0200 |
parents | 3075415f052e |
children | fbd15f694f81 |
line wrap: on
line diff
--- a/www/loc.php Sun Nov 19 21:13:04 2017 +0200 +++ b/www/loc.php Sun Nov 19 21:41:10 2017 +0200 @@ -58,26 +58,29 @@ // // Initialization // +// Special backwards compatibility case for pcities if (isset($_GET["c"])) { - $filter = "C"; + $filterID = "C"; $applyFilter = TRUE; } else -if (($filter = mpGetRequestItem("f", "", TRUE)) != "") +// Try to get the filter ID +if (($filterID = mpGetRequestItem("f", "", TRUE)) != "") { - if (!preg_match("/^[\^A-Za-z!]+\$/", $filter)) + if (!array_key_exists($filterID, $locationTypes)) { - mpError("Invalid filter rule '".chentities($filter)."'"); - $filter = "C"; + mpError("Invalid location filter rule '".chentities($filterID)."'."); + $filterID = ""; $applyFilter = FALSE; } else $applyFilter = TRUE; } else +// No filter ID specified, default to showing everything { - $filter = "CF"; + $filterID = ""; $applyFilter = FALSE; } @@ -115,7 +118,7 @@ if (empty($locTable)) { $locTable = []; - mpParseLocFile($setName, $locTable, $applyFilter, $filter); + mpParseLocFile($setName, $locTable, $applyFilter, $applyFilter ? $locationTypes[$filterID][LTI_REGEXP] : ""); apc_store("loc_".$setName, $locTable, 3600); } } @@ -130,7 +133,7 @@ $locTable = apc_fetch("loc_locTable"); if (empty($locTable)) { - $locTable = mpReadLocationFiles($applyFilter, $filter); + $locTable = mpReadLocationFiles($applyFilter, $applyFilter ? $locationTypes[$filterID][LTI_REGEXP] : ""); apc_store("loc_locTable", $locTable, 3600); } } @@ -167,13 +170,7 @@ // Start of the page // if ($applyFilter) -{ - if (array_key_exists($filter, $locationTypes)) - - $mtitle = $locationTypes[$filter][2]; - else - $mtitle = "Filter '".$filter."'"; -} + $mtitle = $locationTypes[$filterID][LTI_PAGE_DESC]; else $mtitle = "Locations"; @@ -198,25 +195,25 @@ echo " <input type=\"hidden\" name=\"n\" value=\"".chentities($setName)."\" />\n"; echo " <select class=\"control dropdown\" name=\"f\" onChange=\"this.form.submit();\">\n"; -foreach ($locationTypes as $id => $type) +foreach ($locationTypes as $lid => $ldata) { echo - " <option value=\"".$id."\"". - (($applyFilter && $filter == $id) ? " selected=\"selected\"" : ""). - ">".$type[3]."</option>\n"; + " <option value=\"".$lid."\"". + (($applyFilter && $filterID == $lid) ? " selected=\"selected\"" : ""). + ">".$ldata[LTI_MENU_TITLE]."</option>\n"; } echo " </select>\n". " <noscript><input type=\"submit\" value=\" Update \" class=\"control submit\" /></noscript>\n"; -printTitleLink($applyFilter, $filter, $showCoders, "All continents", "", "all"); +printTitleLink($applyFilter, $filterID, $showCoders, "All continents", "", "all"); foreach ($continentList as $continent => $data) { if ($data[4]) - printTitleLink($applyFilter, $filter, $showCoders, $data[0], $continent, $continent); + printTitleLink($applyFilter, $filterID, $showCoders, $data[0], $continent, $continent); } -printTitleLink($applyFilter, $filter, $showCoders, "Special", "special", "special"); +printTitleLink($applyFilter, $filterID, $showCoders, "Special", "special", "special"); echo "</div>\n". @@ -401,7 +398,9 @@ case NAME_EXPANDER: $qs = "title=\"Implemented new content, expansion(s)\" class=\"wizexpander\""; break; default: $qs = ""; } - if ($filter != "C" || !$applyFilter) + + // Pcity entries do not get "author" links as they are actually SS+ + if ($filterID != "C" || !$applyFilter) $fs[] = "<a ".$qs." href=\"?a=".$name["name"]."\">".$name["name"]."</a>"; else $fs[] = $name["name"];