view www/latest.php @ 2819:7f90630781a7

Cleanup.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 14 Apr 2024 20:19:46 +0300
parents 164aa519640d
children
line wrap: on
line source

<?php
require "config.inc.php";
require "world.inc.php";
require "common.inc.php";

$showAll = isset($_REQUEST["all"]);
$locTable = mpParseLocFiles(!$showAll);

mpPrintPageHeader($pageTitle." - Latest added locations");
//echo "<div><b>DEVELOPMENT VERSION</b></div>";
?>
<h1>Latest added locations</h1>

<div class="attnbox">
The dates presented are supposed to be the date when area was added in the game.
<b>However, this information can be inaccurate for various reasons</b>; 
<a href="faq.php#6">please read our FAQ item concerning the accuracy of
the information presented here</a>. You may also be interested in the
<a href="changelog.txt">PupuMaps project changelog</a>, which lists
the changes made to the data.
</div>
<hr />
<?php
$locGetNameLink = function($sdata)
{
  return "<a href=\"loc.php?a=".
    chentities($sdata["name"])."\">".
    chentities($sdata["name"])."</a>";
};


$locGetNameStr = function($sdata)
{
  return $sdata["name"];
};


// Compare two location records by addition date timestamp and primary name
function locCompare($va, $vb)
{
  if ($va["added"] > $vb["added"])
    return -1;
  else
  if ($va["added"] == $vb["added"])
    return strcmp($va["name"], $vb["name"]);
  else
    return 1;
}


echo "Currently showing ";
if ($showAll)
  echo "all locations [<a href=\"?\">Show only notable locations</a> (not including player cities)]";
else
  echo "only notable locations [<a href=\"?all\">Show all latest added locations</a> (including player cities)]";
echo "<hr />\n";


// Sort locations by timestamp ..
foreach ($locTable as $location)
{
  // If "nodate" is set, show locations with NO known addition timestamp
  if (isset($_REQUEST["nodate"]))
  {
    if ($location["added"] < 0)
      $sortedLocs[] = $location;
  }
  else
  {
    if ($location["added"] > 0)
      $sortedLocs[] = $location;
  }
}

usort($sortedLocs, "locCompare");

// Print the list
$totalLoc = 0;
echo
  "<table class=\"locTable\">\n".
  " <tr>\n".
  "  <th class=\"locdate\">Date</th>\n".
  "  <th class=\"locname\">Location name</th>\n".
  "  <th class=\"loccont\">Continent</th>\n".
  ($showAll ? "  <th>Type</th>\n" : "").
  "  <th class=\"locauthor\">Author(s)</th>\n".
  "  <th class=\"locinfo\">Information</th>\n".
  " </tr>\n";

foreach ($sortedLocs as $ik => $iv)
{
  $totalLoc++;

  echo
    " <tr>\n".
    "  <td>".(($iv["added"] <= 0) ? "?" : mpLocFormatTime($iv))."</td>\n".
    "  <td class=\"".$iv["continent"]."\">".mpGetMapLink($iv, TRUE, TRUE, FALSE)."</td>\n".
    "  <td>".$continentList[$iv["continent"]][CTI_NAME]."</td>\n".
    ($showAll ? "  <td>".mpGetLocationTypeStr($iv["flags"])."</td>\n" : "").
    "  <td>".implode(", ", array_map(
      (($iv["flags"] & LOCF_M_MASK) == LOCF_M_PCITY) ? $locGetNameStr : $locGetNameLink,
      $iv["authors"]))."</td>\n".
    "  <td>".(isset($iv["freeform"]) ? chentities($iv["freeform"]) : "")."</td>\n".
    " </tr>\n";
}
echo
  "</table>\n".
  "<p><b>".$totalLoc."</b> locations.</p>\n";

mpPrintPageFooter();
?>