issue46, first slideshow implementation
[phpfspot.git] / phpfspot.class.php
index f572759ed1262c8d98d01ef61ed009168b0f696f..25d144c2dcbe255b0cd7270b1090b13946d1c8a2 100644 (file)
@@ -135,6 +135,10 @@ class PHPFSPOT {
             $this->tmpl->show("export.tpl");
             return;
             break;
+         case 'slideshow':
+            $this->tmpl->show("slideshow.tpl");
+            return;
+            break;
       }
 
       $this->tmpl->assign('from_date', $this->get_calendar('from'));
@@ -636,6 +640,10 @@ class PHPFSPOT {
                      ON pt1.photo_id=pt". ($i+2) .".photo_id
                ";
             }
+            $query_str.= "
+               INNER JOIN photos p
+                  ON pt1.photo_id=p.id
+            ";
             $query_str.= "WHERE pt1.tag_id=". $_SESSION['selected_tags'][0];
             for($i = 1; $i < count($_SESSION['selected_tags']); $i++) {
                $query_str.= "
@@ -861,8 +869,10 @@ class PHPFSPOT {
       }
 
       $export_link = "index.php?mode=export";
+      $slideshow_link = "index.php?mode=slideshow";
 
       $this->tmpl->assign('extern_link', $extern_link);
+      $this->tmpl->assign('slideshow_link', $slideshow_link);
       $this->tmpl->assign('export_link', $export_link);
       $this->tmpl->assign('count', $count);
       $this->tmpl->assign('width', $this->cfg->thumb_width);
@@ -1633,22 +1643,43 @@ class PHPFSPOT {
    {
       switch($_SESSION['sort_order']) {
          case 'date_asc':
-            return "ORDER BY p.time ASC";
+            return " ORDER BY p.time ASC";
             break;
          case 'date_desc':
-            return "ORDER BY p.time DESC";
+            return " ORDER BY p.time DESC";
             break;
          case 'name_asc':
-            return "ORDER BY p.name ASC";
+            return " ORDER BY p.name ASC";
             break;
          case 'name_desc':
-            return "ORDER BY p.name DESC";
+            return " ORDER BY p.name DESC";
             break;
       }
 
-      return $_SESSION['sort_order'];
-
    } // get_sort_order()
+
+   public function getNextSlideShowImage()
+   {
+      $all_photos = $this->getPhotoSelection();
+
+      if(!isset($_SESSION['slideshow_img']) || $_SESSION['slideshow_img'] == count($all_photos)-1) 
+         $_SESSION['slideshow_img'] = 0;
+      else
+         $_SESSION['slideshow_img']++;
+
+      $server_name = $_SERVER['SERVER_NAME'];
+      if(!isset($_SERVER['HTTPS'])) $protocol = "http";
+      else $protocol = "https";
+
+      return $protocol ."://". $server_name . $this->cfg->web_path ."phpfspot_img.php?idx=". $all_photos[$_SESSION['slideshow_img']] ."&width=". $this->cfg->photo_width;
+
+   } // getNextSlideShowImage()
+
+   public function resetSlideShow()
+   {
+      if(isset($_SESSION['slideshow_img']))
+         unset($_SESSION['slideshow_img']);
+   } // resetSlideShow()
 }
 
 ?>