function display() { global $PAGE, $COURSE; $editing = $PAGE->user_is_editing(); $pageblocks = page_blocks_setup(); /// Make sure we can see this page if (!($this->page->display & DISP_PUBLISH) and !(has_capability('format/page:editpages', $this->context) and $editing)) { error(get_string('thispageisnotpublished', 'format_page')); } /// Finally, we can print the page if ($editing) { $PAGE->print_tabs('layout'); page_print_jump_menu(); page_print_add_mods_form($this->page, $COURSE); $class = 'format-page editing'; } else { $class = 'format-page'; } echo '<table id="layout-table" class="' . $class . '" cellspacing="0" summary="' . get_string('layouttable') . '">'; /// Check if the page is locked, if so, print lock message, otherwise print three columns if (page_is_locked($this->page)) { echo '<tr><td colspan="3">'; page_print_lock_prerequisites($this->page); echo '</tr></td>'; } else { echo '<tr>'; if (blocks_have_content($pageblocks, BLOCK_POS_LEFT)) { page_print_position($pageblocks, BLOCK_POS_LEFT, $this->page->prefleftwidth); } page_print_position($pageblocks, BLOCK_POS_CENTER, '100%'); if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT)) { page_print_position($pageblocks, BLOCK_POS_RIGHT, $this->page->prefrightwidth); } echo '</tr>'; } /// Silently attempts to call a function from the block_recent_history block @block_method_result('recent_history', 'block_recent_history_record', $this->page); /// Display navigation buttons if ($this->page->showbuttons) { $nav = page_get_next_previous_pages($this->page->id, $this->page->courseid); $buttons = ''; if ($nav->prev and $this->page->showbuttons & BUTTON_PREV) { $title = get_string('previous', 'format_page', page_get_name($nav->prev)); $buttons .= '<span class="prevpage"><a href="' . $PAGE->url_build('page', $nav->prev->id) . "\" title=\"{$title}\">{$title}</a></span>"; } if ($nav->next and $this->page->showbuttons & BUTTON_NEXT) { $title = get_string('next', 'format_page', page_get_name($nav->next)); $buttons .= '<span class="nextpage"><a href="' . $PAGE->url_build('page', $nav->next->id) . "\" title=\"{$title}\">{$title}</a></span>"; } // Make sure we have something to print if (!empty($buttons)) { echo "\n<tr><td></td><td>{$buttons}</td><td></td></tr>\n"; } } echo '</table>'; }
/** * Checks to see if the page has the proper * display value to be included into the menu * rendering. * * The page must be pusblished and be set to display * in the course menu and not be locked with a * non-visible lock. * * @param object $page Page object * @return boolean **/ protected function dont_display($page) { if (DISP_MENU & $page->display and DISP_PUBLISH & $page->display and !(page_is_locked($page) and !page_is_visible_lock($page))) { return false; } return true; }
/** * This function returns the page objects of the next/previous pages * relative to the passed page ID * * @param int $pageid Base next/previous off of this page ID * @param int $courseid (Optional) ID of the course */ function page_get_next_previous_pages($pageid, $courseid = NULL) { global $COURSE; if ($courseid === NULL) { $courseid = $COURSE->id; } $return = new stdClass(); $return->prev = false; $return->next = false; if ($pages = page_get_all_pages($courseid, 'flat')) { // Remove any unpublished pages foreach ($pages as $id => $page) { if (!($page->display & DISP_PUBLISH)) { unset($pages[$id]); } } if (!empty($pages)) { // Search for the pages $get = false; $locked = array(); foreach ($pages as $id => $page) { if (in_array($page->parent, $locked) or page_is_locked($page) and !page_is_visible_lock($page)) { $locked[] = $page->id; } if ($get and !in_array($page->id, $locked)) { // We have seen the id we're looking for $return->next = $page; break; // quit this business } if ($id == $pageid) { // We've found the id that we are looking for $get = true; } if (!$get and !in_array($page->id, $locked)) { // Only if we haven't found what we're looking for $return->prev = $page; } } } } return $return; }