b455b2d0492c235009b8baac604d03c060e0838a
fenris foo

fenris authored 8 years ago

1) <?php
2) 	include_once("source/logic/server/data.php");
3) 	include_once("source/logic/server/table.php");
bfadmin-master advanced

bfadmin-master authored 8 years ago

4) 	include_once("source/logic/server/misc.php");
bfadmin-master fancy table-stuff, woohoo!

bfadmin-master authored 8 years ago

5) 	include_once("source/logic/server/sql.php");
fenris foo

fenris authored 8 years ago

6)  ?>
bfadmin-master advanced

bfadmin-master authored 8 years ago

7) <section class="subsection" id="correlatives">
Fenris Wolf advanced

Fenris Wolf authored 8 years ago

8) 	<header>Correlatives</header>
bfadmin-master advanced

bfadmin-master authored 8 years ago

9) 	<div class="note_error">This section is only a proposal yet; not part of the draft.</div>
fenris foo

fenris authored 8 years ago

10) <?php
bfadmin-master fancy table-stuff, woohoo!

bfadmin-master authored 8 years ago

11) 	$mode = 2;
12) 	switch ($mode)
bfadmin-master advanced

bfadmin-master authored 8 years ago

13) 	{
bfadmin-master fancy table-stuff, woohoo!

bfadmin-master authored 8 years ago

14) 		case 0:
15) 		{
16) 			$table = new class_table
fenris foo

fenris authored 8 years ago

17) 			(
bfadmin-master fancy table-stuff, woohoo!

bfadmin-master authored 8 years ago

18) 				[
19) 					new class_column
20) 					(
21) 						"Domain",
22) 						function ($row) {return $row["domain"];}
23) 					),
24) 					new class_column
25) 					(
26) 						"Interrogative / Relative",
27) 						_foo("interrogative"),
28) 						_bar("word")
29) 					),
30) 					new class_column
31) 					(
32) 						"Demonstrative far",
33) 						_foo("demonstrative_far"),
34) 						_bar("word")
35) 					),
36) 					new class_column
37) 					(
38) 						"Demonstrative near",
39) 						_foo("demonstrative_near"),
40) 						_bar("word")
41) 					),
42) 					new class_column
43) 					(
44) 						"Universal",
45) 						_foo("universal"),
46) 						_bar("word")
47) 					),
48) 					new class_column
49) 					(
50) 						"Undefined",
51) 						_foo("undefined"),
52) 						_bar("word")
53) 					),
54) 					new class_column
55) 					(
56) 						"Negative",
57) 						_foo("negative"),
58) 						_bar("word")
59) 					),
60) 				],
61) 				read_json("source/data/correlatives.json")
62) 			);
63) 			$table->generate();
64) 			break;
65) 		}
66) 		case 1:
67) 		{
68) 			global $configuration;
69) 			$database = read_json("source/data/x.json");
70) 			$data = $database["words"];
71) 			// $data = sql_cross($database["words"], sql_rename($database["words"]));
72) 			$data = sql_select($data, function ($row) {return ($row["language"] == "fs");});
73) 			$table = new class_table
fenris foo

fenris authored 8 years ago

74) 			(
bfadmin-master fancy table-stuff, woohoo!

bfadmin-master authored 8 years ago

75) 				[
76) 					new class_column("Domain (id)", function ($row) {return $row["domain_id"];}),
77) 					new class_column("Type (id)", function ($row) {return $row["type_id"];}),
78) 					new class_column
79) 					(
80) 						"Folksprak",
81) 						function ($row) {return $row["words"];},
82) 						function ($value) {global $configuration; return _baz($value, "word", "fs");}
83) 					),
84) 					/*
85) 					new class_column
86) 					(
87) 						$configuration["languagemap"][$configuration["target"]],
88) 						function ($row) {global $configuration; return $row["words"][$configuration["target"]];},
89) 						function ($value) {global $configuration; return _baz($value, "word", $configuration["target"]);}
90) 					),
91) 					 */
92) 				],
93) 				$data
94) 			);
95) 			$table->generate();
96) 			break;
97) 		}
98) 		case 2:
99) 		{
100) 			global $configuration;
101) 			$database = read_json("source/data/x.json");
102) 			$data = $database["words"];
bfadmin-master minor changes

bfadmin-master authored 8 years ago

