From 6e632617e95cdccf5f555677f9ec31353eaa9b38 Mon Sep 17 00:00:00 2001 From: vargenau Date: Sat, 13 Dec 2008 19:19:17 +0000 Subject: [PATCH] Added "align" parameter to PrevNext plugin git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@6355 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/plugin/PrevNext.php | 113 ++++++++++++++++++++++++++++++------ pgsrc/Help%2FPrevNextPlugin | 34 ++++++++++- 2 files changed, 127 insertions(+), 20 deletions(-) diff --git a/lib/plugin/PrevNext.php b/lib/plugin/PrevNext.php index 4f069e301..9f98076d1 100644 --- a/lib/plugin/PrevNext.php +++ b/lib/plugin/PrevNext.php @@ -2,6 +2,7 @@ rcs_id('$Id$'); /** Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam + Copyright 2008 Marc-Etienne Vargenau, Alcatel-Lucent This file is part of PhpWiki. @@ -52,6 +53,7 @@ extends WikiPlugin 'last' => '', 'order' => '', 'style' => 'button', // or 'text' + 'align' => 'left', // or 'right', or 'center' 'class' => 'wikiaction' ); } @@ -79,11 +81,27 @@ extends WikiPlugin global $WikiTheme; $sep = $WikiTheme->getButtonSeparator(); - $links = HTML(); + if ($align == 'center') { + $tr = HTML::tr(); + $links = HTML::table(array('cellpadding' => 0, 'cellspacing' => 0, 'width' => '100%'), $tr); + } else if ($align == 'right') { + $td = HTML::td(array('align' => $align)); + $links = HTML::table(array('cellpadding' => 0, 'cellspacing' => 0, 'width' => '100%'), HTML::tr($td)); + } else { + $links = HTML(); + } + if ($style == 'text') { - if (!$sep) + if (!$sep) { $sep = " | "; // force some kind of separator - $links->pushcontent(" [ "); + } + if ($align == 'center') { + $tr->pushContent(HTML::td(array('align' => $align), " [ ")); + } else if ($align == 'right') { + $td->pushcontent(" [ "); + } else { + $links->pushcontent(" [ "); + } } $last_is_text = false; $this_is_first = true; @@ -94,35 +112,92 @@ extends WikiPlugin if ($style == 'button') { // localized version: _("Previous").gif if ($imgurl = $WikiTheme->getButtonURL($label)) { - if ($last_is_text) - $links->pushContent($sep); - $links->pushcontent(new ImageButton($label, $url, - false, $imgurl)); + if ($last_is_text) { + if ($align == 'center') { + $tr->pushContent(HTML::td(array('align' => $align), $sep)); + } else if ($align == 'right') { + $td->pushcontent($sep); + } else { + $links->pushcontent($sep); + } + } + if ($align == 'center') { + $tr->pushContent(HTML::td(array('align' => $align), new ImageButton($label, $url, false, $imgurl))); + } else if ($align == 'right') { + $td->pushContent(new ImageButton($label, $url, false, $imgurl)); + } else { + $links->pushcontent(new ImageButton($label, $url, false, $imgurl)); + } $last_is_text = false; // generic version: prev.gif } elseif ($imgurl = $WikiTheme->getButtonURL($dir)) { - if ($last_is_text) - $links->pushContent($sep); - $links->pushContent(new ImageButton($label, $url, - false, $imgurl)); + if ($last_is_text) { + if ($align == 'center') { + $tr->pushContent(HTML::td(array('align' => $align), $sep)); + } else if ($align == 'right') { + $td->pushcontent($sep); + } else { + $links->pushcontent($sep); + } + } + if ($align == 'center') { + $tr->pushContent(HTML::td(array('align' => $align), new ImageButton($label, $url, false, $imgurl))); + } else if ($align == 'right') { + $td->pushContent(new ImageButton($label, $url, false, $imgurl)); + } else { + $links->pushcontent(new ImageButton($label, $url, false, $imgurl)); + } $last_is_text = false; } else { // text only - if (! $this_is_first) - $links->pushContent($sep); - $links->pushContent(new Button($label, $url, $class)); + if (! $this_is_first) { + if ($align == 'center') { + $tr->pushContent(HTML::td(array('align' => $align), $sep)); + } else if ($align == 'right') { + $td->pushcontent($sep); + } else { + $links->pushcontent($sep); + } + } + if ($align == 'center') { + $tr->pushContent(HTML::td(array('align' => $align), new Button($label, $url, $class))); + } else if ($align == 'right') { + $td->pushContent(new Button($label, $url, $class)); + } else { + $links->pushcontent(new Button($label, $url, $class)); + } $last_is_text = true; } } else { - if (! $this_is_first) - $links->pushContent($sep); - $links->pushContent(new Button($label, $url, $class)); + if (! $this_is_first) { + if ($align == 'center') { + $tr->pushContent(HTML::td(array('align' => $align), $sep)); + } else if ($align == 'right') { + $td->pushcontent($sep); + } else { + $links->pushcontent($sep); + } + } + if ($align == 'center') { + $tr->pushContent(HTML::td(array('align' => $align), new Button($label, $url, $class))); + } else if ($align == 'right') { + $td->pushContent(new Button($label, $url, $class)); + } else { + $links->pushcontent(new Button($label, $url, $class)); + } $last_is_text = true; } $this_is_first = false; } } - if ($style == 'text') - $links->pushcontent(" ] "); + if ($style == 'text') { + if ($align == 'center') { + $tr->pushContent(HTML::td(array('align' => $align), " ] ")); + } else if ($align == 'right') { + $td->pushcontent(" ] "); + } else { + $links->pushcontent(" ] "); + } + } return $links; } } diff --git a/pgsrc/Help%2FPrevNextPlugin b/pgsrc/Help%2FPrevNextPlugin index 938e6bc27..eeb9b548c 100644 --- a/pgsrc/Help%2FPrevNextPlugin +++ b/pgsrc/Help%2FPrevNextPlugin @@ -1,4 +1,4 @@ -Date: Mon, 9 Aug 2008 12:19:24 +0000 +Date: Mon, 12 Dec 2008 12:19:24 +0000 Mime-Version: 1.0 (Produced by PhpWiki 1.3.14-20080124) X-Rcs-Id: $Id$ Content-Type: application/x-phpwiki; @@ -55,6 +55,10 @@ The *~PrevLink* [plugin|Help:WikiPlugin] allows to display Previous and Next but | Reorder the buttons: comma-delimited | empty |- +| order +| Can be ''left'', ''right'' or ''center'' +| left +|- | style | Can be ''button'' or ''text'' | button @@ -84,6 +88,34 @@ The *~PrevLink* [plugin|Help:WikiPlugin] allows to display Previous and Next but contents="Help" ?> + + + + + + + + + + + +