4 * Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam
5 * Copyright 2008 Marc-Etienne Vargenau, Alcatel-Lucent
7 * This file is part of PhpWiki.
9 * PhpWiki is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * PhpWiki is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * Usage: <<PrevNext prev=PrevLink next=NextLink >>
26 * See also PageGroup which automatically tries to extract the various links
29 class WikiPlugin_PrevNext
32 function getDescription()
34 return sprintf(_("Easy navigation buttons for %s."), '[pagename]');
37 function getDefaultArguments()
48 'style' => 'button', // or 'text'
49 'align' => 'left', // or 'right', or 'center'
50 'class' => 'wikiaction'
56 * @param string $argstr
57 * @param WikiRequest $request
58 * @param string $basepage
61 function run($dbi, $argstr, &$request, $basepage)
64 $args = $this->getArgs($argstr, $request);
66 $directions = array('first' => _("First"),
67 'prev' => _("Previous"),
71 'contents' => _("Contents"),
74 if ($order) { // reorder the buttons: comma-delimited
75 $new_directions = array();
76 foreach (explode(',', $order) as $o) {
77 $new_directions[$o] = $directions[$o];
79 $directions = $new_directions;
80 unset ($new_directions); // free memory
84 $sep = $WikiTheme->getButtonSeparator();
85 if ($align == 'center') {
87 $links = HTML::table(array('class' => 'fullwidth'), $tr);
88 } elseif ($align == 'right') {
89 $td = HTML::td(array('class' => 'align-'.$align));
90 $links = HTML::table(array('class' => 'fullwidth'), HTML::tr($td));
95 if ($style == 'text') {
97 $sep = " | "; // force some kind of separator
99 if ($align == 'center') {
100 $tr->pushContent(HTML::td(array('class' => 'align-'.$align), " [ "));
101 } elseif ($align == 'right') {
102 $td->pushcontent(" [ ");
104 $links->pushcontent(" [ ");
107 $last_is_text = false;
108 $this_is_first = true;
109 foreach ($directions as $dir => $label) {
110 // if ($last_is_text) $links->pushContent($sep);
111 if (!empty($args[$dir])) {
113 if ($style == 'button') {
114 // localized version: _("Previous").gif
115 if ($imgurl = $WikiTheme->getButtonURL($label)) {
117 if ($align == 'center') {
118 $tr->pushContent(HTML::td(array('class' => 'align-'.$align), $sep));
119 } elseif ($align == 'right') {
120 $td->pushcontent($sep);
122 $links->pushcontent($sep);
125 if ($align == 'center') {
126 $tr->pushContent(HTML::td(array('class' => 'align-'.$align), new ImageButton($label, $url, false, $imgurl)));
127 } elseif ($align == 'right') {
128 $td->pushContent(new ImageButton($label, $url, false, $imgurl));
130 $links->pushcontent(new ImageButton($label, $url, false, $imgurl));
132 $last_is_text = false;
133 // generic version: prev.gif
134 } elseif ($imgurl = $WikiTheme->getButtonURL($dir)) {
136 if ($align == 'center') {
137 $tr->pushContent(HTML::td(array('class' => 'align-'.$align), $sep));
138 } elseif ($align == 'right') {
139 $td->pushcontent($sep);
141 $links->pushcontent($sep);
144 if ($align == 'center') {
145 $tr->pushContent(HTML::td(array('class' => 'align-'.$align), new ImageButton($label, $url, false, $imgurl)));
146 } elseif ($align == 'right') {
147 $td->pushContent(new ImageButton($label, $url, false, $imgurl));
149 $links->pushcontent(new ImageButton($label, $url, false, $imgurl));
151 $last_is_text = false;
152 } else { // text only
153 if (!$this_is_first) {
154 if ($align == 'center') {
155 $tr->pushContent(HTML::td(array('class' => 'align-'.$align), $sep));
156 } elseif ($align == 'right') {
157 $td->pushcontent($sep);
159 $links->pushcontent($sep);
162 if ($align == 'center') {
163 $tr->pushContent(HTML::td(array('class' => 'align-'.$align), new Button($label, $url, $class)));
164 } elseif ($align == 'right') {
165 $td->pushContent(new Button($label, $url, $class));
167 $links->pushcontent(new Button($label, $url, $class));
169 $last_is_text = true;
172 if (!$this_is_first) {
173 if ($align == 'center') {
174 $tr->pushContent(HTML::td(array('class' => 'align-'.$align), $sep));
175 } elseif ($align == 'right') {
176 $td->pushcontent($sep);
178 $links->pushcontent($sep);
181 if ($align == 'center') {
182 $tr->pushContent(HTML::td(array('class' => 'align-'.$align), new Button($label, $url, $class)));
183 } elseif ($align == 'right') {
184 $td->pushContent(new Button($label, $url, $class));
186 $links->pushcontent(new Button($label, $url, $class));
188 $last_is_text = true;
190 $this_is_first = false;
193 if ($style == 'text') {
194 if ($align == 'center') {
195 $tr->pushContent(HTML::td(array('class' => 'align-'.$align), " ] "));
196 } elseif ($align == 'right') {
197 $td->pushcontent(" ] ");
199 $links->pushcontent(" ] ");
210 // c-hanging-comment-ender-p: nil
211 // indent-tabs-mode: nil