]> git.wh0rd.org Git - tt-rss.git/commitdiff
feed browser: search
authorAndrew Dolgov <fox@bah.spb.su>
Tue, 20 Jan 2009 09:43:45 +0000 (10:43 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Tue, 20 Jan 2009 09:43:45 +0000 (10:43 +0100)
modules/pref-feed-browser.php
prefs.js

index 91df4264ca0c93b0e66a7421bb5738e21cd53b89..b73516ef8f81fd13d1568eb47e9cf00e617470bd 100644 (file)
 
                $limit = db_escape_string($_GET["limit"]);
 
+               $browser_search = db_escape_string($_GET["search"]);
+
+               if (array_key_exists("search", $_GET)) {
+                       $_SESSION["prefs_browser_search"] = $browser_search;
+               } else {
+                       $browser_search = $_SESSION["prefs_browser_search"];
+               }
+
                if (!$limit) $limit = 25;
 
                $owner_uid = $_SESSION["uid"];
 
                print "<div class=\"insensitive\">".__('This panel shows feeds subscribed by other users of this system, just in case you are interested in them too.')."</div>";
 
-
-               $result = db_query($link, "SELECT feed_url, subscribers FROM
-                       ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
-                       WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url 
-                       AND owner_uid = '$owner_uid') ORDER BY subscribers DESC LIMIT $limit");
-
+               print "<p>
+                       <input id=\"feed_browser_search\" size=\"20\" type=\"search\"
+                               onfocus=\"javascript:disableHotkeys();\" 
+                               onblur=\"javascript:enableHotkeys();\"
+                               onchange=\"javascript:updateBigFeedBrowserBtn()\" value=\"$browser_search\">
+                       <input type=\"submit\" class=\"button\" 
+                               onclick=\"javascript:updateBigFeedBrowserBtn()\" value=\"".__('Search')."\">
+                       </p>";
+
+               if ($browser_search) {
+                       $search_qpart = " AND (
+                               UPPER(ttrss_feedbrowser_cache.feed_url) LIKE UPPER('%$browser_search%') OR 
+                               UPPER(title) LIKE UPPER('%$browser_search%'))";
+               } else {
+                       $search_qpart = "";
+               }       
+
+               $result = db_query($link, "SELECT ttrss_feedbrowser_cache.feed_url,
+                               subscribers, 
+                               title 
+                       FROM
+                               ttrss_feedbrowser_cache LEFT JOIN ttrss_feeds 
+                                       ON (ttrss_feedbrowser_cache.feed_url = ttrss_feeds.feed_url)
+                       WHERE 
+                               (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
+                                       WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url 
+                                       AND owner_uid = '$owner_uid') 
+                               $search_qpart
+                       ORDER BY subscribers DESC LIMIT $limit");
+               
                print "<br/>";
                        
                print "<div style=\"float : right\">
index dc2fda13289467d910b8a9b8badfa3efce11219e..cc3733a653ab9f33a95bc86482cb16a2eaed168b 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -1515,6 +1515,12 @@ function updateBigFeedBrowser(limit, from_button) {
                query = query + "&limit=" + param_escape(limit);
        }
 
+       var search = document.getElementById("feed_browser_search");
+
+       if (search) {
+               query = query + "&search=" + param_escape(search.value);
+       }
+
        xmlhttp.open("GET", query, true);
        xmlhttp.onreadystatechange=feed_browser_callback;
        xmlhttp.send(null);