Mercurial > hg > batmud > materials
changeset 17:598fbbb4812e
Code cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 12 Jan 2016 16:49:42 +0200 |
parents | 1a7f8f8cd5ff |
children | 283bba41e4ef |
files | index.php |
diffstat | 1 files changed, 67 insertions(+), 57 deletions(-) [+] |
line wrap: on
line diff
--- a/index.php Tue Jan 05 07:57:33 2016 +0200 +++ b/index.php Tue Jan 12 16:49:42 2016 +0200 @@ -9,10 +9,26 @@ $pageTitle = "Pupunen BatMUD Material Browser"; $pageIndex = "index.php"; +$infoNotes = +[ + "All material data updated as of November 2011 with some updates in 2014 and 2015.", + "This information is free to use in any way you wish. It would be nice to be credited, however.", + "There may be bugs. If you notice any inaccuracies, contact <b>Ggr</b> @ Bat.", + "<b>Raw material data is also available in <a href=\"materials.csv\">CSV format</a>, <a href=\"materials_short.txt\">short tabular format</a> and <a href=\"materials_long.txt\">long format</a></b>.", + "You can sort by any column by clicking on the column name. Clicking again will change + sorting direction (ascending/descending).", + "Filtering to show only certain type of materials or materials with certain feature(s) is possible, + for example <a href=\"index.php?s=0&d=asc&f[1]=5&f[2]=6\">show only 'incr. sturdy' + AND 'highly magical'</a> materials. Click on desired feature (table cell) to add a filter.", + "Columns can be disabled from the filtering list (shift or ctrl with mouse click to select several)", + "The code for these pages and Perl + shellscript based backend utilities is available in + <a href=\"http://pupunen.net/hg/materials/\">a Mercurial repository</a>.", +]; + function stParseList($values, $pair) { - $res = array(); + $res = []; if ($values === FALSE) return $res; @@ -118,7 +134,7 @@ // // Actual code starts // -$sortDirs = array("asc", "desc"); +$sortDirs = [ "asc", "desc" ]; // Horrible kludge $agent = $_SERVER["HTTP_USER_AGENT"]; @@ -184,48 +200,39 @@ } </style> "); -?> -<h1><? echo $pageTitle; ?></h1> -<form action="<? echo $pageIndex; ?>" method="get"> -<? + echo + "<h1>".$pageTitle."</h1>\n". + "<form action=\"".$pageIndex."\" method=\"get\">\n". stGetFormHiddenInput("s", $setSortColumn)."\n". stGetFormHiddenInput("d", $sortDirs[$setSortDirection])."\n". stGetFormHiddenInput("mf", $setEnableMatFilters)."\n". stMakeList("f", FALSE, $setAttrFilters, TRUE). - stMakeList("m", FALSE, $setMatFilters, FALSE); -?> -<table class="optionsTable"> - <tr> - <th>Hide columns</th> - <th>Show only type</th> - <td rowspan="3" class="infobox"> - [<a href="<? echo $pageIndex; ?>">Reset/Clear</a>] [<a href="info.php">Alloy browser</a>] - - <b>CHANGE COLOURS/STYLE: <? - for ($i = 1; $i <= 4; $i++) - echo "<a href=\"?css=".$i."\">(".$i.")</a> " - ?></b> - <br /> - <ul> - <li>All material data updated as of November 2011 with some updates in 2014 and 2015.</li> - <li>This information is free to use in any way you wish. It would be nice to be credited, however.</li> - <li>There may be bugs. If you notice any inaccuracies, contact <b>Ggr</b> @ Bat.</li> - <li><b>Raw material data is also available in <a href="materials.csv">CSV format</a>, <a href="materials_short.txt">short tabular format</a> and <a href="materials_long.txt">long format</a></b>.</li> - <li>You can sort by any column by clicking on the column name. Clicking again will change - sorting direction (ascending/descending).</li> - <li>Filtering to show only certain type of materials or materials with certain feature(s) is possible, - for example <a href="index.php?s=0&d=asc&f[1]=5&f[2]=6">show only 'incr. sturdy' - AND 'highly magical'</a> materials. Click on desired feature (table cell) to add a filter.</li> - <li>Columns can be disabled from the filtering list (shift or ctrl with mouse click to select several)</li> - <li>The code for these pages and Perl + shellscript based backend utilities is available in - <a href="http://pupunen.net/hg/materials/">a Mercurial repository</a>.</li> - </ul> - </td> - </tr> - <tr> - <td> - <select multiple="multiple" size="5" name="h[]"> -<? + stMakeList("m", FALSE, $setMatFilters, FALSE). + "<table class=\"optionsTable\">\n". + " <tr>\n". + " <th>Hide columns</th>\n". + " <th>Show only type</th>\n". + " <td rowspan=\"3\" class=\"infobox\">\n". + " [<a href=\"".$pageIndex."\">Reset/Clear</a>] ". + "[<a href=\"info.php\">Alloy browser</a>]\n". + " - <b>CHANGE COLOURS/STYLE: "; + +for ($i = 1; $i <= 4; $i++) + echo "<a href=\"?css=".$i."\">(".$i.")</a> "; + +echo + "</b>\n". + " <br />\n". + " <ul>\n". + implode("\n", array_map(function($msg){ return " <li>".$msg."</li>"; }, $infoNotes)). + " </ul>\n". + " </td>\n". + " </tr>\n". + " <tr>\n". + " <td>\n". + " <select multiple=\"multiple\" size=\"5\" name=\"h[]\">\n"; + reset($matTransNames); next($matTransNames); while (list($key, $value) = each($matTransNames)) @@ -234,12 +241,13 @@ (isset($setHideColumns[$key]) ? " selected=\"selected\"" : ""). " value=\"$key\">".chentities($value)."</option>\n"; } -?> - </select> - </td> - <td> - <select name="f[14]"> -<? + +echo + " </select>\n". + " </td>\n". + " <td>\n". + " <select name=\"f[14]\">\n"; + $typeFilter = isset($setAttrFilters[14]) ? $setAttrFilters[14] : -1; if ($typeFilter == -1) unset($setAttrFilters[14]); $typeTable = $matTransTable[14]; @@ -247,26 +255,28 @@ ksort($typeTable); foreach ($typeTable as $key => $value) { - echo " <option value=\"$key\"". + echo + " <option value=\"$key\"". ($typeFilter == $key ? " selected=\"selected\"" : ""). ">".chentities($value)."</option>\n"; } -?> - </select> - </td> - </tr> - <tr> - <td colspan="2" class="icenter"><input type="submit" value=" Filter " class="isubmit" /></td> - </tr> -</table> -</form> -<? + +echo + " </select>\n". + " </td>\n". + " </tr>\n". + " <tr>\n". + " <td colspan=\"2\" class=\"icenter\"><input type=\"submit\" value=\" Filter \" class=\"isubmit\" /></td>\n". + " </tr>\n". + "</table>\n". + "</form>\n"; + // // List active filters // if (count($setAttrFilters) > 0) { - $filters = array(); + $filters = []; foreach ($setAttrFilters as $fkey => $fval) { if ($fkey >= 0)