some cleanup
[phpfspot.git] / phpfspot.class.php
index 168d08134fc5b3461a24b23d222dc47bca7802de..628cfeacba8adec7b5e6e4eabc09f0cc5833c294 100644 (file)
@@ -188,18 +188,25 @@ class PHPFSPOT {
 
    public function getAllTagPhotos()
    {  
-      $selected = "";
-      foreach($_SESSION['selected_tags'] as $tag)
-         $selected.= $tag .",";
-      $selected = substr($selected, 0, strlen($selected)-1);
-
       $tagged_photos = Array();
 
-      $result = $this->db->db_query("
-         SELECT DISTINCT photo_id
-         FROM photo_tags
-         WHERE tag_id IN (". $selected .")
-      ");
+      if(isset($_SESSION['selected_tags'])) {
+         $selected = "";
+         foreach($_SESSION['selected_tags'] as $tag)
+            $selected.= $tag .",";
+         $selected = substr($selected, 0, strlen($selected)-1);
+         $result = $this->db->db_query("
+            SELECT DISTINCT photo_id
+            FROM photo_tags
+            WHERE tag_id IN (". $selected .")
+         ");
+      }
+      else {
+         $result = $this->db->db_query("
+            SELECT DISTINCT photo_id
+            FROM photo_tags
+         ");
+      }
 
       while($row = $this->db->db_fetch_object($result)) {
          array_push($tagged_photos, $row['photo_id']);
@@ -212,12 +219,15 @@ class PHPFSPOT {
 
    public function showPhotoIndex()
    {
-
       foreach($this->getAllTagPhotos() as $photo)
       {
-         print "<img src=\"phpfspot_img.php?idx=". $photo ."&amp;width=". $this->cfg->thumb_width ."\" /><br />\n";
+         $images.= "<img src=\"phpfspot_img.php?idx=". $photo ."&amp;width=". $this->cfg->thumb_width ."\" /><br />\n";
       }
 
+      $this->tmpl->assign('image_matrix', $images);
+      $this->tmpl->show("photo_index.tpl");
+
+
    } // showPhotoIndex()
 
 }