<?php
global $configuration;
include_once("source/logic/server/data.php");
include_once("source/logic/server/sql.php");
include_once("source/logic/server/table.php");

/*
function convert_persona($persona) {return [0 => "impersonal", 1 => "1st person", 2 => "2nd person", 3 => "3rd person"][$persona];}
function convert_numerus($numerus) {return [0 => null, 1 => "singular", 2 => "plural"][$numerus];}
function convert_genus($genus) {return [0 => "common", 1 => "masculine", 2 => "feminine", 3 => "neuter"][$genus];}
 */
 ?>
<section class="subsection" id="personal_pronouns">
	<header>Personal Pronouns</header>
<?php
	$data_common = read_json("source/data/common.json");
	$data_pronouns = read_json("source/data/personal_pronouns.json");
	
	$data = $data_pronouns["words"];
	{
		{
			if (false)
			{
				$data = sql_cross($data, $data_common["counts"]);
				$data = sql_select($data, function ($row) {return ($row["count_id"] == $row["id"]);});
				$data = sql_delete($data, ["count_id", "id"]);
				$data = sql_rename($data, "name", "count_name");
			}
			else
			{
				$data = sql_rename($data, "count_id", "count_name");
			}
		}
		{
			if (false)
			{
				$data = sql_cross($data, $data_common["persons"]);
				$data = sql_select($data, function ($row) {return ($row["person_id"] == $row["id"]);});
				$data = sql_delete($data, ["person_id", "id"]);
				$data = sql_rename($data, "name", "person_name");
			}
			else
			{
				$data = sql_rename($data, "person_id", "person_name");
			}
		}
		{
			if (false)
			{
				$data = sql_cross($data, $data_common["genders"]);
				$data = sql_select($data, function ($row) {return ($row["gender_id"] == $row["id"]);});
				$data = sql_delete($data, ["gender_id", "id"]);
				$data = sql_rename($data, "name", "gender_name");
			}
			else
			{
				$data = sql_rename($data, "gender_id", "gender_name");
			}
		}
		{
			if (false)
			{
				$data = sql_cross($data, $data_pronouns["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");
			}
			else
			{
				$data = sql_rename($data, "type_id", "type_name");
			}
		}
		{
			if (false)
			{
				$data = sql_cross($data, $data_common["cases"]);
				$data = sql_select($data, function ($row) {return ($row["case_id"] == $row["id"]);});
				$data = sql_delete($data, ["case_id", "id"]);
				$data = sql_rename($data, "name", "case_name");
			}
			else
			{
				$data = sql_rename($data, "case_id", "case_name");
			}
		}
	}
	
	{
		// $data = sql_select($data, function ($row) {return ($row["type_name"] == "nor");});
		$data = sql_select($data, function ($row) {global $configuration; return (($row["language_id"] == "flk") or ($row["language_id"] == $configuration["target"]));});
	}
	
	$table = new class_table
	(
		[
			new class_column("Language", "language_id"),
			new class_column("Count", "count_name"),
			new class_column("Person", "person_name"),
			new class_column("Gender", "gender_name"),
			new class_column("Type", "type_name"),
			new class_column("Case", "case_name"),
			new class_column("Words", "words", function ($x) {return json_encode($x);}),
		],
		$data
	);
	
	$table->snap
	(
		[
			"label_vertical" => function ($column) {return "";},
			"columns_vertical" =>
			[
				$table->columns_get()[1],
				$table->columns_get()[2],
				$table->columns_get()[3],
			],
			"label_horizontal" => function ($column, $value) {return $value;},
			"columns_horizontal" =>
			[
				$table->columns_get()[4],
				$table->columns_get()[5],
			],
			"columns_data" =>
			[
				$table->columns_get()[0],
				$table->columns_get()[6],
			],
			"data_aggregator" => function ($values)
			{
				return $values;
			},
			"data_formatter" => function_chain
			(
				[
					object_from_array("language_id"),
					object_map(object_attribute("words")),
					format_correlation("type_word"),
				]
			),
		]
	)->generate();
 ?>
	<div class="note note_information">
		<span class="note_content">
			<p>Since the word <?php echo(mark("man", ["type_word", "lang_fs"])); ?> simply means <?php echo(mark("human being", ["type_word", "lang_en"])); ?>, it can be understood as an implicit way to express an abstract actor; similar words like <?php echo(mark("lüd", ["type_word", "lang_fs"])); ?> (<?php echo(mark("people", ["type_word", "lang_en"])); ?>) or <?php echo(mark("di", ["type_word", "lang_fs"])); ?> can be used as well.</p>
		</span>
	</div>
	<div class="note note_information">
		<span class="note_content">
			<p>The honorific salutation is expressed by the plural form <?php echo(mark("je", ["type_word", "lang_fs"])); ?>; however it should be avoided in usual speech in favor of the singular form <?php echo(mark("du", ["type_word", "lang_fs"])); ?>.</p>
		</span>
	</div>
	<div class="note note_information">
		<span class="note_content">
			<p>A reflexive genitive can be formed by inserting the word <?php echo(mark("egen", ["word", "lang_fs"])); ?> (<?php echo(mark("own", ["type_word", "lang_en"])); ?>), for example <?php echo(format_correlation("type_sentence")(["flk" => ["Han (A) hav givt to ham (B) hans egen buk."], "eng" => ["He (A) has given (to) him (B) his own book."]])); ?> (A's book was given to B).</p>
		</span>
	</div>
	<div class="note note_reasoning">
		<input type="checkbox" class="note_hide" title="click to show/hide" id="note_02"/>
		<label class="note_label note_label_show" for="note_02">show</label>
		<label class="note_label note_label_hide" for="note_02">hide</label>
		<span class="note_content">
			<p>When finding appropriate personal pronouns, the most intricate cases were the 3rd person singular and the 2nd person plural; both turned out to be very diverse among the modern Germanic languages. While for the 2nd person plural we could find a sufficient satisfying solution after a while, the 3rd person singular kept defying. In the end we came to the settlement to use a Swedish-like solution including the pronoun <?php echo(mark("hen", ["type_word", "lang_fs"])); ?>, which is not bound to any sexus so that it can be used for actors in general.</p>
		</span>
	</div>
</section>