]> git.wh0rd.org Git - tt-rss.git/commitdiff
add toolbar checkbox to include subcategories to viewfeed()
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 13 Aug 2012 17:25:46 +0000 (21:25 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 13 Aug 2012 17:25:46 +0000 (21:25 +0400)
classes/feeds.php
include/functions.php
index.php
js/tt-rss.js

index 4f0ac4f3fa2a26ad6e16bb992ce21a336c27ef2c..502efd40142dcaac0cb34ec731cbae7dffeb6d0e 100644 (file)
@@ -119,7 +119,7 @@ class Feeds extends Protected_Handler {
 \r
        private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view,\r
                                        $next_unread_feed, $offset, $vgr_last_feed = false,\r
-                                       $override_order = false) {\r
+                                       $override_order = false, $include_children = false) {\r
 \r
                $disable_cache = false;\r
 \r
@@ -196,7 +196,8 @@ class Feeds extends Protected_Handler {
                }\r
 //             error_log("search_mode: " . $search_mode);\r
                $qfh_ret = queryFeedHeadlines($this->link, $feed, $limit, $view_mode, $cat_view,\r
-                       $search, $search_mode, $match_on, $override_order, $offset);\r
+                       $search, $search_mode, $match_on, $override_order, $offset, 0,\r
+                       false, 0, $include_children);\r
 \r
                if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info);\r
 \r
@@ -758,11 +759,12 @@ class Feeds extends Protected_Handler {
                $method = db_escape_string($_REQUEST["m"]);\r
                $view_mode = db_escape_string($_REQUEST["view_mode"]);\r
                $limit = (int) get_pref($this->link, "DEFAULT_ARTICLE_LIMIT");\r
-               @$cat_view = db_escape_string($_REQUEST["cat"]) == "true";\r
+               @$cat_view = $_REQUEST["cat"] == "true";\r
                @$next_unread_feed = db_escape_string($_REQUEST["nuf"]);\r
                @$offset = db_escape_string($_REQUEST["skip"]);\r
                @$vgroup_last_feed = db_escape_string($_REQUEST["vgrlf"]);\r
                $order_by = db_escape_string($_REQUEST["order_by"]);\r
+               $include_children = $_REQUEST["include_children"] == "on";\r
 \r
                if (is_numeric($feed)) $feed = (int) $feed;\r
 \r
@@ -856,7 +858,7 @@ class Feeds extends Protected_Handler {
 \r
                $ret = $this->format_headlines_list($feed, $method,\r
                        $view_mode, $limit, $cat_view, $next_unread_feed, $offset,\r
-                       $vgroup_last_feed, $override_order);\r
+                       $vgroup_last_feed, $override_order, $include_children);\r
 \r
                $topmost_article_ids = $ret[0];\r
                $headlines_count = $ret[1];\r
index 1116e422c7958978b2ba74f7d548c6435f6060b7..3cb503fd865861d7c51d0b9c301390764427b5a5 100644 (file)
                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"];
 
                                } 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) {
                                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 {
index c17a104168688714f5d06768b3eb10ee25882bba..96d13558d1f9e678eadc0296a31f43a452890441 100644 (file)
--- a/index.php
+++ b/index.php
                        <option value="score"><?php echo __('Score') ?></option>
                </select>
 
+               &nbsp;
+
+               <input dojoType="dijit.form.CheckBox" type="checkbox"
+                       onchange="viewCurrentFeed()"
+                       name="include_children" id="include_children">
+               <label id="include_children_label" for="include_children">
+                       <?php echo __('With subcategories') ?></label>
+
                <button dojoType="dijit.form.Button" name="update"
                        onclick="scheduleFeedUpdate()">
                        <?php echo __('Update') ?></button>
index a4c67bfcccfc76b93f10c404338a44acac6d5c87..11d5ef9c1b1ac055a2b8255794652f63abb27e71 100644 (file)
@@ -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);
        }