concrete/src/Page/Page.php
public function populateRecursivePages($pages, $pageRow, $cParentID, $level, $includeThisPage = true)
    {
        $db = Database::connection();
        $children = $db->GetAll('select cID, cDisplayOrder from Pages where cParentID = ? order by cDisplayOrder asc', [$pageRow['cID']]);
        if ($includeThisPage) {
            $pages[] = [
                'cID' => $pageRow['cID'],
                'cDisplayOrder' => isset($pageRow['cDisplayOrder']) ? $pageRow['cDisplayOrder'] : null,
                'cParentID' => $cParentID,
                'level' => $level,
                'total' => count($children),
            ];
        }
        ++$level;
        $cParentID = $pageRow['cID'];
        if (count($children) > 0) {
            foreach ($children as $pageRow) {
                $pages = $this->populateRecursivePages($pages, $pageRow, $cParentID, $level);
            }
        }

        return $pages;
    }
public function populateRecursivePages($pages, $pageRow, $cParentID, $level, $includeThisPage = true)
    {
        $db = Database::connection();
        $children = $db->GetAll('select cID, cDisplayOrder from Pages where cParentID = ? order by cDisplayOrder asc', [$pageRow['cID']]);
        if ($includeThisPage) {
            $pages[] = [
                'cID' => $pageRow['cID'],
                'cDisplayOrder' => isset($pageRow['cDisplayOrder']) ? $pageRow['cDisplayOrder'] : null,
                'cParentID' => $cParentID,
                'level' => $level,
                'total' => count($children),
            ];
        }
        ++$level;
        $cParentID = $pageRow['cID'];
        if (count($children) > 0) {
            foreach ($children as $pageRow) {
                $pages = $this->populateRecursivePages($pages, $pageRow, $cParentID, $level);
            }
        }

        return $pages;
    }
public function populateRecursivePages ( $ pages , $ pageRow , $ cParentID , $ level , $ includeThisPage = true ) { $ db = Database :: connection ( ) ; $ children = $ db -> GetAll ( 'select cID, cDisplayOrder from Pages where cParentID = ? order by cDisplayOrder asc' , [ $ pageRow [ 'cID' ] ] ) ; if ( $ includeThisPage ) { $ pages [ ] = [ 'cID' => $ pageRow [ 'cID' ] , 'cDisplayOrder' => isset ( $ pageRow [ 'cDisplayOrder' ] ) ? $ pageRow [ 'cDisplayOrder' ] : null , 'cParentID' => $ cParentID , 'level' => $ level , 'total' => count ( $ children ) , ] ; } ++ $ level ; $ cParentID = $ pageRow [ 'cID' ] ; if ( count ( $ children ) > 0 ) { foreach ( $ children as $ pageRow ) { $ pages = $ this -> populateRecursivePages ( $ pages , $ pageRow , $ cParentID , $ level ) ; } } return $ pages ; }
Create an array containing data about child pages.

@param array $pages the previously loaded data
@param array $pageRow The data of current parent page (it must contain cID and optionally cDisplayOrder)
@param int $cParentID The parent page ID
@param int $level The current depth level
@param bool $includeThisPage Should $pageRow itself be added to the resulting array?

@return array Every array item contains the following keys: {
@var int $cID
@var int $cDisplayOrder
@var int $cParentID
@var int $level
@var int $total
}
Create an array containing data about child pages .