add support to query multiple tags, use "," as a separation character
authorArun Persaud <arun@nubati.net>
Wed, 30 Nov 2011 05:27:26 +0000 (21:27 -0800)
committerArun Persaud <apersaud@lbl.gov>
Wed, 30 Nov 2011 05:27:26 +0000 (21:27 -0800)
.htaccess_template
getjson.php

index 203ba4c08ac114f5eb3efa38d458c4a0af907b85..f5e86c55603a9a29a89aec3c49875396fcbc8eda 100644 (file)
@@ -7,13 +7,13 @@ RewriteBase   /<insert web base url here>
 # make the url nice and clean; the comments shows an url that should be matched
 
 # web_base/tag/me+berlin/pic/id 
 # make the url nice and clean; the comments shows an url that should be matched
 
 # web_base/tag/me+berlin/pic/id 
-RewriteRule tag/([-_a-zA-Z0-9+]*)/pic/([0-9]*) index.php?tag=$1&pic=$2 [L]
+RewriteRule tag/([-_\s,a-zA-Z0-9+]*)/pic/([0-9]*) index.php?tag=$1&pic=$2 [L]
 
 # web_base/tag/tag1+tag2/page/4 
 
 # web_base/tag/tag1+tag2/page/4 
-RewriteRule tag/([-_a-zA-Z0-9+]*)/page/([0-9]*) index.php?tag=$1&page=$2 [L]
+RewriteRule tag/([-_\s,a-zA-Z0-9+]*)/page/([0-9]*) index.php?tag=$1&page=$2 [L]
 
 # web_base/tag/tag1+tag2
 
 # web_base/tag/tag1+tag2
-RewriteRule tag/([-_a-zA-Z0-9+]*) index.php?tag=$1 [L]
+RewriteRule tag/([-_\s,a-zA-Z0-9+]*) index.php?tag=$1 [L]
 
 # web_base/pic/17
 RewriteRule pic/([0-9]*) index.php?pic=$1 [L]
 
 # web_base/pic/17
 RewriteRule pic/([0-9]*) index.php?pic=$1 [L]
index 007ef7c7d181c9f816d57eb2bcc5ab652aee3c9b..97f8c4973acc5d33a7f4cf880ceb0f3ab4f4604d 100644 (file)
@@ -34,11 +34,13 @@ else
     if (isset($_REQUEST["T"]))
       {
        /* single tag or part of tag */
     if (isset($_REQUEST["T"]))
       {
        /* single tag or part of tag */
-       $tags = sqlite_escape_string($_REQUEST["T"]);
-       $tags = explode("+",$tags);
+       $tags = $_REQUEST["T"];
+       $tags = explode(",",$tags);
+       foreach ($tags as $key => $value)
+         $tags[$key]=sqlite_escape_string(trim($value));
        $tags = "'".implode("','",$tags)."'";
 
        $tags = "'".implode("','",$tags)."'";
 
-       /* individual tags are seperated by '+' */
+       /* individual tags are seperated by ',' */
        $result = $DB->query("SELECT base_uri, filename FROM photos ".
                             "    left join photo_tags on photos.id=photo_tags.photo_id ".
                             "    left join tags on tags.id=photo_tags.tag_id ".
        $result = $DB->query("SELECT base_uri, filename FROM photos ".
                             "    left join photo_tags on photos.id=photo_tags.photo_id ".
                             "    left join tags on tags.id=photo_tags.tag_id ".