Module: website Branch: master Commit: 321f17b3f5ef274ef88ed5522dd3637d18489a00 URL: http://source.winehq.org/git/website.git/?a=commit;h=321f17b3f5ef274ef88ed55...
Author: Jeremy Newman jnewman@codeweavers.com Date: Tue Dec 11 09:53:23 2007 -0600
improve the prev/next links on the news archive
---
site | 24 +++++++++++++++--------- 1 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/site b/site index 8294174..32a6bb8 100644 --- a/site +++ b/site @@ -160,7 +160,9 @@ function view_news ($where) $amax = 25;
// where are we in news list - $x = $_GET['x']; + $x = 0; + if ($_GET['x']) + $x = $_GET['x'];
// get list of news items $news = get_files($config->news_xml_path, "xml"); @@ -201,20 +203,24 @@ function view_news ($where) // prev/next links if ($where == 'archive') { + $pages = floor(($total / $amax)); + $prev_link = ""; + $next_link = ""; + // add back to first page link when not first page + if ($x != 0) + $prev_link .= $html->ahref("[First Page]","?news=archive;x=0", 'class="menuItem"')." "; // display prev link if ($x > 0) - { - $prev = ($total) - $c; - $prev_link = $html->ahref("<< Previous News","?news=archive;x=".$prev,"class=menuItem"); - } + $prev_link .= $html->ahref("<< Previous Page","?news=archive;x=".($x - $amax), 'class="menuItem"'); // display next link if (($x + $amax) < $total) { - $next = $x + $amax; - $next_link .= $html->ahref("More News >>","?news=archive;x=".$next,"class=menuItem"); - } + $next_link .= $html->ahref("Next Page >>","?news=archive;x=".($x + $amax) , 'class="menuItem"'); + // add jump to last page link + $next_link .= " ".$html->ahref("[Last Page]","?news=archive;x=".($pages * $amax) , 'class="menuItem"'); + } // add prev/next links - $news_body .= $html->p($html->div($prev_link.' '.$next_link, 'align=center')); + $news_body .= $html->p($html->div($prev_link.' '.$next_link, 'align="center"')); }
// return the finished body