4 * Copyright 1999,2000,2001,2002,2005 $ThePhpWikiProgrammingTeam
6 * This file is part of PhpWiki.
8 * PhpWiki is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * PhpWiki is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with PhpWiki; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * A simple PageTrail WikiPlugin.
25 * Put this at the begin/end of each page to store the trail,
26 * or better in a template (body or bottom) to support it for all pages.
27 * But Cache should be turned off then.
30 * <?plugin PageTrail?>
31 * <?plugin PageTrail numberlinks=5?>
32 * <?plugin PageTrail invisible=1?>
35 if (!defined('PAGETRAIL_ARROW'))
36 define('PAGETRAIL_ARROW', " => ");
38 class WikiPlugin_PageTrail
41 // Four required functions in a WikiPlugin.
42 var $def_numberlinks = 5;
45 return _("PageTrail");
48 function getDescription () {
49 return _("PageTrail Plugin");
53 function getVersion() {
54 return preg_replace("/[Revision: $]/", '',
59 function getDefaultArguments() {
60 return array('numberlinks' => $this->def_numberlinks,
62 'duplicates' => false,
66 function run($dbi, $argstr, &$request, $basepage) {
67 extract($this->getArgs($argstr, $request));
69 if ($numberlinks > 10 || $numberlinks < 0) {
70 $numberlinks = $this->def_numberlinks;
73 // Get name of the current page we are on
74 $thispage = $request->getArg('pagename');
75 $Pages = $request->session->get("PageTrail");
76 if (!is_array($Pages)) $Pages = array();
78 if (!isset($Pages[0]) or ($duplicates || ($thispage != $Pages[0]))) {
79 array_unshift($Pages, $thispage);
80 $request->session->set("PageTrail", $Pages);
83 $numberlinks = min(count($Pages), $numberlinks);
84 if (! $invisible and $numberlinks) {
85 $html = HTML::div(array('class' => 'pagetrail'));
86 $html->pushContent(WikiLink($Pages[$numberlinks-1], 'auto'));
87 for ($i = $numberlinks - 2; $i >= 0; $i--) {
88 if (!empty($Pages[$i]))
89 $html->pushContent(PAGETRAIL_ARROW,
90 WikiLink($Pages[$i], 'auto'));
103 // c-hanging-comment-ender-p: nil
104 // indent-tabs-mode: nil