summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2008-01-18 20:26:23 +0100
committerAndreas Unterkircher <unki@netshadow.at>2008-01-18 20:26:23 +0100
commit1b98418fc7f31d2d10364a60bc798ee85ef7add1 (patch)
tree8aa76638f1487112625f8617ae823e23caa86dcb
parent6dfc3761155121a3f63ef41e048dedf05b170eff (diff)
issue103, ensure showPhotoIndex() returns to the right page
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
-rw-r--r--phpfspot.class.php27
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
?>