From 6379e3e38e462f07f3560f101be1707b5f2521f9 Mon Sep 17 00:00:00 2001 From: carstenklapp Date: Fri, 11 Jan 2002 06:39:06 +0000 Subject: [PATCH] Plugin now correctly handles end, beginning and looping. git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@1165 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/plugin/walkabout.php | 54 +++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/lib/plugin/walkabout.php b/lib/plugin/walkabout.php index 3788a3258..f0628d4fa 100644 --- a/lib/plugin/walkabout.php +++ b/lib/plugin/walkabout.php @@ -1,5 +1,5 @@ * - * + * + * + * * * */ @@ -143,22 +145,50 @@ extends WikiPlugin $go = array ('previous','next'); $links = array(); + $max = count($c) - 1; //array is 0-based, count is 1-based! foreach ( $go as $go_item ) { - - //these are temp placeholders to test the output + //yuck this smells, needs optimization. if ($go_item == 'previous') { - $text = sprintf(_("%s: %s"), $directions[$go_item], '%s'); - $action = $c[$thispage - 1]; - } - else if ($go_item == 'next') { - $text = sprintf(_("%s: %s"), $directions[$go_item], '%s'); - $action = $c[$thispage + 1]; + if ($loop) { + if ($thispage == 0) { + $action = $c[$max]; + } else { + $action = $c[$thispage - 1]; + } + $text = sprintf(_("%s: %s"), $directions[$go_item], '%s'); + $links[] = sprintf($text, $this->mklinks($action, $action)); + } else { + if ($thispage == 0) { + // skip it + } else { + $text = sprintf(_("%s: %s"), $directions[$go_item], '%s'); + $action = $c[$thispage - 1]; + $links[] = sprintf($text, $this->mklinks($action, $action)); + } + } + } else if ($go_item == 'next') { + if ($loop) { + if ($thispage == $max) { + $action = $c[1]; + } else { + $action = $c[$thispage + 1]; + } + $text = sprintf(_("%s: %s"), $directions[$go_item], '%s'); + $links[] = sprintf($text, $this->mklinks($action, $action)); + } else { + if ($thispage == $max) { + // skip it + } else { + $text = sprintf(_("%s: %s"), $directions[$go_item], '%s'); + $action = $c[$thispage + 1]; + $links[] = sprintf($text, $this->mklinks($action, $action)); + } + } } - $links[] = sprintf($text, $this->mklinks($action, $action)); } - //final assembly + // Final assembly $links = join($sep, $links); $html = sprintf(do_transform(_($label)),$links); -- 2.45.0