4 This is a plugin for the sf.net site, which splits the README
5 into multiple parts, that then will be printed read-only.
7 It was not developed to understand the format used by other text
8 files, so please do not annoy me, if it refuses to work for you.
9 Examples are examples. No support. -- milky
13 $ewiki_plugins["page"]["README"] = "ewiki_page_README";
14 $ewiki_plugins["page"]["README.config"] = "ewiki_page_README";
15 $ewiki_plugins["page"]["README.plugins"] = "ewiki_page_README";
16 $ewiki_plugins["page"]["README.fragments"] = "ewiki_page_README";
17 $ewiki_plugins["page"]["ProtectedMode"] = "ewiki_page_README";
18 $ewiki_plugins["page"]["INTERNALS"] = "ewiki_page_README";
19 #$ewiki_plugins["page"]["README.de"] = "ewiki_page_README";
22 function ewiki_page_README($id, $data, $action) {
25 $SECTIONSEP = "--------------------------------------------------------------";
27 #-- open "README" text file
28 if (($r = fopen("$id", "r")) or ($r = fopen("doc/$id", "r"))) {
30 #-- received request for a specific entry
31 if (($para = $_REQUEST["paragraph"]) || ($goto=$_REQUEST["goto"])) {
33 $str_next = $str_prev = "???";
35 #-- exact "title" pattern given
38 while (!feof($r) && (trim($line) != $para) )
40 $line = fgets($r, 4096);
41 if (strstr($line, $UNDERLINE)) {
49 #-- search for a paragraph number
51 while (!feof($r) && ($n < $goto) )
54 $line = fgets($r, 4096);
55 if (strstr($line, $UNDERLINE)) {
63 if ( ($goto&&($n==$goto)) || strstr(fgets($r, 4096), $UNDERLINE)) {
64 $hl = str_replace("[", "![", "\n!! $para\n\n<pre>");
68 while (!feof($r) && (!strstr($line, $UNDERLINE))) {
70 $line = fgets($r, 4096);
72 preg_match("/^([ ]+)/", $line, $uu);
73 $strip_n = strlen($uu[1]);
76 $line = preg_replace("/^[ ]{{$strip_n}}/", "", $line);
84 $src = rtrim(implode("", $lines)); $lines = "";
87 # $src = str_replace("[", "![", $src);
88 if (preg_match_all('/^\s+(EWIKI_[^\s]+)/m', $src, $uu)
89 && (count($uu[1])>10) ||
90 preg_match_all('/^[ ]+([^\n]+)\n\s\s\s------+/m', $src, $uu)
95 $src = preg_replace('/^[ ]+(EWIKI_[^\s]+)/m',
97 $src = preg_replace('/^[ ]+([^\n]+)\n\s\s\s(------+)/m',
98 "\n $1#[$1\"\"]\n $2", $src);
99 foreach ($uu[1] as $anchor) {
100 $pre .= "- [#$anchor \"$anchor\"]\n";
102 $src = $pre."\n".$src;
106 $o .= ewiki_format($hl.$src.$end);
112 #-- otherwise print all paragraph headlines in ordered lists
115 $o .= "\n<h2>$id overview</h2>\n";
125 $line = fgets($r, 4096);
127 if (strstr($line, $SECTIONSEP)) {
135 if (strstr($line, $UNDERLINE) && ($lastline!=="$id")) {
137 $new_ol_level = 1 - $first + (strpos($line, $UNDERLINE)>2 ?1:0);
138 while($ol_level > $new_ol_level) {
142 while($ol_level < $new_ol_level) {
148 $o .= '<li><a href="' . ewiki_script("", "$id",
149 array("paragraph"=>$lastline)) . '">' . $lastline .
150 '</a><br /></li>' . "\n";
155 $lastline = trim($line);
169 $o .= '<a href="' . ewiki_script("", "$id", "goto=".($n-1)).'">'.
170 'prev << "'.trim($str_prev).'"</a><br />';
171 $o .= '<a href="' . ewiki_script("", "$id", "goto=".($n+1)).'">'.
172 'next >> "'.trim($str_next).'"</a><br />';
175 $br = ewiki_script("", "BugReports");
176 $us = ewiki_script("", "UserSuggestions");
177 $dc = ewiki_script("", "{$id}.Discussion");
181 You cannot modify the {$id} file, but anyhow any ideas or suggestion should
182 as usually get filed on <a href=\"$br\">BugReports</a>,
183 <a href=\"$us\">UserSuggestions</a> or even better the
184 <a href=\"$dc\">{$id}.Discussion</a>.