From 16270276cf27620d72974eb7e71f089ea8bc3bd5 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 20 Apr 2011 13:32:40 +0400 Subject: implement search in pref-feeds (closes #332) --- modules/pref-feeds.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'modules/pref-feeds.php') diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index c95e039cd..f496c782f 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -36,6 +36,10 @@ if ($subop == "getfeedtree") { + $search = $_SESSION["prefs_feed_search"]; + + if ($search) $search_qpart = " AND LOWER(title) LIKE LOWER('%$search%')"; + $root = array(); $root['id'] = 'root'; $root['name'] = __('Feeds'); @@ -59,7 +63,7 @@ ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated FROM ttrss_feeds WHERE cat_id = '".$line['id']."' AND owner_uid = ".$_SESSION["uid"]. - " ORDER BY order_id, title"); + "$search_qpart ORDER BY order_id, title"); while ($feed_line = db_fetch_assoc($feed_result)) { $feed = array(); @@ -75,7 +79,8 @@ array_push($cat['items'], $feed); } - array_push($root['items'], $cat); + if (count($cat['items']) > 0) + array_push($root['items'], $cat); } /* Uncategorized is a special case */ @@ -91,7 +96,7 @@ ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated FROM ttrss_feeds WHERE cat_id IS NULL AND owner_uid = ".$_SESSION["uid"]. - " ORDER BY order_id, title"); + "$search_qpart ORDER BY order_id, title"); while ($feed_line = db_fetch_assoc($feed_result)) { $feed = array(); @@ -107,13 +112,15 @@ array_push($cat['items'], $feed); } - array_push($root['items'], $cat); + if (count($cat['items']) > 0) + array_push($root['items'], $cat); + } else { $feed_result = db_query($link, "SELECT id, title, last_error, ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated FROM ttrss_feeds WHERE owner_uid = ".$_SESSION["uid"]. - " ORDER BY order_id, title"); + "$search_qpart ORDER BY order_id, title"); while ($feed_line = db_fetch_assoc($feed_result)) { $feed = array(); @@ -1304,6 +1311,13 @@ print "
"; + print "
+ + +
"; + print "
". "" . __('Select').""; print "
"; -- cgit v1.2.3-54-g00ecf From 414d0d1f46d2be49e95cf668efec906fb989d1f2 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 20 Apr 2011 15:36:46 +0400 Subject: implement feedbrowser using linked feeds; set proper fetch timeout --- functions.php | 2 +- modules/pref-feeds.php | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'modules/pref-feeds.php') diff --git a/functions.php b/functions.php index e0c2a664b..4980140c1 100644 --- a/functions.php +++ b/functions.php @@ -7371,7 +7371,7 @@ $instance_qpart = ""; if (DB_TYPE == "pgsql") { - $date_qpart = "last_connected < NOW() - INTERVAL '1 second'"; + $date_qpart = "last_connected < NOW() - INTERVAL '6 hours'"; } else { $date_qpart = "last_connected < DATE_SUB(NOW(), INTERVAL 6 HOUR"; } diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index f496c782f..238ca0a85 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -1539,11 +1539,21 @@ } if ($mode == 1) { - $result = db_query($link, "SELECT feed_url, subscribers FROM + /* $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') $search_qpart - ORDER BY subscribers DESC LIMIT $limit"); + ORDER BY subscribers DESC LIMIT $limit"); */ + + $result = db_query($link, "SELECT feed_url, title, SUM(subscribers) AS subscribers FROM + (SELECT feed_url, title, subscribers FROM ttrss_feedbrowser_cache UNION ALL + SELECT feed_url, title, subscribers FROM ttrss_linked_feeds) AS qqq + WHERE + (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf + WHERE tf.feed_url = qqq.feed_url + AND owner_uid = '$owner_uid') $search_qpart + GROUP BY feed_url, title ORDER BY subscribers DESC LIMIT $limit"); + } else if ($mode == 2) { $result = db_query($link, "SELECT *, (SELECT COUNT(*) FROM ttrss_user_entries WHERE -- cgit v1.2.3-54-g00ecf From 9530efa1b506f4a0d64088ae30aec38ff27de331 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 20 Apr 2011 15:48:26 +0400 Subject: feed browser: use title from cache table --- modules/pref-feeds.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/pref-feeds.php') diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index 238ca0a85..4baba572a 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -1613,7 +1613,7 @@ $rv .= "
  • $check_box". - "$feed_icon $feed_url " . htmlspecialchars($details["title"]) . + "$feed_icon $feed_url " . htmlspecialchars($line["title"]) . " ($subscribers) $site_url
  • "; -- cgit v1.2.3-54-g00ecf