annotate index.php @ 35:4e9e9c54036e

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