Beispiel #1
0
/**
 * Recursively calls itself to build the various page structures.
 *
 * @param array $pages Array of page objects that are passed by reference
 * @param array $allpages All pages in the course
 * @param int $depth Current depth in the parent/child hierarchy
 * @return array
 **/
function page_build_structures($pages, &$allpages, $depth = 0)
{
    $return = array('nested' => array(), 'flat' => array());
    foreach ($pages as $pageid => $page) {
        // Add the depth value, very handy
        $page->depth = $depth;
        // Each structure needs its own copy of the page object
        $return['nested'][$pageid] = clone $page;
        $return['flat'][$pageid] = clone $page;
        // Get and process the children
        $children = page_filter_child_pages($pageid, $allpages);
        $children = page_build_structures($children, $allpages, $depth + 1);
        // Store the children based on the structure
        $return['nested'][$pageid]->children = $children['nested'];
        $return['flat'] += $children['flat'];
    }
    return $return;
}
Beispiel #2
0
/**
 * returns the 'station' pages for the passed learning path
 *
 * @param int $courseid
 *
 * @return array
 */
function tao_get_learning_path_stations($courseid)
{
    $toppage = page_get_default_page($courseid);
    return page_filter_child_pages($toppage->id, page_get_all_pages($courseid, 'flat'));
}