$cat['items'] = $this->get_category_items($line['id']);
- $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
+ $num_children = $this->calculate_children_count($cat);
+ $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', $num_children), $num_children);
- if (count($cat['items']) > 0 || $show_empty_cats)
+ if ($num_children > 0 || $show_empty_cats)
array_push($items, $cat);
}
$cat['items'] = $this->get_category_items($line['id']);
- $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
+ $num_children = $this->calculate_children_count($cat);
+ $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', $num_children), $num_children);
- if (count($cat['items']) > 0 || $show_empty_cats)
+ if ($num_children > 0 || $show_empty_cats)
array_push($root['items'], $cat);
$root['param'] += count($cat['items']);
if (count($cat['items']) > 0 || $show_empty_cats)
array_push($root['items'], $cat);
- $root['param'] += count($cat['items']);
- $root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
+ $num_children = $this->calculate_children_count($root);
+ $root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', $num_children), $num_children);
} else {
$feed_result = $this->dbh->query("SELECT id, title, last_error,
owner_uid = " . $_SESSION["uid"]);
}
+ private function calculate_children_count($cat) {
+ $c = 0;
+
+ foreach ($cat['items'] as $child) {
+ if ($child['type'] == 'category') {
+ $c += $this->calculate_children_count($child);
+ } else {
+ $c += 1;
+ }
+ }
+
+ return $c;
+ }
}
?>