source/content/adpositions.html.php
dcda8f59
 <?php
 	include_once("source/logic/server/data.php");
 	include_once("source/logic/server/table.php");
 	include_once("source/logic/server/misc.php");
  ?>
579dbe00
 <section class="section" id="adpositions">
dcda8f59
 	<header>Adpositions</header>
000b5f04
 	<?php proposal(); ?>
 	<!--
 	<p>The following list gives an overview over prepositions:</p>
 	  -->
dcda8f59
 <?php
459c0868
 	$data_adpositions = read_json("source/data/adpositions.json");
93d9ca56
 	// $data = $data_adpositions["words"];
 	$data = $data_adpositions["situations"];
459c0868
 	{
93d9ca56
 		/*
459c0868
 		{
 			$data = sql_cross($data, $data_adpositions["situations"]);
 			$data = sql_select($data, function ($row) {return ($row["situation_id"] == $row["id"]);});
93d9ca56
 			$data = sql_order($data, function ($x, $y) {return ($x["situation_id"] >= $y["situation_id"]);});
 			$data = sql_delete($data, ["situation_id", "id"]);
 			$data = sql_rename($data, "name", "situation_name");
 		}
 		 */
 		{
 			$data = sql_cross($data, $data_adpositions["words"]);
 			$data = sql_select($data, function ($row) {return ($row["situation_id"] == $row["id"]);});
459c0868
 			$data = sql_delete($data, ["situation_id", "id"]);
 			$data = sql_rename($data, "name", "situation_name");
 		}
 		{
 			$data = sql_cross($data, $data_adpositions["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");
 		}
 		{
8794e319
 			$data = sql_cross($data, $data_adpositions["references"]);
 			$data = sql_select($data, function ($row) {return ($row["reference_id"] == $row["id"]);});
 			$data = sql_delete($data, ["reference_id", "id"]);
ba7fad35
 			$data = sql_rename($data, "name", "reference_name");
459c0868
 		}
 	}
 	
dcda8f59
 	$table = new class_table
 	(
 		[
459c0868
 			new class_column("Language", "language_id"),
 			new class_column("Situation", "situation_name"),
 			new class_column("Type", "type_name"),
ba7fad35
 			new class_column("Reference", "reference_name"),
459c0868
 			new class_column("Words", "words", function ($x) {return json_encode($x);}),
dcda8f59
 		],
459c0868
 		$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],
 				$table->columns_get()[3],
 			],
 			"columns_data" =>
 			[
 				$table->columns_get()[0],
 				$table->columns_get()[4],
 			],
 			"data_aggregator" => function ($values)
 			{
 				return $values;
 			},
8794e319
 			"data_formatter" => function_chain
 			(
 				[
 					object_from_array("language_id"),
 					object_map(object_attribute("words")),
 					format_correlation("type_word"),
 				]
 			),
459c0868
 		]
dcda8f59
 	);
8794e319
 	$table_->generate();
dcda8f59
  ?>
5707d791
  	<p><?php echo(format_correlation("type_sentence")(["flk" => ["Ek skal varte foran."], "eng" => ["I will wait in front."]])); ?></p>
  	<p><?php echo(format_correlation("type_sentence")(["flk" => ["Du mut blive bakan."], "eng" => ["You must stay in the back."]])); ?></p>
  	<p><?php echo(format_correlation("type_sentence")(["flk" => ["Han sta nedan de brüg."], "eng" => ["He stands under the bridge."]])); ?></p>
  	<p><?php echo(format_correlation("type_sentence")(["flk" => ["Hun flüg uvan de volker."], "eng" => ["She flies above the clouds."]])); ?></p>
  	<p><?php echo(format_correlation("type_sentence")(["flk" => ["Vi kan gae in de timer."], "eng" => ["We can go into the room."]])); ?></p>
  	<p><?php echo(format_correlation("type_sentence")(["flk" => ["Je skal löpe ut de hus."], "eng" => ["You shall run out of the house."]])); ?></p>
dcda8f59
 </section>