remove the rows x cols logic
[phpfspot.git] / phpfspot.class.php
index f68632184a730dd3b5b4ce90195dcc2187e9be06..cbb6fed1241b72c6edccb63398a4968d48f52450 100644 (file)
@@ -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");