source/content/correlatives.html.php
18080c63
 <?php
 	include_once("source/logic/server/data.php");
 	include_once("source/logic/server/table.php");
dcda8f59
 	include_once("source/logic/server/misc.php");
8e9c8f74
 	include_once("source/logic/server/sql.php");
18080c63
  ?>
579dbe00
 <section class="subsection" id="correlatives">
9b21fc2c
 	<header>Correlatives</header>
000b5f04
 	<?php proposal(); ?>
18080c63
 <?php
459c0868
 	$data_correlatives = read_json("source/data/correlatives.json");
 	$data = $data_correlatives["words"];
dcda8f59
 	{
8e9c8f74
 		{
459c0868
 			$data = sql_cross($data, $data_correlatives["domains"]);
 			$data = sql_select($data, function ($row) {return ($row["domain_id"] == $row["id"]);});
 			$data = sql_delete($data, ["domain_id", "id"]);
 			$data = sql_rename($data, "name", "domain_name");
8e9c8f74
 		}
 		{
459c0868
 			$data = sql_cross($data, $data_correlatives["types"]);
 			$data = sql_select($data, function ($row) {return ($row["type_id"] == $row["id"]);});
 			$data = sql_delete($data, ["type_id", "id"]);
 			$data = sql_rename($data, "name", "type_name");
8e9c8f74
 		}
459c0868
 	}
 	
 	$table = new class_table
 	(
 		[
 			new class_column("Language", "language_id"),
 			new class_column("Domain", "domain_name"),
 			new class_column("Type", "type_name"),
 			new class_column("Words", "words", function ($x) {return json_encode($x);}),
 		],
 		$data
 	);
8794e319
 	$table_ = $table->snap
459c0868
 	(
 		[
 			"label_vertical" => function ($column) {return "";},
 			"columns_vertical" =>
 			[
 				$table->columns_get()[1],
 			],
 			"label_horizontal" => function ($column, $value) {return $value;},
 			"columns_horizontal" =>
 			[
 				$table->columns_get()[2],
 			],
 			"columns_data" =>
 			[
8794e319
 				$table->columns_get()[0],
459c0868
 				$table->columns_get()[3],
 			],
 			"data_aggregator" => function ($values)
b455b2d0
 			{
459c0868
 				return $values;
 			},
8794e319
 			"data_formatter" => function_chain
 			(
 				[
 					object_from_array("language_id"),
 					object_map(object_attribute("words")),
 					format_correlation("type_word"),
 				]
 			),
459c0868
 		]
 	);
8794e319
 	$table_->generate();
18080c63
  ?>
5da1fdb3
 	<div class="note note_information">
 		<span class="note_content">
8794e319
 			<p>Some of these words are very unlikely to ever get used (e.g. <?php echo(mark("ni slag", ["type_word", "lang_fs"])); ?>). Nevertheless they exist and are listed for completeness.</p>
5da1fdb3
 		</span>
 	</div>
9b21fc2c
 </section>