add toolbar checkbox to include subcategories to viewfeed()

This commit is contained in:
Andrew Dolgov 2012-08-13 21:25:46 +04:00
parent 99c9e91a51
commit 09101297ee
4 changed files with 35 additions and 13 deletions

View File

@ -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];

View File

@ -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 ($include_children) {
# sub-cats
$subcats = getChildCategories($link, $feed, $owner_uid);
if (count($subcats) == 0) {
$query_strategy_part = "cat_id = '$feed'";
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 {

View File

@ -183,6 +183,14 @@
<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>

View 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);
}