changed git call from https to git readonly
[atutor.git] / mods / wiki / plugins / markup / abbr.php
1 <?php
2
3 /*
4    The pages "Acronyms" and "Abbreviations" are read in by this plugin,
5    and its contents (a table or definition list) are used to replace
6    all occourences of the noticed words with <abbr> and <acronym> tags
7    on other pages (case-sensitive).
8 */
9
10 $ewiki_config["acronym"][] = "Acronyms";
11 $ewiki_config["abbr"][] = "Abbreviations";
12
13
14 $ewiki_plugins["format_final"][] = "ewiki_acronyms";
15 //(or even)  $ewiki_plugins["page_final"][] = "ewiki_acronyms";
16
17
18 function ewiki_acronyms(&$html) {
19
20    global $ewiki_config;
21
22    foreach (array("acronym", "abbr") as $tag) {
23
24       #-- read in data pages
25       $list = array();
26       foreach ($ewiki_config[$tag] as $id) {
27          $data = ewiki_db::GET($id);
28          preg_match_all('/^[|:]\s*(\w+)\s*[|:]\s*(.+?)[|:\s]*$/m', $data["content"], $uu);
29          foreach ($uu[1] as $i=>$str) {
30             $list[$str] = htmlentities($uu[2][$i]);
31          }
32       }
33
34       #-- add html tags to current page
35       if ($list && ($search = implode("|", array_keys($list)))) {
36          $html .= "<";
37          $html = preg_replace(
38             "/($search)([^>]*<)/mse",
39             "'<$tag title=\"'.\$list['$1'].'\">$1</$tag>' . stripslashes('$2')",
40             $html
41          );
42          $html = rtrim($html, "<");
43       }
44    }
45
46 }
47
48
49 ?>