issue46, first slideshow implementation
authorAndreas Unterkircher <unki@netshadow.at>
Fri, 20 Jul 2007 17:59:03 +0000 (17:59 +0000)
committerAndreas Unterkircher <unki@netshadow.at>
Fri, 20 Jul 2007 17:59:03 +0000 (17:59 +0000)
git-svn-id: file:///var/lib/svn/phpfspot/trunk@225 fa6a889d-dae6-447d-9e79-4ba9a3039384

phpfspot.class.php
phpfspot.js
rpc.php
templates/photo_index.tpl
templates/slideshow.tpl [new file with mode: 0644]

index 2c3170c869e7395d5bd64bff9e7965f6d1f8fdfa..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'));
@@ -865,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);
@@ -1651,6 +1657,29 @@ class PHPFSPOT {
       }
 
    } // 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()
 }
 
 ?>
index dff8da9e68c4aa536061b272c9df3f3bfdf4cef6..9e1a932431923d2d9303628d53fc0826da72aecc 100644 (file)
@@ -300,6 +300,19 @@ function preloadPhotos(lbImg) {
    }
 }
 
+function startSlideShow()
+{
+   HTML_AJAX.grab(encodeURI('rpc.php?action=reset_slideshow'));
+   nextSlide();
+}
+
+function nextSlide()
+{
+   next_img = HTML_AJAX.grab(encodeURI('rpc.php?action=get_next_slideshow_img'));
+   document.getElementById('slide_img').src = next_img;
+   setTimeout("nextSlide()", 3000);
+}
+
 var startup = 1;
 var calendar_shown = 0;
 var calendar_mode = '';
diff --git a/rpc.php b/rpc.php
index 937f4323d803d15a03aac5d1d01831cf8ea96172..d7dafce23d68f486a28c34301ba5593471647d9f 100644 (file)
--- a/rpc.php
+++ b/rpc.php
@@ -112,6 +112,14 @@ class PHPFSPOT_RPC {
             print $fspot->whatToDo();
             break;
 
+         case 'reset_slideshow':
+            print $fspot->resetSlideShow();
+            break;
+
+         case 'get_next_slideshow_img':
+            print $fspot->getNextSlideShowImage();
+            break;
+
       }
 
    } // process_ajax_request();
index 1590f857f709b663f96402e2dfaac7e7b0877eda..bc7e5d1a23633e76f42f318c3e31f6f5bfe22585 100644 (file)
@@ -30,6 +30,9 @@
       {/if}
      </td>
      <td class="index_header" style="text-align: right">
+      {if $slideshow_link }
+       <a href="{$slideshow_link}" title="Slideshow" target="_blank">Slideshow</a>
+      {/if}
       {if $extern_link }
        <a href="{$extern_link}" title="Use this link to return to the current view"><img src="resources/link.png" /></a>
       {/if} 
diff --git a/templates/slideshow.tpl b/templates/slideshow.tpl
new file mode 100644 (file)
index 0000000..a41a018
--- /dev/null
@@ -0,0 +1,13 @@
+{include file="header.tpl"}
+ <body onload="startSlideShow();">
+  <div id="frame">
+  <table>
+   <tr>
+    <td>
+     <img id="slide_img" alt="slideshow_img" />
+    </td>
+   </tr>
+  </table>
+  </div>
+ </body>
+{include file="footer.tpl"}