77d8eec65a6d272eeee78097bf5a526d3a45059d
fenris foo

fenris authored 8 years ago

1) <?php
bfadmin-master advanced

bfadmin-master authored 8 years ago

2) 	function compose($names)
3) 	{
Christian Fraß renamed structure to content

Christian Fraß authored 8 years ago

4) 		array_map
5) 		(
bfadmin-master advanced

bfadmin-master authored 8 years ago

6) 			function ($name)
7) 			{
Christian Fraß renamed structure to content

Christian Fraß authored 8 years ago

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

bfadmin-master authored 8 years ago

9) 			},
10) 			$names
11) 		);
12) 	}
13) 	
fenris foo

fenris authored 8 years ago

14) 	function mark($core, $classes)
15) 	{
16) 		return ('<span class="' . implode(" ", $classes) . '">' . $core . '</span>');
17) 	}
18) 	
19) 	function format($string, $classes = ["word", "lang_fs"])
20) 	{
21) 		if ($string == NULL)
22) 		{
23) 			$string = "--";
24) 		}
25) 		else
26) 		{
27) 			$string = preg_replace("/\/([^\/]*)\//", mark("$1", ["ipa"]), $string);
28) 			$string = preg_replace("/_([^_]*)_/", "<u>$1</u>", $string);
29) 			$string = preg_replace("/\'([^\']*)\'/", mark("$1", $classes), $string);
30) 		}
31) 		return $string;
32) 	}
bfadmin-master advanced

bfadmin-master authored 8 years ago

33) 	
34) 	function _foo($fieldname)
35) 	{
36) 		return (
37) 			function ($row) use (&$fieldname)
38) 			{
39) 				global $configuration;
40) 				return ["original" => $row[$fieldname]["fs"], "translated" => $row[$fieldname][$configuration["target"]]];
41) 			}
42) 		);
43) 	}
44) 	
45) 	function _baz($words, $type, $language)
46) 	{
47) 		return ((count($words) == 0) ? "?" : implode(", ", array_map(function ($word) use (&$type,&$language) {return mark($word, [$type, "lang_" . $language]);}, $words)));
48) 	}
49) 	
50) 	function _bar($type = "word")
51) 	{
52) 		return (
53) 			function ($value) use (&$type)
54) 			{
55) 				global $configuration;
56) 				$output = "";
57) 				$output .= _baz($value["original"], $type, "fs");
58) 				$output .= " ~ ";
59) 				$output .= _baz($value["translated"], $type, $configuration["target"]);
60) 				return $output;
61) 			}
62) 		);
63) 	}