From: Andrew Dolgov Date: Mon, 13 Aug 2012 17:25:46 +0000 (+0400) Subject: add toolbar checkbox to include subcategories to viewfeed() X-Git-Tag: 1.6.0~170^2~1 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=09101297ee0596a6c66d9c7388795e8602c24113;p=tt-rss.git add toolbar checkbox to include subcategories to viewfeed() --- diff --git a/classes/feeds.php b/classes/feeds.php index 4f0ac4f3..502efd40 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -119,7 +119,7 @@ class Feeds extends Protected_Handler { private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, $next_unread_feed, $offset, $vgr_last_feed = false, - $override_order = false) { + $override_order = false, $include_children = false) { $disable_cache = false; @@ -196,7 +196,8 @@ class Feeds extends Protected_Handler { } // error_log("search_mode: " . $search_mode); $qfh_ret = queryFeedHeadlines($this->link, $feed, $limit, $view_mode, $cat_view, - $search, $search_mode, $match_on, $override_order, $offset); + $search, $search_mode, $match_on, $override_order, $offset, 0, + false, 0, $include_children); if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info); @@ -758,11 +759,12 @@ class Feeds extends Protected_Handler { $method = db_escape_string($_REQUEST["m"]); $view_mode = db_escape_string($_REQUEST["view_mode"]); $limit = (int) get_pref($this->link, "DEFAULT_ARTICLE_LIMIT"); - @$cat_view = db_escape_string($_REQUEST["cat"]) == "true"; + @$cat_view = $_REQUEST["cat"] == "true"; @$next_unread_feed = db_escape_string($_REQUEST["nuf"]); @$offset = db_escape_string($_REQUEST["skip"]); @$vgroup_last_feed = db_escape_string($_REQUEST["vgrlf"]); $order_by = db_escape_string($_REQUEST["order_by"]); + $include_children = $_REQUEST["include_children"] == "on"; if (is_numeric($feed)) $feed = (int) $feed; @@ -856,7 +858,7 @@ class Feeds extends Protected_Handler { $ret = $this->format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, $next_unread_feed, $offset, - $vgroup_last_feed, $override_order); + $vgroup_last_feed, $override_order, $include_children); $topmost_article_ids = $ret[0]; $headlines_count = $ret[1]; diff --git a/include/functions.php b/include/functions.php index 1116e422..3cb503fd 100644 --- a/include/functions.php +++ b/include/functions.php @@ -2287,7 +2287,7 @@ return $rv; } - function queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0) { + function queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false) { if (!$owner_uid) $owner_uid = $_SESSION["uid"]; @@ -2332,7 +2332,7 @@ } else if ($feed != -1) { $unread = getFeedUnread($link, $feed, $cat_view); - if ($cat_view && $feed > 0) + if ($cat_view && $feed > 0 && $include_children) $unread += getCategoryChildrenUnread($link, $feed); if ($unread > 0) { @@ -2406,15 +2406,19 @@ if ($cat_view) { if ($feed > 0) { - # sub-cats - $subcats = getChildCategories($link, $feed, $owner_uid); - - if (count($subcats) == 0) { - $query_strategy_part = "cat_id = '$feed'"; + if ($include_children) { + # sub-cats + $subcats = getChildCategories($link, $feed, $owner_uid); + + if (count($subcats) == 0) { + $query_strategy_part = "cat_id = '$feed'"; + } else { + array_push($subcats, $feed); + $query_strategy_part = "cat_id IN (". + implode(",", $subcats).")"; + } } else { - array_push($subcats, $feed); - $query_strategy_part = "cat_id IN (". - implode(",", $subcats).")"; + $query_strategy_part = "cat_id = '$feed'"; } } else { diff --git a/index.php b/index.php index c17a1041..96d13558 100644 --- a/index.php +++ b/index.php @@ -183,6 +183,14 @@ +   + + + + diff --git a/js/tt-rss.js b/js/tt-rss.js index a4c67bfc..11d5ef9c 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -42,6 +42,14 @@ function setActiveFeedId(id, is_cat) { selectFeed(id, is_cat); + if (is_cat && id > 0) { + document.forms["main_toolbar_form"].include_children.disabled = false; + $("include_children_label").removeClassName("insensitive"); + } else { + document.forms["main_toolbar_form"].include_children.disabled = true; + $("include_children_label").addClassName("insensitive"); + } + } catch (e) { exception_error("setActiveFeedId", e); }