summaryrefslogtreecommitdiffstats
path: root/phpfspot.class.php
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2008-01-06 12:01:32 +0100
committerAndreas Unterkircher <unki@netshadow.at>2008-01-06 12:01:32 +0100
commite54e729719c29d263c140d91fd3b93167ceb188e (patch)
treecefad4864efb7b8807a9dbe52132f1fb86516a66 /phpfspot.class.php
parent7eaf3d147420cb0a99296bafe91ac62be0700dcb (diff)
remove the rows x cols logic
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
Diffstat (limited to 'phpfspot.class.php')
-rw-r--r--phpfspot.class.php74
1 files changed, 24 insertions, 50 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index f686321..cbb6fed 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -112,8 +112,8 @@ 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)
+ // if begin_with is still set but thumbs_per_page is now 0, unset it
+ if(isset($_SESSION['begin_with']) && $this->cfg->thumbs_per_page == 0)
unset($_SESSION['begin_with']);
} // __construct()
@@ -906,79 +906,54 @@ class PHPFSPOT {
if(isset($_SESSION['begin_with']) && $_SESSION['begin_with'] != "")
$anchor = $_SESSION['begin_with'];
- if(!isset($this->cfg->rows_per_page) || $this->cfg->rows_per_page == 0) {
+ if(!isset($this->cfg->thumbs_per_page) || $this->cfg->thumbs_per_page == 0) {
$begin_with = 0;
$end_with = $count;
}
- elseif($this->cfg->rows_per_page > 0) {
+ elseif($this->cfg->thumbs_per_page > 0) {
if(!isset($_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);
+ $end_with = $begin_with + $this->cfg->thumbs_per_page;
}
-
- $rows = 0;
- $cols = 0;
- $images[$rows] = Array();
- $img_height[$rows] = Array();
- $img_width[$rows] = Array();
- $img_id[$rows] = Array();
- $img_name[$rows] = Array();
+ $thumbs = 0;
+ $images[$thumbs] = Array();
+ $img_height[$thumbs] = Array();
+ $img_width[$thumbs] = Array();
+ $img_id[$thumbs] = Array();
+ $img_name[$thumbs] = Array();
$img_title = Array();
for($i = $begin_with; $i < $end_with; $i++) {
if(isset($photos[$i])) {
- $images[$rows][$cols] = $photos[$i];
- $img_id[$rows][$cols] = $i;
- $img_name[$rows][$cols] = htmlspecialchars($this->getPhotoName($photos[$i], 15));
- $img_title[$rows][$cols] = "Click to view photo ". htmlspecialchars($this->getPhotoName($photos[$i], 0));
+ $images[$thumbs] = $photos[$i];
+ $img_id[$thumbs] = $i;
+ $img_name[$thumbs] = htmlspecialchars($this->getPhotoName($photos[$i], 15));
+ $img_title[$thumbs] = "Click to view photo ". htmlspecialchars($this->getPhotoName($photos[$i], 0));
$thumb_path = $this->get_thumb_path($this->cfg->thumb_width, $photos[$i]);
if(file_exists($thumb_path)) {
$info = getimagesize($thumb_path);
- $img_width[$rows][$cols] = $info[0];
- $img_height[$rows][$cols] = $info[1];
- }
-
- if($cols == $this->cfg->thumbs_per_row-1) {
- $cols = 0;
- $rows++;
- $images[$rows] = Array();
- $img_width[$rows] = Array();
- $img_height[$rows] = Array();
- }
- else {
- $cols++;
+ $img_width[$thumbs] = $info[0];
+ $img_height[$thumbs] = $info[1];
}
+ $thumbs++;
}
}
// +1 for for smarty's selection iteration
- $rows++;
+ $thumbs++;
if(isset($_SESSION['searchfor']) && $_SESSION['searchfor'] != '')
$this->tmpl->assign('searchfor', $_SESSION['searchfor']);
@@ -993,20 +968,20 @@ class PHPFSPOT {
}
/* do we have to display the page selector ? */
- if($this->cfg->rows_per_page != 0) {
+ if($this->cfg->thumbs_per_page != 0) {
$page_select = "";
/* calculate the page switchers */
- $previous_start = $begin_with - ($this->cfg->rows_per_page * $this->cfg->thumbs_per_row);
- $next_start = $begin_with + ($this->cfg->rows_per_page * $this->cfg->thumbs_per_row);
+ $previous_start = $begin_with - $this->cfg->thumbs_per_page;
+ $next_start = $begin_with + $this->cfg->thumbs_per_page;
if($begin_with != 0)
$this->tmpl->assign("previous_url", "javascript:showPhotoIndex(". $previous_start .");");
if($end_with < $count)
$this->tmpl->assign("next_url", "javascript:showPhotoIndex(". $next_start .");");
- $photo_per_page = $this->cfg->rows_per_page * $this->cfg->thumbs_per_row;
+ $photo_per_page = $this->cfg->thumbs_per_page;
$last_page = ceil($count / $photo_per_page);
/* get the current selected page */
@@ -1102,8 +1077,7 @@ class PHPFSPOT {
$this->tmpl->assign('img_id', $img_id);
$this->tmpl->assign('img_name', $img_name);
$this->tmpl->assign('img_title', $img_title);
- $this->tmpl->assign('rows', $rows);
- $this->tmpl->assign('columns', $this->cfg->thumbs_per_row);
+ $this->tmpl->assign('thumbs', $thumbs);
$this->tmpl->show("photo_index.tpl");