diff options
author | Andreas Unterkircher <unki@netshadow.at> | 2007-07-08 12:09:02 +0000 |
---|---|---|
committer | Andreas Unterkircher <unki@netshadow.at> | 2007-07-08 12:09:02 +0000 |
commit | 7d9e5791c2e628361997ef5cb849ae4c75a2c395 (patch) | |
tree | df2a60a23219a754ba149ccb0501160fe64b1edc | |
parent | f24b3770540d86c587027184850cb6fd28d1a0a2 (diff) |
issue6, improved page selector
git-svn-id: file:///var/lib/svn/phpfspot/trunk@179 fa6a889d-dae6-447d-9e79-4ba9a3039384
-rw-r--r-- | phpfspot.class.php | 42 |
1 files changed, 30 insertions, 12 deletions
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.= "<a href=\"javascript:showPhotoIndex(". (($i*$photo_per_page)-$photo_per_page) .");\""; - if($style != "") - $page_select.= $style; - $page_select.= ">". $i ."</a> "; + $select = "<a href=\"javascript:showPhotoIndex(". (($i*$photo_per_page)-$photo_per_page) .");\""; + if($style != "") + $select.= $style; + $select.= ">". $i ."</a> "; + + // 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 */ |