Item: new method count_descendants

2022.09-rc
Domovoy 2012-08-11 17:48:07 +02:00
rodzic e6c55de070
commit 7c2ed027ff
1 zmienionych plików z 15 dodań i 1 usunięć

Wyświetl plik

@ -65,7 +65,7 @@ class Item extends BaseObject {
$osparkle = '';
$lastcollapsed = false;
$firstcollapsed = false;
$total_children += count_descendants($item);
$total_children = $this->count_descendants();
$show_comment_box = ((($this->is_page_writeable()) && ($this->is_writeable())) ? true : false);
$lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
@ -523,5 +523,19 @@ class Item extends BaseObject {
private function is_writeable() {
return $this->writeable;
}
/**
* Count the total of our descendants
*/
private function count_descendants() {
$children = $this->get_children();
$total = count($children);
if($total > 0) {
foreach($children as $child) {
$total += $child->count_descendants();
}
}
return $total;
}
}
?>