Mercurial > hg > batmud > misc
annotate materials/index.php @ 321:971118747193 misc
Cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 30 Dec 2015 23:16:48 +0200 |
parents | c7f903b2b924 |
children | b4f34ae41008 |
rev | line source |
---|---|
0 | 1 <? |
156 | 2 $pageTitle = "Pupunen BatMUD Material Browser"; |
23
652a6864d3ce
Added alloy.php, updated index.php.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
3 $pageIndex = "index.php"; |
302 | 4 require "mgeneric.inc.php"; |
23
652a6864d3ce
Added alloy.php, updated index.php.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
5 require "materials.inc.php"; |
320
c7f903b2b924
Add some empty lines for cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
6 |
c7f903b2b924
Add some empty lines for cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
7 |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
8 function stParseList($values, $pair) |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
9 { |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
10 $res = array(); |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
11 if ($values === FALSE) |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
12 return $res; |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
13 |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
14 // It's an array already |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
15 if (is_array($values)) |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
16 { |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
17 if ($pair) |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
18 { |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
19 // The data should already be in our desired format .. maybe |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
20 foreach ($values as $key => $val) |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
21 $res[trim($key)] = trim($val); |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
22 } |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
23 else |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
24 { |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
25 // Place values in hash |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
26 foreach ($values as $key) |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
27 $res[trim($key)] = 1; |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
28 } |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
29 return $res; |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
30 } |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
31 |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
32 // Assume string, parse it |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
33 if (($list = preg_split("/\s*,\s*/", trim($values), -1, PREG_SPLIT_NO_EMPTY)) === FALSE) |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
34 return $res; |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
35 |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
36 if ($pair) |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
37 { |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
38 // Parse key-value pairs separated by : |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
39 foreach ($list as $str) |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
40 { |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
41 if (($tmp = preg_split("/\s*:\s*/", trim($str), -1, PREG_SPLIT_NO_EMPTY)) !== FALSE) |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
42 $res[$tmp[0]] = $tmp[1]; |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
43 } |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
44 } |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
45 else |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
46 { |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
47 // Should be just values, so place them in hash |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
48 foreach ($list as $str) |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
49 $res[$str] = 1; |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
50 } |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
51 return $res; |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
52 } |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
53 |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
54 |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
55 function stMakeList($name, $url, $array, $pair) |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
56 { |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
57 if (count($array) == 0) |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
58 return ""; |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
59 |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
60 $tmp = array(); |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
61 if ($pair) |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
62 { |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
63 foreach ($array as $key => $val) |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
64 $tmp[] = $key.":".$val; |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
65 } |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
66 else |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
67 { |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
68 foreach ($array as $key => $val) |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
69 $tmp[] = $key; |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
70 } |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
71 |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
72 if ($url) |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
73 return "&".$name."=".join(",", $tmp); |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
74 else |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
75 return stGetFormHiddenInput($name, join(",", $tmp))."\n"; |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
76 } |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
77 |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
78 |
246 | 79 function stGetTC($a, $column) |
207 | 80 { |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
81 global $setSortColumn; |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
82 return "<".$a.($column == $setSortColumn ? " class=\"hilite\"" : "").">"; |
207 | 83 } |
84 | |
85 | |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
86 function stGetURLStr($cfilters, $col, $dir, $domfilters, $mfilters) |
207 | 87 { |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
88 global $sortDirs, $setHideColumns; |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
89 $str = "s=".$col."&d=".$sortDirs[$dir]."&mf=".$domfilters; |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
90 $str .= stMakeList("f", TRUE, $cfilters, TRUE); |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
91 $str .= stMakeList("h", TRUE, $setHideColumns, FALSE); |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
92 $str .= stMakeList("m", TRUE, $mfilters, FALSE); |
207 | 93 return $str; |
94 } | |
146 | 95 |
96 | |
246 | 97 function stSortMatFunc($a, $b) |
0 | 98 { |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
99 global $setSortDirection, $setSortColumn; |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
100 $index = $setSortColumn - 1; |
0 | 101 |
102 if ($a[$index] == $b[$index]) | |
103 return 0; | |
104 | |
105 $res = $a[$index] < $b[$index]; | |
106 | |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
107 if ($setSortDirection) |
207 | 108 return $res ? 1 : -1; |
0 | 109 else |
207 | 110 return $res ? -1 : 1; |
0 | 111 } |
112 | |
140 | 113 |
293 | 114 // |
115 // Actual code starts | |
116 // | |
117 $sortDirs = array("asc", "desc"); | |
118 | |
119 // Horrible kludge | |
120 $agent = $_SERVER["HTTP_USER_AGENT"]; | |
121 if (stristr($agent, "GoogleBot") !== FALSE) | |
122 { | |
123 header("HTTP/1.1 403 Forbidden"); | |
124 exit; | |
125 } | |
126 | |
127 // Sorting column | |
128 $setSortColumn = intval(stGetRequestItem("s", 0, TRUE)); | |
129 $setSortDirection = substr(strtolower(stGetRequestItem("d", "", TRUE)), 0, 1) == "d"; | |
130 | |
131 // Material column hiding | |
132 $setHideColumns = stParseList(stGetRequestItem("h", FALSE, TRUE), FALSE); | |
133 | |
134 // Column filters | |
135 $setAttrFilters = stParseList(stGetRequestItem("f", FALSE, TRUE), TRUE); | |
136 | |
137 // Material filters | |
138 $setMatFilters = stParseList(stGetRequestItem("m", FALSE, TRUE), FALSE); | |
139 $setEnableMatFilters = intval(stGetRequestItem("mf", 0, TRUE)); | |
140 | |
141 | |
142 // Sort materials by selected column | |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
143 if ($setSortColumn <= 0 || $setSortColumn >= 18) |
246 | 144 { |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
145 $setSortColumn = 0; |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
146 if ($setSortDirection) |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
147 krsort($matDataTable, SORT_STRING); |
0 | 148 else |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
149 ksort($matDataTable, SORT_STRING); |
276
2e2ea2bfd843
Many improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
275
diff
changeset
|
150 } |
2e2ea2bfd843
Many improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
275
diff
changeset
|
151 else |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
152 uasort($matDataTable, "stSortMatFunc"); |
0 | 153 |
154 | |
293 | 155 // Print page header |
279
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
156 cmPrintPageHeader($pageTitle, " |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
157 <meta name=\"robots\" content=\"nofollow\" /> |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
158 <style type=\"text/css\"> |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
159 td a.matToggle { |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
160 display: inline-block; |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
161 background: black; |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
162 width: 1em; |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
163 font-size: 1.2em; |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
164 padding: 0.1em; |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
165 text-align: center; |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
166 margin-right: 0.3em; |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
167 } |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
168 |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
169 td a.matToggle:hover { |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
170 text-decoration: none; |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
171 background: white; |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
172 } |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
173 |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
174 td a.matToggle.active { |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
175 color: green !important; |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
176 } |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
177 |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
178 td a.matToggle.inactive { |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
179 color: red !important; |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
180 } |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
181 </style> |
269ecedff518
Various improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
276
diff
changeset
|
182 "); |
0 | 183 ?> |
184 <h1><? echo $pageTitle; ?></h1> | |
23
652a6864d3ce
Added alloy.php, updated index.php.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
185 <form action="<? echo $pageIndex; ?>" method="get"> |
276
2e2ea2bfd843
Many improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
275
diff
changeset
|
186 <? |
2e2ea2bfd843
Many improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
275
diff
changeset
|
187 echo |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
188 stGetFormHiddenInput("s", $setSortColumn)."\n". |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
189 stGetFormHiddenInput("d", $sortDirs[$setSortDirection])."\n". |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
190 stGetFormHiddenInput("mf", $setEnableMatFilters)."\n". |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
191 stMakeList("f", FALSE, $setAttrFilters, TRUE). |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
192 stMakeList("m", FALSE, $setMatFilters, FALSE); |
276
2e2ea2bfd843
Many improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
275
diff
changeset
|
193 ?> |
0 | 194 <table class="optionsTable"> |
195 <tr> | |
196 <th>Hide columns</th> | |
197 <th>Show only type</th> | |
42 | 198 <td rowspan="3" class="infobox"> |
246 | 199 [<a href="<? echo $pageIndex; ?>">Reset/Clear</a>] [<a href="info.php">Alloy browser</a>] |
149
762e30af53f6
New features, cleanups, stylesheets.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
200 - <b>CHANGE COLOURS/STYLE: <? |
246 | 201 for ($i = 1; $i <= 4; $i++) |
207 | 202 echo "<a href=\"?css=".$i."\">(".$i.")</a> " |
149
762e30af53f6
New features, cleanups, stylesheets.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
203 ?></b> |
126 | 204 <br /> |
0 | 205 <ul> |
275 | 206 <li>Material data updated as of November 2011.</li> |
119 | 207 <li>This informations free to use in any way you wish. It would be nice to be credited, however.</li> |
208 <li>There may be bugs. If you notice any inaccuracies, contact <b>Ggr</b> @ Bat.</li> | |
209 <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> | |
0 | 210 <li>You can sort by any column by clicking on the column name. Clicking again will change |
211 sorting direction (ascending/descending).</li> | |
147 | 212 <li>Filtering to show only certain type of materials or materials with certain feature(s) is possible, |
207 | 213 for example <a href="index.php?s=0&d=asc&f[1]=5&f[2]=6">show only 'incr. sturdy' |
154 | 214 AND 'highly magical'</a> materials. Click on desired feature (table cell) to add a filter.</li> |
0 | 215 <li>Columns can be disabled from the filtering list (shift or ctrl with mouse click to select several)</li> |
216 </ul> | |
217 </td> | |
218 </tr> | |
219 <tr> | |
220 <td> | |
221 <select multiple="multiple" size="5" name="h[]"> | |
222 <? | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
223 reset($matTransNames); |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
224 next($matTransNames); |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
225 while (list($key, $value) = each($matTransNames)) |
246 | 226 { |
143 | 227 echo " <option". |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
228 (isset($setHideColumns[$key]) ? " selected=\"selected\"" : ""). |
246 | 229 " value=\"$key\">".chentities($value)."</option>\n"; |
0 | 230 } |
231 ?> | |
232 </select> | |
233 </td> | |
234 <td> | |
147 | 235 <select name="f[14]"> |
0 | 236 <? |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
237 $typeFilter = isset($setAttrFilters[14]) ? $setAttrFilters[14] : -1; |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
238 if ($typeFilter == -1) unset($setAttrFilters[14]); |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
239 $typeTable = $matTransTable[14]; |
0 | 240 $typeTable[-1] = "EVERYTHING"; |
241 ksort($typeTable); | |
246 | 242 foreach ($typeTable as $key => $value) |
243 { | |
148 | 244 echo " <option value=\"$key\"". |
245 ($typeFilter == $key ? " selected=\"selected\"" : ""). | |
246 | 246 ">".chentities($value)."</option>\n"; |
0 | 247 } |
248 ?> | |
249 </select> | |
250 </td> | |
251 </tr> | |
252 <tr> | |
253 <td colspan="2" class="icenter"><input type="submit" value=" Filter " class="isubmit" /></td> | |
254 </tr> | |
255 </table> | |
256 </form> | |
149
762e30af53f6
New features, cleanups, stylesheets.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
257 <? |
293 | 258 // |
259 // List active filters | |
260 // | |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
261 if (count($setAttrFilters) > 0) |
246 | 262 { |
263 $filters = array(); | |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
264 foreach ($setAttrFilters as $fkey => $fval) |
321 | 265 { |
266 if ($fkey >= 0) | |
267 $filters[] = "<b>".strtolower($matTransNames[$fkey + 1])."</b>=".strtolower($matTransTable[$fkey][$fval]); | |
268 } | |
276
2e2ea2bfd843
Many improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
275
diff
changeset
|
269 |
246 | 270 echo "<p>Filtering: ".implode(", ", $filters)."</p>\n"; |
149
762e30af53f6
New features, cleanups, stylesheets.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
271 } |
276
2e2ea2bfd843
Many improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
275
diff
changeset
|
272 |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
273 if (count($setMatFilters) > 0) |
276
2e2ea2bfd843
Many improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
275
diff
changeset
|
274 { |
2e2ea2bfd843
Many improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
275
diff
changeset
|
275 echo |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
276 "<p>Material filter: ".implode(", ", array_keys($setMatFilters))." ". |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
277 "<a href=\"?".stGetURLStr($setAttrFilters, $setSortColumn, $setSortDirection, !$setEnableMatFilters, $setMatFilters). |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
278 "\">[".($setEnableMatFilters ? "Deactivate" : "Activate")."]</a></p>\n"; |
276
2e2ea2bfd843
Many improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
275
diff
changeset
|
279 } |
293 | 280 |
281 | |
282 // | |
283 // Material table headers | |
284 // | |
285 echo | |
286 "<div class=\"matTable\">\n". | |
287 "<table class=\"matTable\">\n". | |
288 " <tr>\n"; | |
289 | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
290 foreach ($matTransNames as $key => $value) |
246 | 291 { |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
292 if ($key == 0 || !isset($setHideColumns[$key])) |
246 | 293 { |
284
3555578e7d2c
Disable sorting links on fields that do not support it.
Matti Hamalainen <ccr@tnsp.org>
parents:
279
diff
changeset
|
294 echo " ".stGetTC("th", $key); |
3555578e7d2c
Disable sorting links on fields that do not support it.
Matti Hamalainen <ccr@tnsp.org>
parents:
279
diff
changeset
|
295 if ($key < 18) |
3555578e7d2c
Disable sorting links on fields that do not support it.
Matti Hamalainen <ccr@tnsp.org>
parents:
279
diff
changeset
|
296 { |
3555578e7d2c
Disable sorting links on fields that do not support it.
Matti Hamalainen <ccr@tnsp.org>
parents:
279
diff
changeset
|
297 echo |
246 | 298 "<a href=\"?". |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
299 stGetURLStr($setAttrFilters, $key, |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
300 ($key == $setSortColumn) ? !$setSortDirection : $setSortDirection, |
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
301 $setEnableMatFilters, $setMatFilters). |
284
3555578e7d2c
Disable sorting links on fields that do not support it.
Matti Hamalainen <ccr@tnsp.org>
parents:
279
diff
changeset
|
302 "\">".chentities($value)."</a>"; |
3555578e7d2c
Disable sorting links on fields that do not support it.
Matti Hamalainen <ccr@tnsp.org>
parents:
279
diff
changeset
|
303 } |
3555578e7d2c
Disable sorting links on fields that do not support it.
Matti Hamalainen <ccr@tnsp.org>
parents:
279
diff
changeset
|
304 else |
3555578e7d2c
Disable sorting links on fields that do not support it.
Matti Hamalainen <ccr@tnsp.org>
parents:
279
diff
changeset
|
305 echo chentities($value); |
3555578e7d2c
Disable sorting links on fields that do not support it.
Matti Hamalainen <ccr@tnsp.org>
parents:
279
diff
changeset
|
306 |
3555578e7d2c
Disable sorting links on fields that do not support it.
Matti Hamalainen <ccr@tnsp.org>
parents:
279
diff
changeset
|
307 echo "</th>\n"; |
0 | 308 } |
309 } | |
310 echo " </tr>\n"; | |
311 | |
293 | 312 |
313 // | |
314 // Material data rows | |
315 // | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
316 foreach ($matDataTable as $mname => $mdata) |
246 | 317 { |
293 | 318 // |
319 // Check what filters apply here | |
320 // | |
147 | 321 $doShow = TRUE; |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
322 foreach ($setAttrFilters as $fkey => $fval) |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
323 if ($fval >= 0 && $mdata[$fkey] != $fval) |
246 | 324 { |
325 $doShow = FALSE; | |
326 break; | |
147 | 327 } |
276
2e2ea2bfd843
Many improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
275
diff
changeset
|
328 |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
329 if ($setEnableMatFilters && !isset($setMatFilters[$mname])) |
276
2e2ea2bfd843
Many improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
275
diff
changeset
|
330 $doShow = FALSE; |
2e2ea2bfd843
Many improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
275
diff
changeset
|
331 |
246 | 332 if ($doShow) |
333 { | |
293 | 334 // Create temporary filter list for material filter link |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
335 $tmpFilters = $setMatFilters; |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
336 if (isset($tmpFilters[$mname])) |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
337 unset($tmpFilters[$mname]); |
276
2e2ea2bfd843
Many improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
275
diff
changeset
|
338 else |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
339 $tmpFilters[$mname] = 1; |
276
2e2ea2bfd843
Many improvements to the material browser.
Matti Hamalainen <ccr@tnsp.org>
parents:
275
diff
changeset
|
340 |
293 | 341 // First column is material name |
342 $col = 0; | |
275 | 343 echo |
344 " <tr>".stGetTC("td", $col++). | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
345 "<a class=\"matToggle ".(isset($setMatFilters[$mname]) ? "active" : "inactive"). |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
346 "\" href=\"?".stGetURLStr($setAttrFilters, $setSortColumn, $setSortDirection, $setEnableMatFilters, $tmpFilters). |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
347 "\">".(isset($setMatFilters[$mname]) ? "-" : "+")."</a>". |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
348 "<a href=\"/mat/".urlencode($mname)."\">".chentities($mname)."</a>". |
275 | 349 "</td>"; |
293 | 350 |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
351 foreach ($mdata as $kkey => $kvalue) |
246 | 352 { |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
353 if (!isset($setHideColumns[$kkey + 1])) |
246 | 354 { |
355 echo stGetTC("td", $col); | |
356 if (is_array($kvalue)) | |
357 { | |
119 | 358 // Arrays need special handling, and is bit messy |
44 | 359 reset($kvalue); |
119 | 360 |
44 | 361 if (list($nam, $lode) = each($kvalue)) |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
362 echo chentities($matTransTable[$kkey][$lode]); |
119 | 363 |
44 | 364 while (list($nam, $lode) = each($kvalue)) |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
365 echo ", ".chentities($matTransTable[$kkey][$lode]); |
246 | 366 } |
367 else | |
368 { | |
293 | 369 // Create temporary filter list for attribute filter link |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
370 $tmpFilters = $setAttrFilters; |
149
762e30af53f6
New features, cleanups, stylesheets.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
371 if (isset($tmpFilters[$kkey])) |
762e30af53f6
New features, cleanups, stylesheets.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
372 unset($tmpFilters[$kkey]); |
762e30af53f6
New features, cleanups, stylesheets.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
373 else |
762e30af53f6
New features, cleanups, stylesheets.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
374 $tmpFilters[$kkey] = $kvalue; |
762e30af53f6
New features, cleanups, stylesheets.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
375 |
207 | 376 echo "<a href=\"?". |
290
8ffcb08361bc
Various cleanups and improve parameter parsing.
Matti Hamalainen <ccr@tnsp.org>
parents:
284
diff
changeset
|
377 stGetURLStr($tmpFilters, $setSortColumn, $setSortDirection, $setEnableMatFilters, $setMatFilters). |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
378 "\">".chentities($matTransTable[$kkey][$kvalue])."</a>"; |
0 | 379 } |
380 echo "</td>"; | |
381 } | |
382 $col++; | |
383 } | |
384 echo "</tr>\n"; | |
385 } | |
386 } | |
246 | 387 echo |
388 "</table>\n". | |
389 "</div>\n"; | |
140 | 390 |
246 | 391 cmPrintPageFooter(); |
0 | 392 ?> |