* * */ if (!defined('PAGETRAIL_ARROW')) define('PAGETRAIL_ARROW', " ==> "); class WikiPlugin_PageTrail extends WikiPlugin { // Four required functions in a WikiPlugin. var $def_numberlinks = 5; function getName () { return _("PageTrail"); } function getDescription () { return _("PageTrail Plugin"); } function getVersion() { return preg_replace("/[Revision: $]/", '', "\$Revision: 1.4 $"); } // default values function getDefaultArguments() { return array('numberlinks' => $this->def_numberlinks, 'invisible' => false, 'duplicates' => false, ); } function run($dbi, $argstr, &$request, $basepage) { extract($this->getArgs($argstr, $request)); if ($numberlinks > 10 || $numberlinks < 0) { $numberlinks = $this->def_numberlinks; } // Get name of the current page we are on $thispage = $request->getArg('pagename'); $thiscookie = $request->cookies->get("Wiki_PageTrail"); $Pages = explode(':', $thiscookie); if ($duplicates || !in_array($thispage, $Pages)) { // New page, add it array_unshift($Pages, $thispage); } else { // We go back to a previous page while ($Pages[0] != $thispage) array_shift($Pages); } $request->cookies->set("Wiki_PageTrail",implode(':',$Pages)); if (! $invisible) { $numberlinks = min(count($Pages)-1, $numberlinks); $html = WikiLink($Pages[$numberlinks-1], 'auto'); for ($i = $numberlinks - 2; $i >= 0; $i--) { if (!empty($Pages[$i])) $html->pushContent(PAGETRAIL_ARROW, WikiLink($Pages[$i], 'auto')); } return $html; } else return HTML(); } }; // $Log: PageTrail.php,v $ // Revision 1.4 2004/02/27 02:49:40 rurban // patch #680562 "PageTrail Duplicates Patch (1.3.4)" // // Revision 1.3 2004/02/17 12:11:36 rurban // added missing 4th basepage arg at plugin->run() to almost all plugins. This caused no harm so far, because it was silently dropped on normal usage. However on plugin internal ->run invocations it failed. (InterWikiSearch, IncludeSiteMap, ...) // // Revision 1.2 2003/01/18 22:22:36 carstenklapp // defined constant for arrow, eliminate use of fmt() // // 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: ?>