issue46, slideshow control (rew, pause/play/stop, fwd)
authorAndreas Unterkircher <unki@netshadow.at>
Sun, 22 Jul 2007 07:31:40 +0000 (07:31 +0000)
committerAndreas Unterkircher <unki@netshadow.at>
Sun, 22 Jul 2007 07:31:40 +0000 (07:31 +0000)
git-svn-id: file:///var/lib/svn/phpfspot/trunk@239 fa6a889d-dae6-447d-9e79-4ba9a3039384

phpfspot.class.php
phpfspot.js
resources/32_fwd.png [new file with mode: 0644]
resources/32_rew.png [new file with mode: 0644]
resources/32_stop.png [new file with mode: 0644]
rpc.php
themes/default/templates/slideshow.tpl

index 825f92d098d55a8e602ee8c16bd5cf027ac89b31..2a2813545045235f2503eeeb7455efe4a14bdf91 100644 (file)
@@ -105,6 +105,7 @@ class PHPFSPOT {
       $this->tmpl->assign('searchfor', $_SESSION['searchfor']);
       $this->tmpl->assign('page_title', $this->cfg->page_title);
       $this->tmpl->assign('current_condition', $_SESSION['tag_condition']);
+      $this->tmpl->assign('template_path', 'themes/'. $this->cfg->theme_name);
 
       $_SESSION['start_action'] = $_GET['mode'];
 
@@ -150,7 +151,6 @@ class PHPFSPOT {
       $this->tmpl->assign('to_date', $this->get_calendar('to'));
       $this->tmpl->assign('sort_field', $this->get_sort_field());
       $this->tmpl->assign('content_page', 'welcome.tpl');
-      $this->tmpl->assign('template_path', 'themes/'. $this->cfg->theme_name);
       $this->tmpl->show("index.tpl");
 
 
@@ -1666,6 +1666,12 @@ class PHPFSPOT {
 
    } // get_sort_order()
 
+   /***
+     * return the next to be shown slide show image
+     *
+     * this function returns the URL of the next image
+     * in the slideshow sequence.
+     */
    public function getNextSlideShowImage()
    {
       $all_photos = $this->getPhotoSelection();
@@ -1683,6 +1689,29 @@ class PHPFSPOT {
 
    } // getNextSlideShowImage()
 
+   /***
+     * return the previous to be shown slide show image
+     *
+     * this function returns the URL of the previous image
+     * in the slideshow sequence.
+     */
+   public function getPrevSlideShowImage()
+   {
+      $all_photos = $this->getPhotoSelection();
+
+      if(!isset($_SESSION['slideshow_img']) || $_SESSION['slideshow_img'] == 0)
+         $_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;
+
+   } // getPrevSlideShowImage()
+
    public function resetSlideShow()
    {
       if(isset($_SESSION['slideshow_img']))
index 6bc0d2c96be4857ad1c8859a6286c832f640a1fb..1e074bb83397305805048f3dd078ed467519e801 100644 (file)
@@ -302,9 +302,17 @@ function preloadPhotos(lbImg) {
 
 function startSlideShow()
 {
-   HTML_AJAX.grab(encodeURI('rpc.php?action=reset_slideshow'));
-   nextSlide();
-   setInterval("nextSlide()", 3000);
+   if(!sliding) {
+      HTML_AJAX.grab(encodeURI('rpc.php?action=reset_slideshow'));
+      nextSlide();
+      sliding = setInterval("nextSlide()", 3000);
+      document.getElementById('stop_ico').src = "resources/32_stop.png";
+   }
+   else {
+      clearInterval(sliding);
+      sliding = 0;
+      document.getElementById('stop_ico').src = "resources/32_play.png";
+   }
 }
 
 function nextSlide()
@@ -313,6 +321,26 @@ function nextSlide()
    document.getElementById('slide_img').src = next_img;
 }
 
+function prevSlide()
+{
+   prev_img = HTML_AJAX.grab(encodeURI('rpc.php?action=get_prev_slideshow_img'));
+   document.getElementById('slide_img').src = prev_img;
+}
+
+function pauseSlideShow()
+{
+   if(!sliding_paused) {
+      sliding_paused = 1;
+      clearInterval(sliding);
+      document.getElementById('pause_ico').src = "resources/32_play.png";
+   }
+   else {
+      sliding_paused = 0;
+      sliding = setInterval("nextSlide()", 3000);
+      document.getElementById('pause_ico').src = "resources/32_pause.png";
+   }
+} 
+
 function startAutoBrowse()
 {
    if(!autobrowse) {
@@ -339,3 +367,5 @@ var startup = 1;
 var calendar_shown = 0;
 var calendar_mode = '';
 var autobrowse = 0;
+var sliding = 0;
+var sliding_paused = 0;
diff --git a/resources/32_fwd.png b/resources/32_fwd.png
new file mode 100644 (file)
index 0000000..128920e
Binary files /dev/null and b/resources/32_fwd.png differ
diff --git a/resources/32_rew.png b/resources/32_rew.png
new file mode 100644 (file)
index 0000000..d94192d
Binary files /dev/null and b/resources/32_rew.png differ
diff --git a/resources/32_stop.png b/resources/32_stop.png
new file mode 100644 (file)
index 0000000..4d88e48
Binary files /dev/null and b/resources/32_stop.png differ
diff --git a/rpc.php b/rpc.php
index d5a7e8f09c237b2c71d6e472abb5565a48d757d8..b691bd8908abdaa287928a4018fa4ce889c9a4fa 100644 (file)
--- a/rpc.php
+++ b/rpc.php
@@ -121,6 +121,10 @@ class PHPFSPOT_RPC {
          case 'get_next_slideshow_img':
             print $fspot->getNextSlideShowImage();
             break;
+         
+         case 'get_prev_slideshow_img':
+            print $fspot->getPrevSlideShowImage();
+            break;
 
       }
 
index bba5cd20393af52eb988bd7ef1ebf74d29256638..3d0ab27ce15cd9e5901beec2481130cd37941505 100644 (file)
@@ -5,5 +5,11 @@
     <img id="slide_img" alt="slideshow_img" />
    </a>
   </div>
+  <div style="margin: 0 auto; padding: 10px;">
+   <a href="javascript:prevSlide();" onclick="click(this);" title="slive to previous photo"><img id="rew_ico" src="resources/32_rew.png" /></a>
+   <a href="javascript:pauseSlideShow();" onclick="click(this);"><img id="pause_ico" src="resources/32_pause.png" /></a>
+   <a href="javascript:startSlideShow();" onclick="click(this);" title="stop and revert slideshow"><img id="stop_ico" src="resources/32_stop.png" /></a>
+   <a href="javascript:nextSlide();" onclick="click(this);" title="slide to next photo"><img id="fwd_ico" src="resources/32_fwd.png" /></a>
+  </div>
  </body>
 {include file="footer.tpl"}