]> git.wh0rd.org Git - tt-rss.git/commitdiff
search by category (closes #29)
authorAndrew Dolgov <fox@bah.spb.su>
Sat, 25 Feb 2006 19:41:27 +0000 (20:41 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sat, 25 Feb 2006 19:41:27 +0000 (20:41 +0100)
backend.php
tt-rss.php

index 3dda8d0bbe68e6c90a75a7fd7da5c37ef7dda39c..91506880f98022e51d727a7f945e8268e31cd012 100644 (file)
                // override query strategy and enable feed display when searching globally
                if ($search && $search_mode == "All feeds") {
                        $query_strategy_part = "ttrss_entries.id > 0";
-                       $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
+                       $vfeed_query_part = "ttrss_feeds.title AS feed_title,";         
                } else if (sprintf("%d", $feed) == 0) {
                        $query_strategy_part = "ttrss_entries.id > 0";
                        $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
                                id = feed_id) as feed_title,";
+               } else if ($feed >= 0 && $search && $search_mode == "This category") {
+
+                       $vfeed_query_part = "ttrss_feeds.title AS feed_title,";         
+
+                       $tmp_result = db_query($link, "SELECT id 
+                               FROM ttrss_feeds WHERE cat_id = 
+                                       (SELECT cat_id FROM ttrss_feeds WHERE id = '$feed') AND id != '$feed'");
+
+                       $cat_siblings = array();
+
+                       if (db_num_rows($tmp_result) > 0) {
+                               while ($p = db_fetch_assoc($tmp_result)) {
+                                       array_push($cat_siblings, "feed_id = " . $p["id"]);
+                               }
+
+                               $query_strategy_part = sprintf("(feed_id = %d OR %s)", 
+                                       $feed, implode(" OR ", $cat_siblings));
+
+                       } else {
+                               $query_strategy_part = "ttrss_entries.id > 0";
+                       }
+
                } else if ($feed >= 0) {
                
                        $tmp_result = db_query($link, "SELECT id 
 
                                $query_strategy_part = sprintf("(feed_id = %d OR %s)", 
                                        $feed, implode(" OR ", $parent_ids));
-       
+
                                $vfeed_query_part = "ttrss_feeds.title AS feed_title,";
                        } else {
                                $query_strategy_part = "feed_id = '$feed'";
                        } else {
                                print "<option disabled>This feed</option>";
                        }
-                       
+
+                       if (get_pref($link, 'ENABLE_FEED_CATS')) {
+                               print "<option>This category</option>";
+                       }
+
                        print "</select>                
                        <input type=\"submit\" 
                                class=\"button\" onclick=\"javascript:search()\" value=\"Search\">
index 03bbc0f6151f13465e51cabdcf7e830131c57d25..b9c74efc639026a3eb5018878fc4cd26c9e0d907 100644 (file)
@@ -153,10 +153,12 @@ window.onload = init;
                <? if (get_pref($link, 'ENABLE_SEARCH_TOOLBAR')) { ?>
 
                <input id="searchbox"
-                       onblur="javascript:enableHotkeys()" onfocus="javascript:disableHotkeys()"
-                       onchange="javascript:search()">
+                       onblur="javascript:enableHotkeys();" onfocus="javascript:disableHotkeys();">
                <select id="searchmodebox">
                        <option>This feed</option>
+                       <? if (get_pref($link, 'ENABLE_FEED_CATS')) { ?>
+                       <option>This category</option>
+                       <? } ?>
                        <option>All feeds</option>
                </select>