4 Adds a CSS container with links to all listed headlines of the
5 current page (but threshold for its activation is 3).
10 border: 2px #333333 solid;
14 Modified 20040810 by Jochen
15 - makes now use of EWIKI_TOC_CAPTION to print "TOC" above it all
16 - indention swapped (biggest headlines are now left,
17 and smaller ones are indented to the right)
18 - added some \n for more readable html
23 $ewiki_plugins["format_source"][] = "ewiki_toc_format_source";
24 $ewiki_plugins["format_final"][] = "ewiki_toc_view_prepend";
25 define("EWIKI_TOC_CAPTION", 0);
26 $ewiki_t["en"]["toc"] = "Content";
27 $ewiki_t["de"]["toc"] = "Inhalt";
30 #-- wiki page source rewriting
31 function ewiki_toc_format_source(&$src) {
35 $src = explode("\n", $src);
36 foreach ($src as $i=>$line) {
38 if ($line[0] == "!") {
39 $n = strspn($line, "!");
40 if (($n <= 3) and ($line[$n]==" ")) {
42 $text = substr($line, $n);
43 $toc[$i] = str_repeat(" ", 3-$n) . "ยท"
44 .// Had top fix this to make anchor links in the TOC work '<a href="#line'.$i.'">
45 '<a href="'.EWIKI_SCRIPT.$_GET['page'].'#line'.$i.'">'
46 . trim($text) . "</a>";
48 $src[$i] = str_repeat("!", $n) . $text . " [#line$i]";
53 $src = implode("\n", $src);
55 $GLOBALS["ewiki_page_toc"] = &$toc;
59 #-- injects toc above page
60 function ewiki_toc_view_prepend(&$html) {
62 global $ewiki_page_toc;
64 if (count($ewiki_page_toc) >= 3) {
66 $html = "<div class=\"page-toc\">\n"
67 . ( EWIKI_TOC_CAPTION ? '<div class="page-toc-caption">'.ewiki_t("toc")."</div>\n" : '')
68 . implode("<br />\n", $ewiki_page_toc) . "</div>\n"
72 // $ewiki_page_toc = NULL;