changed git call from https to git readonly
[atutor.git] / mods / wiki / plugins / filter / fun_screamomatic.php
1 <?php
2
3 /*
4    This filter plugin converts pages content into all-uppercase, if someone
5    edits a page and leaves at least one line of uppercase characters (a
6    persistent cookie is set).
7 */
8
9
10 define("EWIKI_UP_SCREAMOMATIC", "screamomatic");
11
12 $ewiki_plugins["edit_save"][] = "ewiki_edit_save_fun_screamomatic";
13 $ewiki_plugins["page_final"][] = "ewiki_page_final_fun_screamomatic";
14
15
16 function ewiki_edit_save_fun_screamomatic(&$save, &$old) {
17
18    #-- count lines of yelling
19    preg_match_all("/^[^a-z\340-\377_\n]{10,}$/m", $old["content"], $uu);
20    $old_screaming = count($uu[0]);
21    preg_match_all("/^[^a-z\340-\377_\n]{10,}$/m", $save["content"], $uu);
22    $new_screaming = count($uu[0]);
23
24    #-- trapped!
25    if ($new_screaming > $old_screaming) {
26       setcookie(EWIKI_UP_SCREAMOMATIC, "true", time()+7*24*3600, "/");
27    }
28 }
29
30
31 function ewiki_page_final_fun_screamomatic(&$html, $id, &$data, $action) {
32    if ($_COOKIE[EWIKI_UP_SCREAMOMATIC]) {
33       $html = preg_replace('/>([^<>]+)</e',
34               '">".strtoupper(stripslashes("\\1"))."<"', $html);
35    }
36 }
37
38
39 ?>