]> git.wh0rd.org Git - tt-rss.git/commitdiff
category search fixes, search dialog now searches in category view
authorAndrew Dolgov <fox@madoka.spb.ru>
Tue, 1 Aug 2006 04:13:48 +0000 (05:13 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Tue, 1 Aug 2006 04:13:48 +0000 (05:13 +0100)
backend.php
feedlist.js
functions.js
functions.php
tt-rss.js

index bd53354f2f35518e54130d652ef5c3db6ce61567..6f4c932fb3eac4497806bb47f091875bcf63de87 100644 (file)
 
                        print "<form id='search_form'>";
 
-                       $active_feed_id = db_escape_string($_GET["param"]);
+                       #$active_feed_id = db_escape_string($_GET["param"]);
+
+                       $params = split(":", db_escape_string($_GET["param"]));
+
+                       $active_feed_id = $params[0];
+                       $is_cat = $params[1] == "true";
 
                        print "<table width='100%'><tr><td>Search:</td><td>";
                        
                                <option value=\"all_feeds\">All feeds</option>";
                        
                        $feed_title = getFeedTitle($link, $active_feed_id);
-                       $feed_cat_title = getFeedCatTitle($link, $active_feed_id);
+
+                       if (!$is_cat) {
+                               $feed_cat_title = getFeedCatTitle($link, $active_feed_id);
+                       } else {
+                               $feed_cat_title = getCategoryTitle($link, $active_feed_id);
+                       }
                        
-                       if ($active_feed_id) {                          
+                       if ($active_feed_id && !$is_cat) {                              
                                print "<option selected value=\"this_feed\">This feed ($feed_title)</option>";
                        } else {
                                print "<option disabled>This feed</option>";
                        }
 
-                       if (get_pref($link, 'ENABLE_FEED_CATS') && $active_feed_id && $active_feed_id > 0) {
-                               print "<option value=\"this_cat\">This category ($feed_cat_title)</option>";
+                       if ($is_cat) {
+                               $cat_preselected = "selected";
+                       }
+
+                       if (get_pref($link, 'ENABLE_FEED_CATS') && $active_feed_id >= 0) {
+                               print "<option $cat_preselected value=\"this_cat\">This category ($feed_cat_title)</option>";
                        } else {
                                print "<option disabled>This category</option>";
                        }
index 97d74ba2b4227e16f107fd3aa4dfeb34e1708fef..dd00c4da9a40d5b39e5c52ba38721a298c7067bf 100644 (file)
@@ -12,7 +12,7 @@ function viewfeed(feed, skip, subop, doc, is_cat, subop_param) {
                if (!doc) doc = parent.document;
        
                enableHotkeys();
-       
+
                var toolbar_query = parent.Form.serialize("main_toolbar_form");
                var toolbar_form = parent.document.forms["main_toolbar_form"];
 
@@ -55,6 +55,8 @@ function viewfeed(feed, skip, subop, doc, is_cat, subop_param) {
 
                setActiveFeedId(feed);
        
+               getMainContext().active_feed_is_cat = is_cat;
+
                if (subop == "MarkAllRead") {
 
                        var feedr = document.getElementById("FEEDR-" + feed);
index 853f36e1928196f68719d0ffe97c910db1c5fffa..64fac613544bf23ab2ee3a200b64be28e26e80fa 100644 (file)
@@ -462,6 +462,10 @@ function getActiveFeedId() {
        }
 }
 
+function activeFeedIsCat() {
+       return getMainContext().active_feed_is_cat;
+}
+
 function setActiveFeedId(id) {
 //     return setCookie("ttrss_vf_actfeed", id);
        try {
index a58613ccb7d63f5fb2bada6d8a04d98d79e7540c..65b374e1b84096100ee3e409afe6d575ef931412 100644 (file)
                                                        OR UPPER(ttrss_entries.content) LIKE UPPER('%$k%'))");
                                        }
 
-                                       $search_query_part = implode("AND", $query_keywords) . "AND";
+                                       $search_query_part = implode("AND", $query_keywords) . " AND ";
 
                                } else if ($match_on == "title") {
 
                                                array_push($query_keywords, "(UPPER(ttrss_entries.title) LIKE UPPER('%$k%'))");
                                        }
 
-                                       $search_query_part = implode("AND", $query_keywords) . "AND";
+                                       $search_query_part = implode("AND", $query_keywords) . " AND ";
 
                                } else if ($match_on == "content") {
 
                                                array_push($query_keywords, "(UPPER(ttrss_entries.content) LIKE UPPER('%$k%'))");
                                        }
 
-                                       $search_query_part = implode("AND", $query_keywords) . "AND";
+                                       $search_query_part = implode("AND", $query_keywords) . " AND ";
                                }
                        } else {
                                $search_query_part = "";
                        } else if ($feed >= 0 && $search && $search_mode == "this_cat") {
        
                                $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'");
+
+                               $tmp_result = false;
+
+                               if ($cat_view) {
+                                       $tmp_result = db_query($link, "SELECT id 
+                                               FROM ttrss_feeds WHERE cat_id = '$feed'");
+                               } else {
+                                       $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();
        
 
        }
 
+       function getCategoryTitle($link, $cat_id) {
+
+               $result = db_query($link, "SELECT title FROM ttrss_feed_categories WHERE
+                       id = '$cat_id'");
+
+               if (db_num_rows($result) == 1) {
+                       return db_fetch_result($result, 0, "title");
+               } else {
+                       return "Uncategorized";
+               }
+       }
+
 ?>
index 0a17c14c3f94937ae9e6eb114e0a3e5083f5c2b3..538e3203cb31ae75a9ae816d05d850b593a902f3 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -12,6 +12,7 @@ var firsttime_update = true;
 var last_refetch = 0;
 var cookie_lifetime = 0;
 var active_feed_id = 0;
+var active_feed_is_cat = false;
 
 var xmlhttp = Ajax.getTransport();
 
@@ -433,7 +434,7 @@ function quickMenuGo(opid) {
                }
        
                if (opid == "qmcSearch") {
-                       displayDlg("search", getActiveFeedId());
+                       displayDlg("search", getActiveFeedId() + ":" + activeFeedIsCat());
                        return;
                }