wiki integration

dvanhorn <[email protected]> Sun, 25 Jul 2004 20:22:20 -0700
Newsgroups gmane.org.ballistichelmet.devel
Message-ID <[email protected]>
I hacked the wiki sources a bit to give it that bh homepage feel. 
PhpWiki uses HTML templates in www/wiki/templates/ with templates marked 
like ###KEYWORD###.  See templates/README for the placeholders 	provided 
by PhpWiki.

Essentially I added 3 template keywords: BHHEAD, BHPRE, BHPOST.  See 
templates/browse.html for example.  The added code that handles these 
keywords is in lib/stdlib.php.

We define 3 corresponding global variables which are assigned values in 
lib/config.php.  These values are what is to be substituted for the 
keywords when the template is instatiated.  An auxilliary function 
_include_string(filename) is used that works like 'include', but returns 
a string rather than outputting.  We then call _include_string on 
~/www/bh_head and assign the result to $bh_head and so on.

Here's the diff:

*** /home/bh/phpwiki-1.2.4/lib/stdlib.php       Thu Nov  8 17:20:19 2001
--- /home/bh/www/wiki/lib/stdlib.php    Sat Jul 24 03:23:46 2004
***************
*** 443,446 ****
--- 443,449 ----
         global $datetimeformat, $dbi, $logo, $FieldSeparator;

+       // Ballistic Helmet Hack
+       global $bh_head, $bh_pre, $bh_post;
+
         if (!is_array($hash))
            unset($hash);
***************
*** 493,496 ****
--- 496,504 ----
         _dotoken('LOGO', $logo, $page);

+       // BH Hack:
+       _dotoken('BHHEAD', $bh_head, $page);
+       _dotoken('BHPRE',  $bh_pre,  $page);
+       _dotoken('BHPOST', $bh_post, $page);
+
         // invalid for messages (search results, error messages)
         if ($template != 'MESSAGE') {


*** /home/bh/phpwiki-1.2.4/lib/config.php       Fri Nov  9 10:36:03 2001
--- /home/bh/www/wiki/lib/config.php    Sun Jul 25 22:56:03 2004
***************
*** 168,171 ****
--- 168,184 ----
      /////////////////////////////////////////////////////////////////////

+    // Ballistic Helmet Hack:
+    function _include_string($file) {
+      ob_start();
+      include $file;
+      $str = ob_get_contents();
+      ob_end_clean();
+      return $str;
+    }
+
+    $bh_head = _include_string('/home/bh/www/bh_head');
+    $bh_pre  = _include_string('/home/bh/www/bh_body_preamble');
+    $bh_post = _include_string('/home/bh/www/bh_body_postamble');
+
      // logo image (path relative to index.php)
      $logo = "images/wikibase.png";