changed git call from https to git readonly
[atutor.git] / mods / wiki / plugins / filter / fun_chef.php
1 <?php
2
3 /*
4    Code modelled after Joes Hess` description of the 'chef' filter from
5    the debian text filters package. This one is heavily broken,
6    rearranging the rules is required; some other differences are because
7    the orig. 'chef' filter gets some rules wrong too.
8 */
9
10
11 $ewiki_plugins["view_final"][] = "ewiki_page_filter_chef";
12
13
14 function ewiki_page_filter_chef(&$o) {
15    $o = preg_replace('/>([^<>]+)</e',
16    '">".stripslashes(strhtml_chef("\\1"))."<"', $o);
17 }
18
19
20 function strhtml_chef($text) {
21
22    #-- end of word
23    $text = preg_replace('/th\b/', 't', $text);
24    $text = preg_replace('/en\b/', 'ee', $text);
25
26    #-- simple
27    $text = preg_replace('/the/', 'zhe', $text);
28    $text = preg_replace('/The/', 'Zhe', $text);
29
30    #-- if not first letter
31    $text = preg_replace('/(\w)f/', '\\1ff', $text);
32    $text = preg_replace('/\b(\w+?)i(\w+)\b/', '\\1ee\\2', $text);
33
34    #-- u to oo, o to u
35    $text = strtr($text, "uo", "ou");
36    $text = preg_replace('/o/', 'oo', $text);
37    #-- first letter o
38    $text = preg_replace('/\bO(\w)/', 'Oo\\2', $text);
39
40    #-- always (o and u rules)
41    $text = preg_replace('/au/', 'oo', $text);
42    $text = preg_replace('/Au/', 'Oo', $text);
43
44    #-- always (not conflicting)
45    $text = preg_replace('/v/', 'f', $text);
46    $text = preg_replace('/V/', 'F', $text);
47    $text = preg_replace('/w/', 'v', $text);
48    $text = preg_replace('/W/', 'V', $text);
49    $text = preg_replace('/an/', 'un', $text);
50    $text = preg_replace('/An/', 'Un', $text);
51 // $text = preg_replace('/en/', 'un', $text);   // for bug emulation
52
53    #-- begin of word
54    $text = preg_replace('/\be/', 'i', $text);
55    $text = preg_replace('/\bE/', 'I', $text);
56
57    #-- not last letter
58    $text = preg_replace('/[Aa](\w)/', 'e\\1', $text);
59
60    #-- all following must take into account previous garbaging, and revert
61    #   as needed
62
63    #-- simple
64    $text = preg_replace('/(tion|teeun)/', 'shun', $text);
65
66    #-- end of word
67    $text = preg_replace('/(?<![zZ]h)e\b/', 'e-a', $text);
68
69    $text = preg_replace('/[ou][vw]\b/', 'oo', $text);
70         
71    $text = preg_replace('/([.!?]\s*\n)/', "\\1<br />\nBork Bork Bork!<br />\n", $text);
72
73    return($text);
74 }
75
76
77 ?>