3 Standard functions for Wiki functionality
8 LinkExistingWikiWord($wikiword)
9 LinkUnknownWikiWord($wikiword)
12 CookSpaces($pagearray)
14 SetHTMLOutputMode($newmode, $depth)
17 // render the Wiki toolbar at bottom of page
18 function WikiToolBar() {
19 global $ScriptUrl, $pagename, $pagehash;
21 echo "<a href=\"$ScriptUrl?edit=$pagename\">EditText</a>\n";
22 echo " of this page\n";
23 if (is_array($pagehash)) {
24 echo " (last edited ", $pagehash["date"], ")\n";
28 echo "<a href='$ScriptUrl?FindPage&value=$pagename";
29 echo "'>FindPage</a> by browsing or searching\n";
33 function WikiHeader($pagename) {
34 global $LogoImage, $ScriptUrl;
37 echo "<title>$pagename</title>\n";
42 function WikiFooter() {
43 echo "</body>\n</html>\n";
46 function GetCurrentDate() {
47 // format is like December 13, 1999
48 return date("F j, Y");
51 function LinkExistingWikiWord($wikiword) {
53 return "<a href=\"$ScriptUrl?$wikiword\">$wikiword</a>";
56 function LinkUnknownWikiWord($wikiword) {
58 return "$wikiword<a href=\"$ScriptUrl?edit=$wikiword\">?</a>";
63 function RenderQuickSearch() {
64 global $value, $ScriptUrl;
65 static $formtext = "<form action='$ScriptUrl'>\n<input type='text' size='40' name='search' value='$value'>\n</form>\n";
69 function RenderFullSearch() {
70 global $value, $ScriptUrl;
71 static $formtext = "<form action='$ScriptUrl'>\n<input type='text' size='40' name='full' value='$value'>\n</form>\n";
75 // converts spaces to tabs
76 function CookSpaces($pagearray) {
77 return preg_replace("/ {3,8}/", "\t", $pagearray);
85 function push($item) {
86 $this->items[$this->size] = $item;
92 if ($this->size == 0) {
93 return false; // stack is empty
96 return $this->items[$this->size];
104 return $this->items[$this->size - 1];
108 // end class definition
112 Wiki HTML output can, at any given time, be in only one mode.
113 It will be something like Unordered List, Preformatted Text,
114 plain text etc. When we change modes we have to issue close tags
115 for one mode and start tags for another.
118 // couldn't create a static version :-/
119 // I couldn't move this to config.php3 because it
120 // wasn't declared yet.
123 function SetHTMLOutputMode($tag, $tagdepth, $tabcount) {
126 if ($tagdepth == SINGLE_DEPTH) {
128 if ($tabcount < $stack->cnt()) {
130 // there are fewer tabs than stack, reduce stack
131 // to one less than tab count; then push new tag
132 while ($stack->cnt() > ($tabcount - 1)) {
133 $closetag = $stack->pop();
134 if ($closetag == false) {
135 //echo "bounds error in tag stack";
139 echo "</$closetag>\n";
145 } elseif ($tabcount > $stack->cnt()) {
146 // we add the diff to the stack
147 // stack might be zero
148 while ($stack->cnt() < $tabcount) {
151 if ($stack->cnt() > 10) {
152 // arbitrarily limit tag nesting
153 echo "Stack bounds exceeded in SetHTMLOutputMode\n";
159 if ($tag == $stack->top()) {
162 $closetag = $stack->pop();
163 echo "</$closetag>\n";
169 } elseif ($tagdepth == ZERO_DEPTH) {
170 // empty the stack for $depth == 0;
171 // what if the stack is empty?
172 if ($tag == $stack->top()) {
175 while ($stack->cnt() > 0) {
176 $closetag = $stack->pop();
177 echo "</$closetag>\n";
187 echo "Passed bad tag depth value in SetHTMLOutputMode\n";
191 // end SetHTMLOutputMode