Mercurial > hg > batmud > misc
view materials/index.php @ 35:d4fef95c2f3e misc
Misc. improvements.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 18 Apr 2009 06:25:13 +0000 |
parents | 652a6864d3ce |
children | 6d43ff1c592a |
line wrap: on
line source
<? $pageTitle = "BatMUD Material Browser"; $pageIndex = "index.php"; require "materials.inc.php"; $sortDirs = array("asc", "desc"); if (isset($_GET["s"])) { $sortColumn = intval($_GET["s"]); } else $sortColumn = 0; if (isset($_GET["d"])) { $s = substr(strtolower($_GET["d"]), 0, 1); if ($s == "d") $sortDirection = 1; else $sortDirection = 0; } else $sortDirection = 0; if (isset($_GET["h"]) && is_array($_GET["h"])) $filterTable = array_flip($_GET["h"]); else $filterTable = array(); if (isset($_GET["o"])) { $showOnly = intval($_GET["o"]); } else $showOnly = -1; function sortMatFunc($a, $b) { global $sortDirection, $sortColumn; $index = $sortColumn - 1; if ($a[$index] == $b[$index]) return 0; $res = $a[$index] < $b[$index]; if ($sortDirection) return ($res ? 1 : -1); else return ($res ? -1 : 1); } if ($sortColumn <= 0 || $sortColumn >= 18) { $sortColumn = 0; if ($sortDirection) krsort($matTable, SORT_STRING); else ksort($matTable, SORT_STRING); } else uasort($matTable, "sortMatFunc"); function printTC($a, $column) { global $sortColumn; echo "<".$a; if ($column == $sortColumn) echo " class=\"hilite\""; echo ">"; } require "../header.inc.php"; ?> <h1><? echo $pageTitle; ?></h1> <form action="<? echo $pageIndex; ?>" method="get"> <table class="optionsTable"> <tr> <th>Hide columns</th> <th>Show only type</th> <td rowspan="3" style="background: black; border: 1px solid white; color: red; padding: 8px;"> There may be bugs. If you notice any inaccuracies, contact <b>Ggr</b>@Bat. <ul> <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 is possible.</li> <li>Columns can be disabled from the filtering list (shift or ctrl with mouse click to select several)</li> </ul> There's also a very preliminary alpha version of <a href="alloy.php">alloy browser</a> available. </td> </tr> <tr> <td> <select multiple="multiple" size="5" name="h[]"> <? reset($transNameTable); next($transNameTable); while (list($key, $value) = each($transNameTable)) { echo "<option"; if (isset($filterTable[$key])) echo " selected=\"selected\""; echo " value=\"$key\">".htmlentities($value)."</option>\n"; } ?> </select> </td> <td> <select name="o"> <? $typeTable = $transTable[14]; $typeTable[-1] = "EVERYTHING"; ksort($typeTable); reset($typeTable); $showOnlySet = FALSE; while (list($key, $value) = each($typeTable)) { echo " <option value=\"$key\""; if ($showOnly == $key) { echo " selected=\"selected\""; $showOnlySet = TRUE; } echo ">".htmlentities($value)."</option>\n"; } if ($showOnly < 0) $showOnlySet = FALSE; ?> </select> </td> </tr> <tr> <td colspan="2" class="icenter"><input type="submit" value=" Filter " class="isubmit" /></td> <td></td> </tr> </table> <? /* if ($sortColumn >= 0) { echo "<input type=\"hidden\" name=\"s\" value=\"".$sortColumn."\" />\n"; echo "<input type=\"hidden\" name=\"d\" value=\"".$sortDirs[$sortDirection]."\" />\n"; } */ ?> </form> <table class="matTable"> <tr> <? reset($transNameTable); while (list($key, $value) = each($transNameTable)) { if (!isset($filterTable[$key])) { echo " "; printTC("th", $key); echo "<a href=\"?s=".$key."&d="; if ($key == $sortColumn) echo $sortDirs[!$sortDirection]; else echo $sortDirs[$sortDirection]; if ($showOnlySet) echo "&o=".$showOnly; reset($filterTable); while (list($fkey, $fvalue) = each($filterTable)) { echo "&h%5B%5D=".$fkey; } echo "\">".htmlentities($value)."</a></th>\n"; } } echo " </tr>\n"; reset($matTable); while (list($key, $value) = each($matTable)) { if ($showOnlySet) $doShow = ($value[14] == $showOnly); else $doShow = TRUE; if ($doShow) { $col = 0; echo " <tr>"; printTC("td", $col++); echo "<a href=\"alloy.php?m=".urlencode($key)."\">".htmlentities($key)."</a></td>"; while (list($kkey, $kvalue) = each($value)) { if (!isset($filterTable[$kkey+1])) { printTC("td", $col); if (isset($transTable[$kkey][$kvalue])) { echo htmlentities($transTable[$kkey][$kvalue]); } else { echo $kvalue; } echo "</td>"; } $col++; } echo "</tr>\n"; } } echo "</table>\n"; require "../footer.inc.php"; ?>