From: Andreas Unterkircher Date: Sun, 8 Jul 2007 12:09:02 +0000 (+0000) Subject: issue6, improved page selector X-Git-Tag: phpfspot-1.2~156 X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=phpfspot.git;a=commitdiff_plain;h=7d9e5791c2e628361997ef5cb849ae4c75a2c395 issue6, improved page selector git-svn-id: file:///var/lib/svn/phpfspot/trunk@179 fa6a889d-dae6-447d-9e79-4ba9a3039384 --- diff --git a/phpfspot.class.php b/phpfspot.class.php index 15d1302..d9e8bbe 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -501,6 +501,7 @@ class PHPFSPOT { if(isset($_SESSION['searchfor']) && $_SESSION['searchfor'] != '') $this->tmpl->assign('searchfor', $_SESSION['searchfor']); + /* do we have to display the page selector ? */ if($this->cfg->rows_per_page != 0) { /* calculate the page switchers */ @@ -512,19 +513,13 @@ class PHPFSPOT { if($end_with < $count) $this->tmpl->assign("next_url", "javascript:showPhotoIndex(". $next_start .");"); - /* page selector */ $photo_per_page = $this->cfg->rows_per_page * $this->cfg->thumbs_per_row; - - /* until 6 pages we show the selector from 1-6 - everything large will be - 1 ... 2 3 4 (5) 6 7 ... 9 - */ $last_page = ceil($count / $photo_per_page); + /* get the current selected page */ if($begin_with == 0) { $current_page = 1; - } - else { + } else { $current_page = 0; for($i = $begin_with; $i >= 0; $i-=$photo_per_page) { $current_page++; @@ -543,11 +538,34 @@ class PHPFSPOT { else $style = ""; - $page_select.= " "; + $select = " "; + + // until 9 pages we show the selector from 1-9 + if($last_page <= 9) { + $page_select.= $select; + continue; + } else { + if($i == 1 /* first page */ || + $i == $last_page /* last page */ || + $i == $current_page /* current page */ || + $i == ceil($last_page * 0.25) /* first quater */ || + $i == ceil($last_page * 0.5) /* half */ || + $i == ceil($last_page * 0.75) /* third quater */ || + (in_array($i, array(1,2,3,4,5,6)) && $current_page <= 4) /* the first 6 */ || + (in_array($i, array($last_page, $last_page-1, $last_page-2, $last_page-3, $last_page-4, $last_page-5)) && $current_page >= $last_page-4) /* the last 6 */ || + $i == $current_page-3 || $i == $current_page-2 || $i == $current_page-1 /* three before */ || + $i == $current_page+3 || $i == $current_page+2 || $i == $current_page+1 /* three after */) { + + $page_select.= $select; + continue; + + } + } + $page_select.= "."; } /* only show the page selector if we have more then one page */