diff options
Diffstat (limited to 'phpfspot.class.php')
-rw-r--r-- | phpfspot.class.php | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php index cf0a60c..17ec450 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -503,7 +503,7 @@ class PHPFSPOT { $this->tmpl->assign('image_filename', $this->parse_uri($details['uri'], 'filename')); $this->tmpl->assign('tags', $this->get_photo_tags($photo)); - $this->tmpl->assign('current', $current); + $this->tmpl->assign('current', $this->getCurrentPage($current, $count)); if($previous_img) { $this->tmpl->assign('previous_url', "javascript:showImage(". $previous_img .");"); @@ -955,12 +955,12 @@ class PHPFSPOT { if(isset($_SESSION['begin_with']) && $_SESSION['begin_with'] != "") $anchor = $_SESSION['begin_with']; + /* if all thumbnails should be shown on one page */ if(!isset($this->cfg->thumbs_per_page) || $this->cfg->thumbs_per_page == 0) { - $begin_with = 0; $end_with = $count; - } + /* thumbnails should be splitted up in several pages */ elseif($this->cfg->thumbs_per_page > 0) { if(!isset($_SESSION['begin_with']) || $_SESSION['begin_with'] == 0) { @@ -2464,6 +2464,27 @@ class PHPFSPOT { } // cleanup_phpfspot_db() + /** + * return first image of the page, the $current photo + * lies in. + * + * this function is used to find out the first photo of the + * current page, in which the $current photo lies. this is + * used to display the correct photo, when calling showPhotoIndex() + * from showImage() + */ + private function getCurrentPage($current, $max) + { + if(isset($this->cfg->thumbs_per_page) && !empty($this->cfg->thumbs_per_page)) { + for($page_start = 0; $page_start <= $max; $page_start+=$this->cfg->thumbs_per_page) { + if($current >= $page_start && $current < ($page_start+$this->cfg->thumbs_per_page)) + return $page_start; + } + } + return 0; + + } // getCurrentPage() + } // class PHPFSPOT ?> |