From: Paul P. <wa...@gl...> - 2002-09-26 20:11:40
|
One of the features which I found to be missing from phpWiki is the ability to have a page trail of the last pages which you clicked on. I worked for a while trying to understand the phpWiki plugins and I think I have it. If anyone would like to try it, feel free, and let me know if you have suggestions, comments, or questions. The basis for this is the HelloWorld.php plugin... ===Start of PageTrail.php=== <?php // -*-php-*- rcs_id('$Id: PageTrail.php,v 1.1 2002/09/24 21:56:28 ppearson Exp $'); /** * A simple PageTrail WikiPlugin. * * Usage: * <?plugin PageTrail?> * <?plugin PageTrail numberlinks=5?> */ // Constants are defined before the class. if (!defined('THE_END')) define('THE_END', "!"); class WikiPlugin_PageTrail extends WikiPlugin { // Four required functions in a WikiPlugin. function getName () { return _("PageTrail"); } function getDescription () { return _("PageTrail Plugin"); } // Establish default values for each of this plugin's arguments. function getDefaultArguments() { return array('numberlinks' => "5"); } function run($dbi, $argstr, $request) { global $Theme; extract($this->getArgs($argstr, $request)); if ($numberlinks>5 || $numberlinks<0) { $numberlinks=5;} // Get name of the current page we are on $thispage = $GLOBALS['request']->args['pagename']; $Page=array(); // Shift down the page names and store them back to cookies for ($count=$numberlinks; $count>0; $count--) { $thisvalue="PageTrail".$count; $thiscookie = @$_COOKIE["$thisvalue"]; if ($thiscookie!="") { $Page[$count+1]=$thiscookie; } else { $Page[$count+1]=""; } } $Page[1]=$thispage; // Now lets cycle through them saving them with setcookie $html = " "; for ($count=$numberlinks; $count>0; $count--) { if ($Page[$count]!="") { $Name="PageTrail" . $count; $Value = $Page[$count]; setcookie ($Name, $Value, 0, '/'); } } $html = HTML::tt(fmt('%s ==> %s ==> %s ==> %s ==> %s', WikiLink($Page[5], 'auto'), WikiLink($Page[4], 'auto'), WikiLink($Page[3], 'auto'), WikiLink($Page[2], 'auto'), WikiLink($Page[1], 'auto')),THE_END); return $html; } }; // For emacs users // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil // End: ?> ===End of PageTrail.php=== Comments ??? Paul |