reusable single photo function
[phpfspot.git] / phpfspot.class.php
index 1dd3b9369e33f87d377c83fb2a624fd863ce1072..1a344f465e66bd1b75b01a3a138e03bf59b1c4bb 100644 (file)
@@ -20,7 +20,7 @@ class PHPFSPOT {
       $this->cfg = new PHPFSPOT_CFG;
 
       $this->db = new PHPFSPOT_DB(&$this, $this->cfg->db);
-      $this->tmpl = new PHPFSPOT_TMPL(&$this);
+      $this->tmpl = new PHPFSPOT_TMPL($this);
 
       $this->get_tags();
       $this->get_photos();
@@ -37,18 +37,8 @@ class PHPFSPOT {
 
    public function show()
    {
-      if(isset($this->current_photo)) {
-         $this->tmpl->assign('image_url', 'phpfspot_img.php?idx='. $this->avail_photos[$this->current_photo] ."&width=". $this->cfg->photo_width);
-      }
-
-      if($this->current_photo > 0) {
-         $this->tmpl->assign('previous_url', "javascript:showImage(". ($this->current_photo-1) .");");
-      }
-
-      if($this->current_photo < count($this->avail_photos)) {
-         $this->tmpl->assign('next_url', "javascript:showImage(". ($this->current_photo+1) .");");
-      }
 
+      $this->prepare_single_photo($this->current_photo);
       $this->tmpl->assign('tags', $this->tags);
       $this->tmpl->show("index.tpl");
 
@@ -119,6 +109,22 @@ class PHPFSPOT {
 
    } // translate_path
 
+   public function prepare_single_photo($photo)
+   {
+      if(isset($photo)) {
+         $this->tmpl->assign('image_url', 'phpfspot_img.php?idx='. $this->avail_photos[$photo] ."&amp;width=". $this->cfg->photo_width);
+      }
+
+      if($photo > 0) {
+         $this->tmpl->assign('previous_url', "javascript:showImage(". ($photo-1) .");");
+      }
+
+      if($photo < count($this->avail_photos)) {
+         $this->tmpl->assign('next_url', "javascript:showImage(". ($photo+1) .");");
+      }
+
+   } // prepare_single_photo()
+
 }
 
 ?>