X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=phpfspot.git;a=blobdiff_plain;f=phpfspot.class.php;h=f1b0dc64dbf53702ab52e10c15a6b698dbfb1ca2;hp=85d276e104d29a09a792cae3b5f59d004f83017c;hb=9db171ee763fbf5ba6d7f5cebd565e14d55b4ce0;hpb=b8e94789af7969321cd895d1cef5d175074afcbb
diff --git a/phpfspot.class.php b/phpfspot.class.php
index 85d276e..f1b0dc6 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -503,7 +503,8 @@ 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_page', $this->getCurrentPage($current, $count));
+ $this->tmpl->assign('current_img', $photo);
if($previous_img) {
$this->tmpl->assign('previous_url', "javascript:showImage(". $previous_img .");");
@@ -520,8 +521,6 @@ class PHPFSPOT {
$this->tmpl->show("single_photo.tpl");
- print "\n";
-
} // showPhoto()
/**
@@ -954,15 +953,12 @@ class PHPFSPOT {
$count = count($photos);
- 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) {
@@ -1132,8 +1128,14 @@ class PHPFSPOT {
$this->tmpl->show("photo_index.tpl");
- if(isset($anchor))
- print "\n";
+ /* if we are returning to photo index from an photo-view,
+ scroll the window to the last shown photo-thumbnail.
+ after this, unset the last_photo session variable.
+ */
+ if(isset($_SESSION['last_photo'])) {
+ print "\n";
+ unset($_SESSION['last_photo']);
+ }
} // showPhotoIndex()
@@ -2466,6 +2468,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
?>