From 5d397db3e6ff4dc02bf989bb64945e990d2c9da2 Mon Sep 17 00:00:00 2001 From: Andreas Unterkircher Date: Sun, 1 Jul 2007 10:12:10 +0000 Subject: issue20, jumping back to the right multipage is now possible git-svn-id: file:///var/lib/svn/phpfspot/trunk@155 fa6a889d-dae6-447d-9e79-4ba9a3039384 --- phpfspot.class.php | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) (limited to 'phpfspot.class.php') diff --git a/phpfspot.class.php b/phpfspot.class.php index f0e2fb2..980dc81 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -39,6 +39,10 @@ class PHPFSPOT { if(!isset($_SESSION['searchfor'])) $_SESSION['searchfor'] = ''; + // if begin_with is still set but rows_per_page is now 0, unset it + if(isset($_SESSION['begin_with']) && $this->cfg->rows_per_page == 0) + unset($_SESSION['begin_with']); + } // __construct() public function __destruct() @@ -117,19 +121,24 @@ class PHPFSPOT { public function showPhoto($photo) { $all_photos = $this->getPhotoSelection(); + $count = count($all_photos); - foreach($all_photos as $all_photo) { + for($i = 0; $i < $count; $i++) { if($get_next) { - $next_img = $all_photo; + $next_img = $all_photos[$i]; break; } - if($all_photo == $photo) { + if($all_photos[$i] == $photo) { $get_next = 1; } else { - $previous_img = $all_photo; + $previous_img = $all_photos[$i]; + } + + if($photo == $all_photos[$i]) { + $current = $i; } } @@ -175,6 +184,7 @@ class PHPFSPOT { $this->tmpl->assign('image_url_full', 'phpfspot_img.php?idx='. $photo); $this->tmpl->assign('tags', $this->get_photo_tags($photo)); + $this->tmpl->assign('current', $current); } else { $this->_warning("Can't open file ". $thumb_path ."\n"); @@ -389,15 +399,35 @@ class PHPFSPOT { $count = count($photos); - if(!$_SESSION['begin_with'] || $_SESSION['begin_with'] == 0) - $begin_with = 0; - else - $begin_with = $_SESSION['begin_with']; + if(!isset($this->cfg->rows_per_page) || $this->cfg->rows_per_page == 0) { - if($this->cfg->rows_per_page == 0) + $begin_with = 0; $end_with = $count; - else + + } + elseif($this->cfg->rows_per_page > 0) { + + if(!$_SESSION['begin_with'] || $_SESSION['begin_with'] == 0) + $begin_with = 0; + else { + + $begin_with = $_SESSION['begin_with']; + + // verify $begin_with - perhaps the thumbs-per-rows or + // rows-per-page variables have changed or the jump back + // from a photo wasn't exact - so calculate the real new + // starting point + $multiplicator = $this->cfg->rows_per_page * $this->cfg->thumbs_per_row; + for($i = 0; $i <= $count; $i+=$multiplicator) { + if($begin_with >= $i && $begin_with < $i+$multiplicator) { + $begin_with = $i; + break; + } + } + } + $end_with = $begin_with + ($this->cfg->rows_per_page * $this->cfg->thumbs_per_row); + } $rows = 0; -- cgit v1.2.3-18-g5258