issue121, initial support for F-Spot's rating system and sort-by rating
authorAndreas Unterkircher <unki@netshadow.at>
Fri, 23 May 2008 18:05:38 +0000 (20:05 +0200)
committerAndreas Unterkircher <unki@netshadow.at>
Sat, 24 May 2008 07:57:08 +0000 (09:57 +0200)
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
CHANGELOG
phpfspot.class.php

index c0befcba97b4d29727c15fb8bcfdfa9e9d5e59e0..e6fee40125bb562252a1685543684f5b8d3af69d 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@ phpfspot (1.5)
   * feature, display tag-selection with preview-icons in photo index.
   * feature, support for Nikon's NEF RAW photo format (via dcraw and ImageMagick).
   * feature, auto-scroll in photo index if thumbnails are out of sight.
+  * feature, support F-Spot's rating values.
   * bug, if tag added to hide-tags, don't show up in photo-details box (single-photo).
   * bug, if tag added to hide-tags, don't allow adding to selected-tags list.
   * bug, if tag added to hide-tags, random-photo needs to take care of it.
index 1d20ab19e3e17a140313a0a433bf6b4f4204d9f6..e6c4aff91e8b4f548ede61302c491cca57fa2be3 100644 (file)
@@ -157,6 +157,7 @@ class PHPFSPOT {
          ");
       }
 
+      /* get F-Spot database version */
       $this->dbver = $this->getFspotDBVersion();
 
       if(!is_writeable($this->cfg->base_path ."/templates_c")) {
@@ -203,6 +204,14 @@ class PHPFSPOT {
 
       $this->tmpl->assign('web_path', $this->cfg->web_path);
 
+      /* Starting with F-Spot 0.4.2, the rating-feature was available */
+      if($this->dbver > 10) {
+         $this->sort_orders = array_merge($this->sort_orders, array(
+            'rate_asc' => 'Rate &uarr;',
+            'rate_desc' => 'Rate &darr;',
+         ));
+      }
+
       /* check if all necessary indices exist */
       $this->checkDbIndices();
 
@@ -425,10 +434,19 @@ class PHPFSPOT {
          ";
       }
       else {
-         $query_str = "
-            SELECT p.id, p.uri, p.time, p.description
-            FROM photos p
-         ";
+         /* till F-Spot version 0.4.1 */
+         if($this->dbver < 11) {
+            $query_str = "
+               SELECT p.id, p.uri, p.time, p.description
+               FROM photos p
+            ";
+         }
+         else {
+            $query_str = "
+               SELECT p.id, p.uri, p.time, p.description, p.rating
+               FROM photos p
+            ";
+         }
       }
 
       /* if show_tags is set, only return details for photos which
@@ -2538,6 +2556,12 @@ class PHPFSPOT {
          case 'tags_desc':
             return " ORDER BY t.name DESC ,p.time ASC";
             break;
+         case 'rate_asc':
+            return " ORDER BY t.name ASC, p.rating ASC";
+            break;
+         case 'rate_desc':
+            return " ORDER BY t.name DESC, p.rating DESC";
+            break;
       }
 
    } // get_sort_order()