]> git.wh0rd.org Git - tt-rss.git/commitdiff
add special All Articles feed; tweak counter calculation rules
authorAndrew Dolgov <fox@bah.spb.su>
Sun, 18 Jan 2009 14:16:31 +0000 (15:16 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sun, 18 Jan 2009 14:16:31 +0000 (15:16 +0100)
functions.php

index eb27641ae215a7d6d0aecc227b94ad1e47c31814..5bcfa3e35f35350aaa58a401590ad7f2fac3a026 100644 (file)
        function getCategoryCounters($link) {
                # two special categories are -1 and -2 (all virtuals; all labels)
 
-               $ctr = getCategoryUnread($link, -1);
+/*             $ctr = getCategoryUnread($link, -1);
 
-               print "<counter type=\"category\" id=\"-1\" counter=\"$ctr\"/>";
+               print "<counter type=\"category\" id=\"-1\" counter=\"$ctr\"/>"; */
 
-               $ctr = getCategoryUnread($link, -2);
+               $ctr = getCategoryUnread($link, -2); 
 
                print "<counter type=\"category\" id=\"-2\" counter=\"$ctr\"/>";
 
                        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; */
                } 
        }
 
                        } 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 
 
                $ret_arr = array();
 
-               for ($i = -1; $i >= -3; $i--) {
+               for ($i = -1; $i >= -4; $i--) {
 
                        $count = getFeedUnread($link, $i);
        
                        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'");
                                        $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;
                        } 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
 
                        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);
                        }
 
                $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";