]> git.mxchange.org Git - friendica.git/commitdiff
Item: new method count_descendants
authorDomovoy <domovoy@errlock.org>
Sat, 11 Aug 2012 15:48:07 +0000 (17:48 +0200)
committerDomovoy <domovoy@errlock.org>
Sat, 11 Aug 2012 15:48:07 +0000 (17:48 +0200)
object/Item.php

index 88256789410dd06da8ba1c7a15a7de756cbc6b51..a9115ee08e8759bc66c95b56b2ff34f54e5570fc 100644 (file)
@@ -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;
+       }
 }
 ?>