<?php
	include_once("source/logic/server/data.php");
	include_once("source/logic/server/table.php");
	include_once("source/logic/server/misc.php");
	include_once("source/logic/server/sql.php");
 ?>
<section class="subsection" id="correlatives">
	<header>Correlatives</header>
	<?php proposal(); ?>
<?php
	$data_correlatives = read_json("source/data/correlatives.json");
	$data = $data_correlatives["words"];
	{
		{
			$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");
		}
		{
			$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");
		}
	}
	
	$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
	);
	$table = $table->snap
	(
		[
			"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" =>
			[
				$table->columns_get()[3],
			],
			"data_aggregator" => function ($values)
			{
				return $values;
			},
			"data_formatter" => function ($value)
			{
				return (
					_bar("word")
					(
						[
							"original" => $value[0]["words"],
							"translated" => $value[1]["words"],
						]
					)
				);
				return json_encode($value);
			},
		]
	);
	$table->generate();
 ?>
<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>
</section>