2 rcs_id('$Id: PrevNext.php,v 1.4 2004-06-14 11:31:39 rurban Exp $');
4 Copyright 1999, 2000, 2001, 2002 $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 * Usage: <?plugin PrevNext prev=PrevLink next=NextLink ?>
25 * See also PageGroup which automatically tries to extract the various links
28 class WikiPlugin_PrevNext
35 function getDescription() {
36 return sprintf(_("Easy navigation buttons for %s"),'[pagename]');
39 function getVersion() {
40 return preg_replace("/[Revision: $]/", '',
44 function getDefaultArguments() {
55 'style' => 'button', // or 'text'
56 'class' => 'wikiaction'
60 function run($dbi, $argstr, &$request, $basepage) {
62 $args = $this->getArgs($argstr, $request);
64 $directions = array ('first' => _("First"),
65 'prev' => _("Previous"),
69 'contents' => _("Contents"),
72 if ($order) { // reorder the buttons: comma-delimited
73 $new_directions = array();
74 foreach (explode(',', $order) as $o) {
75 $new_directions[$o] = $directions[$o];
77 $directions = $new_directions;
78 unset ($new_directions); // free memory
82 $sep = $WikiTheme->getButtonSeparator();
84 if ($style == 'text') {
86 $sep = " | "; // force some kind of separator
87 $links->pushcontent(" [ ");
89 $last_is_text = false;
90 $this_is_first = true;
91 foreach ($directions as $dir => $label) {
92 // if ($last_is_text) $links->pushContent($sep);
93 if (!empty($args[$dir])) {
95 if ($style == 'button') {
96 // localized version: _("Previous").gif
97 if ($imgurl = $WikiTheme->getButtonURL($label)) {
99 $links->pushContent($sep);
100 $links->pushcontent(new ImageButton($label, $url,
102 $last_is_text = false;
103 // generic version: prev.gif
104 } elseif ($imgurl = $WikiTheme->getButtonURL($dir)) {
106 $links->pushContent($sep);
107 $links->pushContent(new ImageButton($label, $url,
109 $last_is_text = false;
110 } else { // text only
111 if (! $this_is_first)
112 $links->pushContent($sep);
113 $links->pushContent(new Button($label, $url, $class));
114 $last_is_text = true;
117 if (! $this_is_first)
118 $links->pushContent($sep);
119 $links->pushContent(new Button($label, $url, $class));
120 $last_is_text = true;
122 $this_is_first = false;
125 if ($style == 'text')
126 $links->pushcontent(" ] ");
131 // $Log: not supported by cvs2svn $
132 // Revision 1.3 2004/02/17 12:11:36 rurban
133 // 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, ...)
135 // Revision 1.2 2003/01/18 22:01:43 carstenklapp
137 // Reformatting & tabs to spaces;
138 // Added copyleft, getVersion, getDescription, rcs_id.
145 // c-hanging-comment-ender-p: nil
146 // indent-tabs-mode: nil