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() {
54 'style' => 'button', // or 'text'
55 'class' => 'wikiaction'
59 function run($dbi, $argstr, &$request, $basepage) {
61 $args = $this->getArgs($argstr, $request);
63 $directions = array ('first' => _("First"),
64 'prev' => _("Previous"),
68 'contents' => _("Contents"),
71 if ($order) { // reorder the buttons: comma-delimited
72 $new_directions = array();
73 foreach (explode(',', $order) as $o) {
74 $new_directions[$o] = $directions[$o];
76 $directions = $new_directions;
77 unset ($new_directions); // free memory
81 $sep = $WikiTheme->getButtonSeparator();
83 if ($style == 'text') {
85 $sep = " | "; // force some kind of separator
86 $links->pushcontent(" [ ");
88 $last_is_text = false;
89 $this_is_first = true;
90 foreach ($directions as $dir => $label) {
91 // if ($last_is_text) $links->pushContent($sep);
92 if (!empty($args[$dir])) {
94 if ($style == 'button') {
95 // localized version: _("Previous").gif
96 if ($imgurl = $WikiTheme->getButtonURL($label)) {
98 $links->pushContent($sep);
99 $links->pushcontent(new ImageButton($label, $url,
101 $last_is_text = false;
102 // generic version: prev.gif
103 } elseif ($imgurl = $WikiTheme->getButtonURL($dir)) {
105 $links->pushContent($sep);
106 $links->pushContent(new ImageButton($label, $url,
108 $last_is_text = false;
109 } else { // text only
110 if (! $this_is_first)
111 $links->pushContent($sep);
112 $links->pushContent(new Button($label, $url, $class));
113 $last_is_text = true;
116 if (! $this_is_first)
117 $links->pushContent($sep);
118 $links->pushContent(new Button($label, $url, $class));
119 $last_is_text = true;
121 $this_is_first = false;
124 if ($style == 'text')
125 $links->pushcontent(" ] ");
134 // c-hanging-comment-ender-p: nil
135 // indent-tabs-mode: nil