// Display all menu pages with show/hide eyes $table = new stdClass(); $table->head = array(get_string('coursemenu', 'format_page'), get_string('menuitem', 'format_page'), get_string('showhide', 'format_page')); $table->wrap = array('nowrap', 'nowrap', ''); $table->size = array('', '', '150px'); $table->align = array('left', 'left', 'center'); $table->width = '60%'; $table->tablealign = 'center'; $table->cellpadding = '5px'; $table->cellspacing = '0'; $table->data = array(); foreach ($masters as $master) { $table->data[] = array($master->nameone, '', ''); if ($pages = get_records('format_page', 'parent', $master->id, 'sortorder, nameone')) { foreach ($pages as $page) { if ($childpages = page_get_children($page->id)) { $showhide = 'show'; // Default // If any child is published, then this menu item is considered unlocked foreach ($childpages as $childpage) { if ($childpage->display & DISP_PUBLISH) { $showhide = 'hide'; break; } } $sesskey = sesskey(); $showhidestr = get_string($showhide); $eye = ''; if (has_capability('format/page:managepages', $context)) { $eye .= "<a href=\"{$CFG->wwwroot}/course/format/page/managemenu.php?id={$course->id}&pageid={$page->id}&showhide={$showhide}&sesskey={$sesskey}\">"; }
/** * Gets all possible page parents for the given page * * @param int $pageid ID of the page to find parents for (0 is fine) * @param int $courseid ID of the course that the page belongs to * @return mixed */ function page_get_possible_parents($pageid, $courseid) { if ($parents = page_get_all_pages($courseid, 'flat')) { if ($pageid != 0) { // If zero, then it can have any page as a parent // Get the children $children = page_get_children($pageid); // Unset the current page... unset($parents[$pageid]); // ...and all of its children foreach ($children as $id => $child) { unset($parents[$id]); } } } else { $parents = false; } return $parents; }
public function get_menuitem($editing = false, $descend = false) { if (empty($this->link->id) or empty($this->config->pageid)) { return false; } if (!($page = page_get($this->config->pageid))) { // Probably deleted :( return false; } // Set editing to avoid passing it everywhere $this->editing = $editing; $this->descend = $descend; // Load the page with child tree(s) $page->children = page_get_children($page->id, 'nested', $page->courseid); // Generate menu item tree return $this->page_to_menuitem($page); }