5da1fdb36808b6ca63ab2d114abb788ca9571531
fenris foo

fenris authored 7 years ago

1) <?php
Christian Fraß better table-snap

Christian Fraß authored 7 years ago

2) 	function fetch($structure, $field, $fallback = null, $escalation = 1)
3) 	{
4) 		if (array_key_exists($field, $structure))
5) 		{
6) 			return $structure[$field];
7) 		}
8) 		else
9) 		{
10) 			switch ($escalation)
11) 			{
12) 				case 0:
13) 				{
14) 					return $fallback;
15) 					// break;
16) 				}
17) 				case 1:
18) 				{
19) 					return $fallback;
20) 					// break;
21) 				}
22) 				case 2:
23) 				{
24) 					throw (sprintf("field '%s' missing in structure!", $field));
25) 					return $fallback;
26) 					// break;
27) 				}
28) 				default:
29) 				{
30) 					throw (sprintf("unhandled escalation level %u", $escalation));
31) 					// break;
32) 				}
33) 			}
34) 		}
35) 	}
36) 	
bfadmin-master advanced

bfadmin-master authored 7 years ago

37) 	function compose($names)
38) 	{
Christian Fraß renamed structure to content

Christian Fraß authored 7 years ago

39) 		array_map
40) 		(
bfadmin-master advanced

bfadmin-master authored 7 years ago

41) 			function ($name)
42) 			{
Christian Fraß renamed structure to content

Christian Fraß authored 7 years ago

43) 				include("source/content/" . $name . ".html.php");
bfadmin-master advanced

bfadmin-master authored 7 years ago

44) 			},
45) 			$names
46) 		);
47) 	}
48) 	
fenris foo

fenris authored 7 years ago

49) 	function mark($core, $classes)
50) 	{
51) 		return ('<span class="' . implode(" ", $classes) . '">' . $core . '</span>');
52) 	}
53) 	
54) 	function format($string, $classes = ["word", "lang_fs"])
55) 	{
56) 		if ($string == NULL)
57) 		{
58) 			$string = "--";
59) 		}
60) 		else
61) 		{
62) 			$string = preg_replace("/\/([^\/]*)\//", mark("$1", ["ipa"]), $string);
63) 			$string = preg_replace("/_([^_]*)_/", "<u>$1</u>", $string);
64) 			$string = preg_replace("/\'([^\']*)\'/", mark("$1", $classes), $string);
65) 		}
66) 		return $string;
67) 	}
bfadmin-master advanced

bfadmin-master authored 7 years ago

68) 	
69) 	function _foo($fieldname)
70) 	{
71) 		return (
72) 			function ($row) use (&$fieldname)
73) 			{
74) 				global $configuration;
75) 				return ["original" => $row[$fieldname]["fs"], "translated" => $row[$fieldname][$configuration["target"]]];
76) 			}
77) 		);
78) 	}
79) 	
80) 	function _baz($words, $type, $language)
81) 	{
82) 		return ((count($words) == 0) ? "?" : implode(", ", array_map(function ($word) use (&$type,&$language) {return mark($word, [$type, "lang_" . $language]);}, $words)));
83) 	}
84) 	
85) 	function _bar($type = "word")
86) 	{
87) 		return (
88) 			function ($value) use (&$type)
89) 			{
90) 				global $configuration;
91) 				$output = "";
92) 				$output .= _baz($value["original"], $type, "fs");
93) 				$output .= " ~ ";
94) 				$output .= _baz($value["translated"], $type, $configuration["target"]);
95) 				return $output;
96) 			}
97) 		);
Christian Fraß personal pronouns and infin...

Christian Fraß authored 7 years ago

98) 	}
99) 	
100) 	function proposal()
101) 	{
102)  ?>
Christian Fraß included developer-notes; a...

Christian Fraß authored 7 years ago

103) 		<div class="note note_error">
104) 			<span class="note_content">
105) 				<p>This section is only a proposal yet; not part of the draft.</p>
106) 			</span>
107) 		</div>
Christian Fraß personal pronouns and infin...

Christian Fraß authored 7 years ago

108) <?php
109) 	}