From 5a438ec442d69694e13a5f517ae17e38a35bbbc6 Mon Sep 17 00:00:00 2001 From: floppy0 <31189947+floppy0@users.noreply.github.com> Date: Thu, 8 Feb 2018 16:53:35 +0100 Subject: [PATCH] improve children on pages --- bl-kernel/functions.php | 2 +- bl-kernel/page.class.php | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index 59f72b8c..0aa7f683 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -59,7 +59,7 @@ function buildPage($key) { $page->setField('categoryMap', $dbCategories->getMap($categoryKey)); // Get the keys of the child - $page->setField('children', $dbPages->getChildren($key)); + $page->setField('childrenKeys', $dbPages->getChildren($key)); return $page; } diff --git a/bl-kernel/page.class.php b/bl-kernel/page.class.php index 55661e6f..be4d9fb0 100644 --- a/bl-kernel/page.class.php +++ b/bl-kernel/page.class.php @@ -459,16 +459,29 @@ class Page { return $this->parentKey()!==false; } - // Returns an array with all children's key + // Returns an array with all children as page-object public function children() { - return $this->getValue('children'); + $list = array(); + $childrenKeys = $this->getValue('childrenKeys'); + foreach ($childrenKeys as $childKey) { + $child = buildPage($childKey); + array_push($list, $child); + } + + return $list; + } + + // Returns an array with all children's keys + public function childrenKeys() + { + return $this->getValue('childrenKeys'); } // Returns an array with all children's key - public function subpages() + public function subpagesKeys() { - return $this->children(); + return $this->childrenKeys(); } // Returns TRUE if the page has children @@ -521,6 +534,5 @@ class Page { } return $string ? implode(', ', $string) . ' ago' : 'Just now'; - } }