]> git.wh0rd.org Git - tt-rss.git/commitdiff
filter prefs: add search
authorAndrew Dolgov <fox@bah.spb.su>
Sat, 17 May 2008 02:52:46 +0000 (03:52 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sat, 17 May 2008 02:52:46 +0000 (03:52 +0100)
modules/pref-filters.php
prefs.js

index 18c78da6cd3b9d63d4e2488f54655365692a784d..ac71c96a2549e79bdce3b2b39c9daa9b8688dbaf 100644 (file)
                        $filter_types[$line["id"]] = $line["description"];
                }
 
-               print "<a class='helpLinkPic' href=\"javascript:displayHelpInfobox(2)\">
-                       <img src='images/sign_quest.gif'></a>";
+
+               $filter_search = db_escape_string($_GET["search"]);
+
+               if (array_key_exists("search", $_GET)) {
+                       $_SESSION["prefs_filter_search"] = $filter_search;
+               } else {
+                       $filter_search = $_SESSION["prefs_filter_search"];
+               }
+
+               print "<div class=\"feedEditSearch\">
+                       <input id=\"filter_search\" size=\"20\" type=\"search\"
+                               onchange=\"javascript:updateFilterList()\" value=\"$filter_search\">
+                       <input type=\"submit\" class=\"button\" 
+                       onclick=\"javascript:updateFilterList()\" value=\"".__('Search')."\">&nbsp<a class='helpLinkPic' href=\"javascript:displayHelpInfobox(2)\">
+                       <img src='images/sign_quest.gif'></a>
+                       </div>";
+
 
                print "<input type=\"submit\" 
                        class=\"button\" 
                        onclick=\"rescore_all_feeds()\" 
                        value=\"".__('Rescore articles')."\">"; 
 
+               if ($filter_search) {
+                       $filter_search = db_escape_string($filter_search);
+                       $filter_search_query = "(
+                               ttrss_filter_actions.description LIKE '%$filter_search%' OR 
+                               reg_exp LIKE '%$filter_search%' OR 
+                               ttrss_feeds.title LIKE '%$filter_search%' OR
+                               ttrss_filter_types.description LIKE '%$filter_search%') AND";
+               } else {
+                       $filter_search_query = "";
+               }
+
                $result = db_query($link, "SELECT 
                                ttrss_filters.id AS id,reg_exp,
                                ttrss_filter_types.name AS filter_type_name,
                                        ttrss_feeds ON (ttrss_filters.feed_id = ttrss_feeds.id)
                        WHERE
                                filter_type = ttrss_filter_types.id AND
+                               $filter_search_query
                                ttrss_filter_actions.id = action_id AND
                                ttrss_filters.owner_uid = ".$_SESSION["uid"]."
                        ORDER by action_description, $sort");
                        }
        
                        if ($lnum == 0) {
-                               print "<tr><td colspan=\"4\" align=\"center\">".__('No filters defined.')."</td></tr>";
+                               print "<tr><td colspan=\"4\" align=\"center\">";
+                               if (!$filter_search) {
+                                       print __('No filters defined.');
+                               } else {
+                                       print __('No matching filters found.');
+                               }
+                                       
+                               print "</td></tr>";
                        }
        
                        print "</table>";
 
                } else {
 
-                       print "<p>".__('No filters defined.')."</p>";
+                       print "<p>";
+
+                       if (!$filter_search) {
+                               print __('No filters defined.');
+                       } else {
+                               print __('No matching filters found.');
+                       }
+
+                       print "</p>";
 
                }
        }
index 78ec548a949ff4f647be1c130dcf541d4be22df2..b207ba2d5e420fa0c5ac0c1f75eb4cb7d5c3ebdc 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -1228,8 +1228,13 @@ function updateFilterList(sort_key) {
                return
        }
 
+       var filter_search = document.getElementById("filter_search");
+       var search = "";
+       if (filter_search) { search = filter_search.value; }
+
        xmlhttp.open("GET", "backend.php?op=pref-filters&sort=" + 
-               param_escape(sort_key), true);
+               param_escape(sort_key) + 
+               "&search=" + param_escape(search), true);
        xmlhttp.onreadystatechange=filterlist_callback;
        xmlhttp.send(null);