public function edit_form_add(&$mform) { global $COURSE; $pages = array(); if ($pages = page_get_all_pages($COURSE->id)) { $options = array(0 => get_string('choose', 'pagemenu')); $options += $this->build_select_menu($pages); $mform->addElement('select', 'pageid', get_string('addpage', 'pagemenu'), $options); $mform->setType('pageid', PARAM_INT); } }
public function edit_form_add(&$mform) { global $COURSE; // for some reason the nested pages don't work on site id $pages = $COURSE->id == SITEID ? page_get_all_pages($COURSE->id, 'flat') : page_get_all_pages($COURSE->id); if ($pages) { $options = array(0 => get_string('choose', 'pagemenu')); $options += $this->build_select_menu($pages); $mform->addElement('select', 'pageid', get_string('addpage', 'pagemenu'), $options); $mform->setType('pageid', PARAM_INT); } }
function display() { global $CFG, $PAGE, $COURSE; $moving = optional_param('moving', 0, PARAM_INT); require_capability('format/page:managepages', $this->context); $PAGE->print_tabs('manage'); if ($pages = page_get_all_pages($COURSE->id, 'flat')) { $table->head = array(get_string('pagename', 'format_page'), get_string('pageoptions', 'format_page'), get_string('displaytheme', 'format_page'), get_string('displaymenu', 'format_page'), get_string('publish', 'format_page'), get_string('locks', 'format_page')); $table->align = array('left', 'center', 'center', 'center', 'center', 'center'); $table->width = '70%'; $table->cellspacing = '0'; $table->id = 'editing-table'; $table->class = 'generaltable pageeditingtable'; $table->data = array(); foreach ($pages as $page) { $a = strip_tags(format_string($page->nameone)); $editalt = get_string('edita', 'format_page', $a); $movealt = get_string('movea', 'format_page', $a); $delealt = get_string('deletea', 'format_page', $a); // Page link/name $name = page_pad_string('<a href="' . $PAGE->url_build('page', $page->id) . '" title="' . $a . '">' . format_string($page->nameone) . '</a>', $page->depth); // Edit, move and delete widgets $widgets = '<a title="' . $editalt . '" href="' . $PAGE->url_build('page', $page->id, 'action', 'editpage', 'returnaction', 'manage') . '" class="icon edit"><img src="' . $CFG->pixpath . '/t/edit.gif" alt="' . $editalt . '" /></a> '; $widgets .= '<a title="' . $movealt . '" href="' . $PAGE->url_build('action', 'moving', 'moving', $page->id, 'sesskey', sesskey()) . '" class="icon move"><img src="' . $CFG->pixpath . '/t/move.gif" alt="' . $movealt . '" /></a> '; $widgets .= '<a title="' . $delealt . '" href="' . $PAGE->url_build('action', 'confirmdelete', 'page', $page->id, 'sesskey', sesskey()) . '" class="icon delete"><img src="' . $CFG->pixpath . '/t/delete.gif" alt="' . $delealt . '" /></a>'; // Theme, menu and publish widgets if ($page->parent == 0) { // Only master pages get this one $theme = $this->manage_showhide($page, DISP_THEME); } else { //$theme = ''; $theme = $this->manage_showhide($page, DISP_THEME); } $menu = $this->manage_showhide($page, DISP_MENU); $publish = $this->manage_showhide($page, DISP_PUBLISH); if (empty($page->locks)) { $lockalt = get_string('notlockedalt', 'format_page'); $lockicon = 'lock.gif'; } else { $lockalt = get_string('lockedalt', 'format_page'); $lockicon = 'unlock.gif'; } $lock = '<a title="' . $lockalt . '" href="' . $PAGE->url_build('page', $page->id, 'action', 'lock') . '" class="icon lock"><img src="' . $CFG->pixpath . '/t/' . $lockicon . '" alt="' . $lockalt . '" /></a>'; $table->data[] = array($name, $widgets, $theme, $menu, $publish, $lock); } print_table($table); } else { error(get_string('nopages', 'format_page'), $PAGE->url_build('action', 'editpage')); } }
function display() { global $PAGE, $COURSE; $moving = required_param('moving', PARAM_INT); require_capability('format/page:managepages', $this->context); $PAGE->print_tabs('manage'); if ($pages = page_get_all_pages($COURSE->id)) { if (!($name = get_field('format_page', 'nameone', 'id', $moving))) { error('Cannot get the name of the page'); } $a = new stdClass(); $a->name = format_string($name); $a->url = $PAGE->url_get_full(array('action' => 'manage')); $table->head = array(get_string('movingpage', 'format_page', $a)); $table->cellpadding = '2px'; $table->cellspacing = '0'; $table->width = '30%'; $table->wrap = array('nowrap'); $table->id = 'editing-table'; $table->class = 'pageeditingtable'; $table->data = array(); $sortorder = 1; $data = array(); $data[] = $this->movehere_widget($moving, 0, 0, -2, get_string('asamasterpageone', 'format_page')); foreach ($pages as $page) { if ($page->id != $moving) { $data = array_merge($data, $this->print_moving_hierarchy($page, $moving)); $data[] = $this->movehere_widget($moving, 0, $sortorder, -2, get_string('asamasterpageafter', 'format_page', format_string($page->nameone))); $sortorder++; } } // Convert each item in $data into a table row foreach ($data as $row) { $table->data[] = array($row); } print_table($table); } else { error(get_string('nopages', 'format_page'), $PAGE->url_build('action', 'editpage')); } }
/** * 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; foreach ($pages as $id => $page) { if ($get) { // 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) { // Only if we haven't found what we're looking for $return->prev = $page; } } } } return $return; }
<?php /** * Prints the moving interface * * @author Jeff Graham, Mark Nielsen * @license http://www.gnu.org/copyleft/gpl.html GNU Public License */ $moving = required_param('moving', PARAM_INT); require_capability('format/page:managepages', $context); $PAGE->print_tabs('manage'); if ($pages = page_get_all_pages($course->id)) { if (!($name = get_field('format_page', 'nameone', 'id', $moving))) { error('Cannot get the name of the page'); } $a = new stdClass(); $a->name = format_string($name); $a->url = $PAGE->url_get_full(array('action' => 'manage')); $table->head = array(get_string('movingpage', 'format_page', $a)); $table->cellpadding = '2px'; $table->cellspacing = '0'; $table->width = '30%'; $table->wrap = array('nowrap'); $table->id = 'editing-table'; $table->class = 'pageeditingtable'; $table->data = array(); $sortorder = 1; $data = array(); $data[] = page_movehere_widget($moving, 0, 0, -2, get_string('asamasterpageone', 'format_page')); foreach ($pages as $page) { if ($page->id != $moving) {
/** * 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')); }
<?php /** * Page management * * @author Jeff Graham, Mark Nielsen * @license http://www.gnu.org/copyleft/gpl.html GNU Public License */ $moving = optional_param('moving', 0, PARAM_INT); require_capability('format/page:managepages', $context); $PAGE->print_tabs('manage'); if ($pages = page_get_all_pages($course->id, 'flat')) { $table->head = array(get_string('pagename', 'format_page'), get_string('pageoptions', 'format_page'), get_string('displaytheme', 'format_page'), get_string('displaymenu', 'format_page'), get_string('publish', 'format_page')); $table->align = array('left', 'center', 'center', 'center', 'center'); $table->width = '70%'; $table->cellspacing = '0'; $table->id = 'editing-table'; $table->class = 'generaltable pageeditingtable'; $table->data = array(); foreach ($pages as $page) { // Page link/name $name = page_pad_string('<a href="' . $PAGE->url_build('page', $page->id) . '">' . format_string($page->nameone) . '</a>', $page->depth); // Edit, move and delete widgets $widgets = '<a href="' . $PAGE->url_build('page', $page->id, 'action', 'editpage', 'returnaction', 'manage') . '" class="icon edit"><img src="' . $CFG->pixpath . '/t/edit.gif" alt="' . get_string('editpage', 'format_page') . '" /></a> '; $widgets .= '<a href="' . $PAGE->url_build('action', 'moving', 'moving', $page->id, 'sesskey', sesskey()) . '" class="icon move"><img src="' . $CFG->pixpath . '/t/move.gif" /></a> '; $widgets .= '<a href="' . $PAGE->url_build('action', 'confirmdelete', 'page', $page->id, 'sesskey', sesskey()) . '" class="icon delete"><img src="' . $CFG->pixpath . '/t/delete.gif" alt="' . get_string('deletepage', 'format_page') . '" /></a>'; // Theme, menu and publish widgets if ($page->parent == 0) { // Only master pages get this one $theme = page_manage_showhide($page, DISP_THEME); } else {
/** * Prints the theme tabs * * @return void **/ function page_theme_print_tabs($return = false) { global $COURSE, $CFG, $ME; if ($COURSE->format == 'page') { require_once $CFG->libdir . '/blocklib.php'; require_once $CFG->dirroot . '/course/format/page/lib.php'; $tabs = $row = $inactive = array(); $selected = ''; $disableselected = false; if (page_theme_config('page_menutab') and $tabmenus = page_theme_get_tab_menu()) { foreach ($tabmenus as $tabmenu) { if ($tabmenu->active) { if (empty($selected)) { $selected = $tabmenu->id; } else { $disableselected = true; } } else { if ($tabmenu->id == 'menutree0' and !empty($tabmenu->menu)) { /// This code is a HACK and it is legacy - so only check for first menu tree /// Nothing in the menu is selected, so check out white list areas /// To do this, run through a series of URL tests $locations = array('/blocks/task_list/', '/blocks/announcement/', '/blocks/teo_schedule/', '/mod/pairandshare/index.php', '/course/format/page/managemenu.php', '/mod/assess/index.php', '/blocks/certify/'); foreach ($locations as $location) { $testurl = $CFG->wwwroot . $location; if (strpos($ME, $testurl) !== false) { foreach ($tabmenu->menu as $menuitem) { if (isset($menuitem->data->url) and strpos($menuitem->data->url, $testurl) !== false) { $selected = $tabmenu->id; break; } } break; } } } } // HACKING in id and onclick attributes $row[] = new tabobject($tabmenu->id, $tabmenu->tablink, $tabmenu->name, $tabmenu->name . '" onclick="this.target=\'_top\'" id="tab' . $tabmenu->id, true); } } /// Master pages are added as tabs $secondpage = ''; //if ($pages = page_get_theme_pages($COURSE->id)) { if ($pages = page_get_all_pages($COURSE->id)) { // echo "<div style=\"direction:ltr;\">"; // print_r($pages); // echo "</div>"; // Different URL depending on if this is the front page or not if ($COURSE->id == SITEID) { $baseurl = $CFG->wwwroot . '/index.php?page='; } else { $baseurl = "{$CFG->wwwroot}/course/view.php?id={$COURSE->id}&page="; } $i = 1; foreach ($pages as $page) { $name = format_string($page->nameone, true); // HACKING in an onclick attribute $row[] = new tabobject("page{$page->id}", $baseurl . $page->id, $name, $name . '" onclick="this.target=\'_top\'', true); if (!empty($page->children) && $page->id == $_GET['page'] || array_key_exists($_GET['page'], $page->children)) { $subrow = array(); foreach ($page->children as $subpage) { $subname = format_string($subpage->nameone, true); $subrow[] = new tabobject("page{$subpage->id}", $baseurl . $subpage->id, $subname, $subname . '" onclick="this.target=\'_top\'', true); //echo " { $subname } "; } //$row[] = $subrow; } //echo " $name "; if ($i == 2) { // Get the second page's tabojbect name - might be used later $secondpage = "page{$page->id}"; } $i++; } } if ($disableselected) { // Multiple tabs are selected, resolution: nothing is selected $selected = ''; } else { if (empty($selected)) { // Didn't find a manage page - look for a course format page to select if ($currentpage = page_get_current_page($COURSE->id, false)) { /// First check to see if this current page parent is a tab $masterpage = page_get_toplevel_parent($currentpage->id, $COURSE->id); if (!empty($masterpage->id) and $masterpage->display & DISP_THEME) { $selected = "page{$masterpage->id}"; /// Next, check if this page is in the menu } else { if ($currentpage->display & DISP_MENU) { // In the course menu, default to second master page tab $selected = $secondpage; } } } } } /// Logout tab if needed if (page_theme_config('page_signouttab')) { $row[] = new tabobject('logout', "{$CFG->wwwroot}/login/logout.php?sesskey=" . sesskey(), get_string('signout', 'format_page')); } $tabs[] = $row; $tabs[] = $subrow; $output = '<div id="header-tabs" class="header-tabs">'; $output .= print_tabs($tabs, $selected, $inactive, null, true); if (page_theme_config('page_menutab') and $tabmenus) { foreach ($tabmenus as $tabmenu) { if (!empty($tabmenu->menuhtml)) { $class = 'menutreeroot'; } else { $class = 'nomenurender'; } $output .= "<div id=\"{$tabmenu->id}\" class=\"{$class}\">\n{$tabmenu->menuhtml}\n</div>\n"; } } $output .= '</div>'; if ($return) { return $output; } echo $output; } }