]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Fix bug #2887063: Common tag combination description feels broken
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Sat, 16 Jan 2010 11:16:43 +0000 (11:16 +0000)
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Sat, 16 Jan 2010 11:16:43 +0000 (11:16 +0000)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@598 b3834d28-1941-0410-a4f8-b48e95affb8f

doc/ChangeLog
src/SemanticScuttle/Service/CommonDescription.php

index 4b1c30b29c1b0a5320e0acc4b9e7d44a7edb9c9c..3ea4b8a2431fd1938a1c625f7c8bc8536fb4c213 100644 (file)
@@ -9,6 +9,8 @@ ChangeLog for SemantiScuttle
   - Fix HTTP content type header for RSS
   - Add config option to allow sorting by bookmark creation date
     instead of modification date
+- Fix bug #2887063: Common tag combination description feels broken
+
 
 0.95.1 - 2009-11-16
 -------------------
index 8acd2546564ee762aeaa097a2d65cba96b1037aa..39c5826bfb57f2e35bc7cdb7c3c650ef0d989203 100644 (file)
@@ -49,6 +49,8 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic
     }
 
     function addTagDescription($tag, $desc, $uId, $time) {
+        $tag = self::getSortedTag($tag);
+
         // Check if no modification
         $lastDesc = $this->getLastTagDescription($tag);
         if($lastDesc['cdDescription'] == $desc) {
@@ -70,6 +72,8 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic
     }
 
     function getLastTagDescription($tag) {
+        $tag = self::getSortedTag($tag);
+
         $query = "SELECT *";
         $query.= " FROM `". $this->getTableName() ."`";
         $query.= " WHERE tag='".$tag."'";
@@ -200,5 +204,26 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic
         $this->db->sql_query($query);
     }
 
+
+
+    /**
+     * Sorts a tag combination.
+     *
+     * Multiple tags are separated by "+" signs. Semantically,
+     * tag combinations like "blue+flower" and "flower+blue" are identical.
+     * This method sorts the single tags so i.e. the common bookmark description
+     * of "blue+flower" is also shown for "flower+blue".
+     *
+     * @param string $tag Single tag or tag combination ("+")
+     *
+     * @return string Sorted tag combination
+     */
+    protected static function getSortedTag($tag)
+    {
+        $tags = explode('+', $tag);
+        sort($tags);
+        return implode('+', $tags);
+    }
+
 }
 ?>