]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/PageTrail.php
don't cache this at all
[SourceForge/phpwiki.git] / lib / plugin / PageTrail.php
1 <?php // -*-php-*-
2 rcs_id('$Id: PageTrail.php,v 1.3 2004-02-17 12:11:36 rurban Exp $');
3 /**
4  Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam
5
6  This file is part of PhpWiki.
7
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.
12
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.
17
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
21  */
22
23 /**
24  * A simple PageTrail WikiPlugin.
25  * Put this at the end of each page to store the trail.
26  *
27  * Usage:
28  * <?plugin PageTrail?>
29  * <?plugin PageTrail numberlinks=5?>
30  * <?plugin PageTrail invisible=1?>
31  */
32
33 if (!defined('PAGETRAIL_ARROW'))
34     define('PAGETRAIL_ARROW', " ==> ");
35
36 class WikiPlugin_PageTrail
37 extends WikiPlugin
38 {
39     // Four required functions in a WikiPlugin.
40     var $def_numberlinks = 5;
41
42     function getName () {
43         return _("PageTrail");
44     }
45
46     function getDescription () {
47         return _("PageTrail Plugin");
48
49     }
50
51     function getVersion() {
52         return preg_replace("/[Revision: $]/", '',
53                             "\$Revision: 1.3 $");
54     }
55
56     // default values
57     function getDefaultArguments() {
58         return array('numberlinks' => $this->def_numberlinks,
59                      'invisible' => false,
60                      );
61     }
62
63     function run($dbi, $argstr, &$request, $basepage) {
64         extract($this->getArgs($argstr, $request));
65
66         if ($numberlinks > 10 || $numberlinks < 0) {
67             $numberlinks = $this->def_numberlinks;
68         }
69
70         // Get name of the current page we are on
71         $thispage = $request->getArg('pagename');
72         $thiscookie = $request->cookies->get("Wiki_PageTrail");
73         $Pages = explode(':', $thiscookie);
74         array_unshift($Pages, $thispage);
75         $request->cookies->set("Wiki_PageTrail", implode(':', $Pages));
76
77         if (! $invisible) {
78             $numberlinks = min(count($Pages)-1, $numberlinks);
79             $html = HTML::tt(WikiLink($Pages[$numberlinks-1], 'auto'));
80             for ($i = $numberlinks - 2; $i >= 0; $i--) {
81                 if (!empty($Pages[$i]))
82                     $html->pushContent(PAGETRAIL_ARROW, WikiLink($Pages[$i],
83                                                                  'auto'));
84             }
85             return $html;
86         } else
87             return HTML();
88     }
89 };
90
91 // $Log: not supported by cvs2svn $
92 // Revision 1.2  2003/01/18 22:22:36  carstenklapp
93 // defined constant for arrow, eliminate use of fmt()
94 //
95
96 // For emacs users
97 // Local Variables:
98 // mode: php
99 // tab-width: 8
100 // c-basic-offset: 4
101 // c-hanging-comment-ender-p: nil
102 // indent-tabs-mode: nil
103 // End:
104 ?>