103) 			
104) 			// get domain names
105) 			{
106) 				$data = sql_cross($data, $database["domains"]);
107) 				$data = sql_rename($data, "name", "domain_name");
108) 				$data = sql_select($data, function ($row) {return ($row["id"] == $row["domain_id"]);});
109) 				$data = sql_delete($data, ["id"]);
110) 			}
111) 			
112) 			// get type names
113) 			{
114) 				$data = sql_cross($data, $database["types"]);
115) 				$data = sql_rename($data, "name", "type_name");
116) 				$data = sql_select($data, function ($row) {return ($row["id"] == $row["type_id"]);});
117) 				$data = sql_delete($data, ["id"]);
118) 			}
119) 			
120) 			// transform
121) 			{
122) 				$data = sql_select($data, function ($row) {global $configuration; return (($row["language"] == "fs") or ($row["language"] == $configuration["target"]));});
123) 				// $data = sql_group($data, "language");
124) 				$data = sql_add($data, ["type_name/words"], ["type_name/words" => function ($row) {return ["key" => $row["type_id"], "value" => [$row["language"] => $row["words"]]];}]);
125) 				$data = sql_project($data, ["domain_name", "type_name/words"]);
126) 				$data = sql_group
bfadmin-master fancy table-stuff, woohoo!

bfadmin-master authored 8 years ago

127) 				(
128) 					$data,
129) 					"domain_name",
130) 					[
131) 						"type_name/words" => function ($args)
132) 						{
133) 							$output = [];
bfadmin-master minor changes

bfadmin-master authored 8 years ago

134) 							foreach ($args as $arg)
135) 							{
136) 								if (! array_key_exists($arg["key"], $output)) $output[$arg["key"]] = [];
137) 								foreach ($arg["value"] as $key => $value)
bfadmin-master fancy table-stuff, woohoo!

bfadmin-master authored 8 years ago

138) 								{
bfadmin-master minor changes

bfadmin-master authored 8 years ago

139) 									$output[$arg["key"]][$key] = $value;
140) 								}
141) 							}
bfadmin-master fancy table-stuff, woohoo!

bfadmin-master authored 8 years ago

142) 							return $output;
143) 						},
144) 					]
bfadmin-master minor changes

bfadmin-master authored 8 years ago

145) 				);
146) 			}
147) 			
bfadmin-master fancy table-stuff, woohoo!

bfadmin-master authored 8 years ago

148) 			$table = new class_table
fenris foo

fenris authored 8 years ago

149) 			(
bfadmin-master fancy table-stuff, woohoo!

bfadmin-master authored 8 years ago

150) 				array_merge
151) 				(
152) 					[
153) 						new class_column("Domain", function ($row) {return $row["domain_name"];}),
bfadmin-master minor changes

bfadmin-master authored 8 years ago

154) 						// new class_column("type_name/words", function ($row) {return $row["type_name/words"];}, function ($value) {print_r($value);}),
bfadmin-master fancy table-stuff, woohoo!

bfadmin-master authored 8 years ago

155) 					],
156) 					array_map
157) 					(
158) 						function ($type)
159) 						{
160) 							return (
161) 								new class_column
162) 								(
163) 									("Type: " . $type["name"]),
bfadmin-master minor changes

bfadmin-master authored 8 years ago

164) 									function ($row) use (&$type)
165) 									{
166) 										global $configuration;
167) 										return ["original" => $row["type_name/words"][$type["id"]]["fs"], "translated" => $row["type_name/words"][$type["id"]][$configuration["target"]]];
168) 									},
169) 									_bar("word")
bfadmin-master fancy table-stuff, woohoo!

bfadmin-master authored 8 years ago

170) 								)
171) 							);
172) 						},
bfadmin-master minor changes

bfadmin-master authored 8 years ago

173) 						array_filter($database["types"], function ($type) {return ($type["id"] != "relative");})
bfadmin-master fancy table-stuff, woohoo!

bfadmin-master authored 8 years ago

174) 					)
175) 				),
176) 				$data
177) 			);
178) 			$table->generate();
179) 			break;
180) 		}
181) 		default:
182) 		{
183) 			break;
184) 		}
185) 	}
fenris foo

fenris authored 8 years ago

186)  ?>
187) <div class="note_information">Some of these words are very unlikely to ever get used (e.g. <span class="word lang_fs">ing slag</span>). Nevertheless they exist and are listed for completeness.</div>