Exemple #1
0
/**
 * This function returns a number of "menu" pages that are first in the sortorder
 * 
 * @param int $courseid the course id ot get pages from
 * @param int $limit (optional) the maximum number of pages to return (0 meaning no limit);
 * @return array of pages
 */
function page_get_menu_pages($courseid, $limit = 0)
{
    return page_get_master_pages($courseid, $limit, DISP_MENU | DISP_PUBLISH);
}
Exemple #2
0
function page_print_site_page_structure_ul($pages = null, $ulid = '')
{
    global $CFG, $PAGE;
    if (empty($pages)) {
        $pages = page_get_master_pages(SITEID, 0, DISP_THEME);
    }
    if (empty($pages)) {
        return '';
    }
    $baseurl = $CFG->wwwroot . '/index.php?page=';
    static $canviewnonpublishedpages = null;
    if (is_null($canviewnonpublishedpages)) {
        $canviewnonpublishedpages = has_capability('format/page:managepages', get_system_context());
        // this is a recursive function so cache this heavy op
    }
    $pagestring = '';
    foreach ($pages as $page) {
        if (!($page->display & DISP_PUBLISH) && !$canviewnonpublishedpages) {
            continue;
            // this page isn't published and the user doesn't have the ability to see it
        }
        $pagestring .= !empty($page->children) ? '<li class="havechild">' : '<li>';
        $pageurl = !empty($page->redirect) ? $page->redirect : $baseurl . $page->id;
        $pagestring .= "<a href=\"{$pageurl}\"><span class=\"menu-title\">{$page->nameone}</span></a>";
        if (!empty($page->children)) {
            $pagestring .= page_print_site_page_structure_ul($page->children);
        }
        $pagestring .= '</li>';
    }
    return "<ul id=\"{$ulid}\" class=\"{$ulid}\">{$pagestring}</ul>";
}