issue121, show rating value in photo-index- and single-photo-view
authorAndreas Unterkircher <unki@netshadow.at>
Sat, 24 May 2008 07:26:11 +0000 (09:26 +0200)
committerAndreas Unterkircher <unki@netshadow.at>
Sat, 24 May 2008 07:57:13 +0000 (09:57 +0200)
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
phpfspot.class.php
resources/rating.png [new file with mode: 0644]
resources/star.png [new file with mode: 0644]
themes/default/templates/photo_index.tpl
themes/default/templates/single_photo.tpl

index e6c4aff91e8b4f548ede61302c491cca57fa2be3..0711499f3ef113893fe89255225afb5c8baaee11 100644 (file)
@@ -506,6 +506,28 @@ class PHPFSPOT {
 
    } // getPhotoName()
 
+   /**
+    * get photo rating level
+    *
+    * this function will return the integer-based rating
+    * level of the photo. This can only be done, if the F-Spot
+    * database is at a specific level. If rating value can not
+    * be found, zero will be returned indicating no rating value
+    * is available.
+    * @param integer idx
+    * @return integer
+    */
+   public function get_photo_rating($idx)
+   {
+      if($detail = $this->get_photo_details($idx)) {
+         if(isset($detail['rating']))
+            return $detail['rating'];
+      }
+
+      return 0;
+
+   } // get_photo_rating()
+
    /**
     * shrink text according provided limit
     *
@@ -643,6 +665,7 @@ class PHPFSPOT {
 
       $this->tmpl->assign('description', $details['description']);
       $this->tmpl->assign('image_name', $this->parse_uri($details['uri'], 'filename'));
+      $this->tmpl->assign('image_rating', $this->get_photo_rating($photo));
 
       $this->tmpl->assign('width', $info_thumb[0]);
       $this->tmpl->assign('height', $info_thumb[1]);
@@ -1232,6 +1255,7 @@ class PHPFSPOT {
       $img_name[$thumbs] = Array();
       $img_fullname[$thumbs] = Array();
       $img_title = Array();
+      $img_rating = Array();
 
       for($i = $begin_with; $i < $end_with; $i++) {
 
@@ -1242,6 +1266,7 @@ class PHPFSPOT {
             $img_name[$thumbs] = htmlspecialchars($this->getPhotoName($photos[$i], 15));
             $img_fullname[$thumbs] = htmlspecialchars($this->getPhotoName($photos[$i], 0));
             $img_title[$thumbs] = "Click to view photo ". htmlspecialchars($this->getPhotoName($photos[$i], 0));
+            $img_rating[$thumbs] = $this->get_photo_rating($photos[$i]);
 
             $thumb_path = $this->get_thumb_path($this->cfg->thumb_width, $photos[$i]);
 
@@ -1389,6 +1414,7 @@ class PHPFSPOT {
       $this->tmpl->assign('img_name', $img_name);
       $this->tmpl->assign('img_fullname', $img_fullname);
       $this->tmpl->assign('img_title', $img_title);
+      $this->tmpl->assign('img_rating', $img_rating);
       $this->tmpl->assign('thumbs', $thumbs);
       $this->tmpl->assign('selected_tags', $this->getSelectedTags('img'));
 
diff --git a/resources/rating.png b/resources/rating.png
new file mode 100644 (file)
index 0000000..c39b428
Binary files /dev/null and b/resources/rating.png differ
diff --git a/resources/star.png b/resources/star.png
new file mode 100644 (file)
index 0000000..b88c857
Binary files /dev/null and b/resources/star.png differ
index c9da47778b0e8e40b327b693f7679da52fdd7b04..7fe04ab053e00c788340269aa0ab6c88b256cf55 100644 (file)
      <br />
     {$img_name[thumb]}
     </a>
+    <!-- show lightbox eyes, if enabled -->
     { if $use_lightbox }
     <a href="{$web_path}/phpfspot_img.php?idx={$images[thumb]}&amp;width={$preview_width}" alt="thumb_{$images[thumb]}" rel="lightbox[photoidx]" title="Preview of {$img_fullname[thumb]}"><img src="{$web_path}/resources/eyes.png" /></a>
     { /if }
+    <!-- show F-Spot photo rating value, if available -->
+    { if $img_rating[thumb] }
+     <br />
+     {section name="rating" loop=$img_rating[thumb] step=1}
+      <img src="{$web_path}/resources/star.png" />
+     {/section}
+    { /if }
    </div>
 
   {/if}
index 97ef0cfe16dfaef8b12e6ea12ce8f20c27a931a9..b1415178135ad4114d0c5be3890d40d26254cd29 100644 (file)
    {$ExifOrigResolution}<br />
    { /if }
    <u>Size:</u>&nbsp;{$ExifFileSize}<br />
+   { if $image_rating }
+    <u><img src="{$web_path}/resources/rating.png" alt="rating" />&nbsp;Rating:</u><br />
+    {section name="rating" loop=$image_rating step=1}
+     <img src="{$web_path}/resources/star.png" />
+    {/section}
+    <br />
+   { /if }
    { if $tags }
     <br />
     <u><img src="{$web_path}/resources/small_available_tags.png" alt="available tags" />&nbsp;Tagged with:</u><br />