From: Andreas Unterkircher Date: Fri, 23 May 2008 18:05:38 +0000 (+0200) Subject: issue121, initial support for F-Spot's rating system and sort-by rating X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=phpfspot.git;a=commitdiff_plain;h=aab7d4d07c16dc78a6d2a41223d469a1a60e5022 issue121, initial support for F-Spot's rating system and sort-by rating Signed-off-by: Andreas Unterkircher --- diff --git a/CHANGELOG b/CHANGELOG index c0befcb..e6fee40 100644 --- 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. diff --git a/phpfspot.class.php b/phpfspot.class.php index 1d20ab1..e6c4aff 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -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 ↑', + 'rate_desc' => 'Rate ↓', + )); + } + /* 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()