From 76e9a473d1d2152ef8a3b1ebe905f6f36a73c887 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 20 Jan 2009 10:43:45 +0100 Subject: [PATCH] feed browser: search --- modules/pref-feed-browser.php | 40 +++++++++++++++++++++++++++++++---- prefs.js | 6 ++++++ 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/modules/pref-feed-browser.php b/modules/pref-feed-browser.php index 91df4264c..b73516ef8 100644 --- a/modules/pref-feed-browser.php +++ b/modules/pref-feed-browser.php @@ -84,6 +84,14 @@ $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"]; @@ -108,12 +116,36 @@ print "
".__('This panel shows feeds subscribed by other users of this system, just in case you are interested in them too.')."
"; + print "

+ + +

"; - $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"); + 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 "
"; print "
diff --git a/prefs.js b/prefs.js index dc2fda132..cc3733a65 100644 --- 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);