From b2531a28a63fe23ddb0d0c518f8405d4d5e4eb25 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 18 Jan 2009 15:16:31 +0100 Subject: [PATCH] add special All Articles feed; tweak counter calculation rules --- functions.php | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/functions.php b/functions.php index eb27641a..5bcfa3e3 100644 --- a/functions.php +++ b/functions.php @@ -2307,11 +2307,11 @@ function getCategoryCounters($link) { # two special categories are -1 and -2 (all virtuals; all labels) - $ctr = getCategoryUnread($link, -1); +/* $ctr = getCategoryUnread($link, -1); - print ""; + print ""; */ - $ctr = getCategoryUnread($link, -2); + $ctr = getCategoryUnread($link, -2); print ""; @@ -2380,18 +2380,18 @@ return getFeedUnread($link, -1) + getFeedUnread($link, -2) + getFeedUnread($link, -3); } else if ($cat == -2) { - // FIXME: NEW_LABELS + $result = db_query($link, " + SELECT COUNT(unread) AS unread FROM + ttrss_user_entries, ttrss_labels2, ttrss_user_labels2, ttrss_feeds + WHERE label_id = ttrss_labels2.id AND article_id = ref_id AND + ttrss_labels2.owner_uid = '$owner_uid' + AND unread = true AND hidden = false AND feed_id = ttrss_feeds.id + AND ttrss_user_entries.owner_uid = '$owner_uid'"); -/* $rv = getLabelCounters($link, false, true); - $ctr = 0; + $unread = db_fetch_result($result, 0, "unread"); - foreach (array_keys($rv) as $k) { - if ($k < -10) { - $ctr += $rv[$k]["counter"]; - } - } + return $unread; - return $ctr; */ } } @@ -2458,7 +2458,8 @@ } else { $match_part .= " AND updated > DATE_SUB(NOW(), INTERVAL $intl HOUR) "; } - + } else if ($n_feed == -4) { + $match_part = "true"; } else if ($n_feed > 0) { $result = db_query($link, "SELECT id FROM ttrss_feeds @@ -2627,7 +2628,7 @@ $ret_arr = array(); - for ($i = -1; $i >= -3; $i--) { + for ($i = -1; $i >= -4; $i--) { $count = getFeedUnread($link, $i); @@ -2967,6 +2968,8 @@ return __("Published articles"); } else if ($id == -3) { return __("Fresh articles"); + } else if ($id == -4) { + return __("All articles"); } else if ($id < -10) { $label_id = -$id - 11; $result = db_query($link, "SELECT caption FROM ttrss_labels2 WHERE id = '$label_id'"); @@ -3274,6 +3277,9 @@ $query_strategy_part .= " AND updated > DATE_SUB(NOW(), INTERVAL $intl HOUR) "; } + $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; + } else if ($feed == -4) { // all articles virtual feed + $query_strategy_part = "true"; $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; } else if ($feed <= -10) { // labels $label_id = -$feed - 11; @@ -3350,6 +3356,9 @@ } else if ($feed == -3) { $feed_title = __("Fresh articles"); if ($search) { $feed_title = __("Searched for") . " $search ($feed_title)"; } + } else if ($feed == -4) { + $feed_title = __("All articles"); + if ($search) { $feed_title = __("Searched for") . " $search ($feed_title)"; } } else if ($feed < -10) { $label_id = -$feed - 11; $result = db_query($link, "SELECT caption FROM ttrss_labels2 @@ -4116,7 +4125,7 @@ if ($cat_id > 0) { $cat_unread = ccache_find($link, $cat_id, $_SESSION["uid"], true); - } else { + } else if ($cat_id == 0 || $cat_id == -2) { $cat_unread = getCategoryUnread($link, $cat_id); } @@ -4186,6 +4195,14 @@ $num_starred = getFeedUnread($link, -1); $num_published = getFeedUnread($link, -2); $num_fresh = getFeedUnread($link, -3); + $num_total = getFeedUnread($link, -4); + + $class = "virt"; + + if ($num_total > 0) $class .= "Unread"; + + printFeedEntry(-4, $class, __("All articles"), $num_total, + "images/tag.png", $link); $class = "virt"; -- 2.39.5