/** * Factory function page_create_object(). Called with a pagetype identifier and possibly with * its numeric ID. Returns a fully constructed page_base subclass you can work with. */ function page_create_object($type, $id = NULL) { global $CFG; $data = new stdClass(); $data->pagetype = $type; $data->pageid = $id; $classname = page_map_class($type); $object = new $classname(); // TODO: subclassing check here if ($object->get_type() !== $type) { // Somehow somewhere someone made a mistake debugging('Page object\'s type (' . $object->get_type() . ') does not match requested type (' . $type . ')'); } $object->init_quick($data); return $object; }
require_once $CFG->dirroot . '/course/lib.php'; // Needed for some blocks require_once $CFG->dirroot . '/course/format/page/pagelib.php'; // Needed for inheritance if (!defined('BLOCK_POS_CENTER')) { define('BLOCK_POS_CENTER', 'c'); } if (defined('ADMIN_STICKYBLOCKS')) { define('PAGE_FORMAT_LEARNING', 'format_learning'); page_map_class(PAGE_FORMAT_LEARNING, 'format_learning'); } /** * Remapping PAGE_COURSE_VIEW to format_page class * **/ page_map_class(PAGE_COURSE_VIEW, 'format_learning'); /** * Add the page types defined in this file * **/ $DEFINEDPAGES = array(PAGE_COURSE_VIEW); /** * Class that models the behavior of a format page * * @package format_page **/ class format_learning extends format_page { /** * Prints the tabs for the learning path type *
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package lesson **/ require_once $CFG->libdir . '/pagelib.php'; require_once $CFG->dirroot . '/course/lib.php'; // needed for some blocks /** * Define the page types * **/ define('PAGE_LESSON_VIEW', 'mod-lesson-view'); /** * Map the classes to the page types * **/ page_map_class(PAGE_LESSON_VIEW, 'page_lesson'); /** * Add the page types defined in this file * **/ $DEFINEDPAGES = array(PAGE_LESSON_VIEW); /** * Class that models the behavior of a lesson * * @author Mark Nielsen (lesson extention only) * @package lesson **/ class page_lesson extends page_generic_activity { /** * Module name
function get_format_name() { return MYVIEW_MOODLE_FORMAT; } } /** * Returns a turn edit on/off button for course in a self contained form. * Used to be an icon, but it's now a simple form button * * @uses $CFG * @uses $USER * @param int $courseid The course to update by id as found in 'course' table * @return string */ function update_myviewmoodle_icon() { global $CFG, $USER; if (!empty($USER->editing)) { $string = get_string('updatemymoodleoff'); $edit = '0'; } else { $string = get_string('updatemymoodleon'); $edit = '1'; } return "<form {$CFG->frametarget} method=\"get\" action=\"{$CFG->wwwroot}/myview/index.php\">" . "<div>" . "<input type=\"hidden\" name=\"edit\" value=\"{$edit}\" />" . "<input type=\"submit\" value=\"{$string}\" /></div></form>"; } define('PAGE_MYVIEW_MOODLE', 'myview-index'); define('MYVIEW_MOODLE_FORMAT', 'myview'); //doing this so we don't run into problems with applicable formats. page_map_class(PAGE_MYVIEW_MOODLE, 'page_myview_moodle');
} return $instance->position; } function get_format_name() { return TAG_FORMAT; } //----------- printing funtions ----------- function print_header() { global $USER, $CFG; $tag = $this->tag_object; $tagname = tag_display_name($tag); $navlinks = array(); $navlinks[] = array('name' => get_string('tags', 'tag'), 'link' => "{$CFG->wwwroot}/tag/search.php", 'type' => ''); $navlinks[] = array('name' => $tagname, 'link' => '', 'type' => ''); $navigation = build_navigation($navlinks); $title = get_string('tag', 'tag') . ' - ' . $tagname; $button = ''; if ($this->user_allowed_editing()) { $button = update_tag_button($this->id); } print_header_simple($title, '', $navigation, '', '', '', $button); } function print_footer() { print_footer(); } } page_map_class(PAGE_TAG_INDEX, 'page_tag');
/** * @deprecated since Moodle 2.0 * Do not use this any more. The global $PAGE is automatically created for you. * If you need custom behaviour, you should just set properties of that object. */ function page_create_object($type, $id = NULL) { global $CFG, $PAGE, $SITE, $ME; debugging('Call to deprecated function page_create_object.', DEBUG_DEVELOPER); $data = new stdClass; $data->pagetype = $type; $data->pageid = $id; $classname = page_map_class($type); if (!$classname) { return $PAGE; } $legacypage = new $classname; $legacypage->init_quick($data); $course = $PAGE->course; if ($course->id != $SITE->id) { $legacypage->set_course($course); } else { try { $category = $PAGE->category; } catch (coding_exception $e) { // Was not set before, so no need to try to set it again. $category = false; } if ($category) { $legacypage->set_category_by_id($category->id); } else { $legacypage->set_course($SITE); } } $legacypage->set_pagetype($type); $legacypage->set_url($ME); $PAGE->set_url(str_replace($CFG->wwwroot . '/', '', $legacypage->url_get_full())); $PAGE->set_pagetype($type); $PAGE->set_legacy_page_object($legacypage); return $PAGE; }
<?php // $Id: pagelib.php,v 1.5 2012/07/25 11:16:04 bdaloukas Exp $ require_once $CFG->libdir . '/pagelib.php'; require_once $CFG->dirroot . '/course/lib.php'; // needed for some blocks define('PAGE_GAME_VIEW', 'mod-game-view'); page_map_class(PAGE_GAME_VIEW, 'page_game'); $DEFINEDPAGES = array(PAGE_GAME_VIEW); /** * Class that models the behavior of a game * * @author Jon Papaioannou * @package pages */ class page_game extends page_generic_activity { function init_quick($data) { if (empty($data->pageid)) { print_error('Cannot quickly initialize page: empty course id'); } $this->activityname = 'game'; parent::init_quick($data); } function print_header($title, $morebreadcrumbs = NULL, $navigation = '') { global $USER, $CFG; $this->init_full(); $replacements = array('%fullname%' => format_string($this->activityrecord->name)); foreach ($replacements as $search => $replace) {
// // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License version 2 as // // published by the Free Software Foundation. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details: // // // // http://www.gnu.org/licenses/old-licenses/gpl-2.0.html // // // /////////////////////////////////////////////////////////////////////////// require_once $CFG->libdir . '/pagelib.php'; define('PAGE_bigbluebutton_VIEW', 'mod-bigbluebutton-view'); page_map_class(PAGE_bigbluebutton_VIEW, 'page_bigbluebutton'); $DEFINEDPAGES = array(PAGE_bigbluebutton_VIEW); /** * Class that models the behavior of a Web conference * * @package pages */ class page_bigbluebutton extends page_generic_activity { function init_quick($data) { if (empty($data->pageid)) { error('Cannot quickly initialize page: empty course id'); } $this->activityname = 'bigbluebutton'; parent::init_quick($data);
{ return PAGE_MY_COLLABORATION; } function print_header($title) { global $USER, $CFG; $replacements = array('%fullname%' => get_string('mycollaboration', 'local')); foreach ($replacements as $search => $replace) { $title = str_replace($search, $replace, $title); } $site = get_site(); $nav = get_string('mycollaboration', 'local'); $header = $site->shortname . ': ' . $nav; $navlinks = array(array('name' => $nav, 'link' => '', 'type' => 'misc')); $navigation = build_navigation($navlinks); print_header($title, $header, $navigation, '', '', true); } function url_get_path() { global $CFG; page_id_and_class($id, $class); if ($id == PAGE_MY_MOODLE) { return $CFG->wwwroot . '/my/local/collaboration.php'; } elseif (defined('ADMIN_STICKYBLOCKS')) { return $CFG->wwwroot . '/' . $CFG->admin . '/stickyblocks.php'; } } } define('PAGE_MY_COLLABORATION', 'my-collaboration'); page_map_class(PAGE_MY_COLLABORATION, 'page_my_collaboration');
<?php // $Id: pagelib.php,v 1.10 2007/04/16 20:59:17 mattc-catalyst Exp $ require_once $CFG->libdir . '/pagelib.php'; define('PAGE_CHAT_VIEW', 'mod-chat-view'); page_map_class(PAGE_CHAT_VIEW, 'page_chat'); $DEFINEDPAGES = array(PAGE_CHAT_VIEW); /** * Class that models the behavior of a chat * * @author Jon Papaioannou * @package pages */ class page_chat extends page_generic_activity { function init_quick($data) { if (empty($data->pageid)) { error('Cannot quickly initialize page: empty course id'); } $this->activityname = 'chat'; parent::init_quick($data); } function get_type() { return PAGE_CHAT_VIEW; } }
} return ''; } function url_get_parameters() { if (defined('ADMIN_STICKYBLOCKS')) { return array('pt' => 'tao'); } } function print_header($title, $morenavlinks = NULL) { $nav = build_navigation($morenavlinks); print_header($title, $title, $nav); } } page_map_class('tao', 'tao_page_class_hack'); /** * local footer hook. nothing yet but this could print right blocks */ function tao_local_footer_hook() { if (!defined('TAO_HEADER_OVERRIDDEN')) { return; } echo '</td></tr></table>'; } /** * print out the TAO nav section */ function tao_print_static_nav($return = false) {
<?php // $Id: pagelib.php,v 1.14.4.1 2007/11/02 16:19:58 tjhunt Exp $ require_once $CFG->libdir . '/pagelib.php'; require_once $CFG->dirroot . '/course/lib.php'; // needed for some blocks define('PAGE_CASECOURSEWARE_VIEW', 'mod-casecourseware-v'); page_map_class(PAGE_CASECOURSEWARE_VIEW, 'page_casecourseware'); $DEFINEDPAGES = array(PAGE_CASECOURSEWARE_VIEW); /** * Class that models the behavior of a quiz * * @author Jon Papaioannou * @package pages */ class page_casecourseware extends page_generic_activity { function init_quick($data) { if (empty($data->pageid)) { error('Cannot quickly initialize page: empty course id'); } $this->activityname = 'casecourseware'; parent::init_quick($data); } function get_type() { return PAGE_CASECOURSEWARE_VIEW; } // BLOCKS RELATED SECTION // Which are the positions in this page which support blocks? Return an array containing their identifiers.
<?php // $Id: pagelib.php,v 1.14.4.1 2007/11/02 16:19:58 tjhunt Exp $ require_once $CFG->libdir . '/pagelib.php'; require_once $CFG->dirroot . '/course/lib.php'; // needed for some blocks define('PAGE_QUIZ_VIEW', 'mod-quiz-view'); page_map_class(PAGE_QUIZ_VIEW, 'page_quiz'); $DEFINEDPAGES = array(PAGE_QUIZ_VIEW); /** * Class that models the behavior of a quiz * * @author Jon Papaioannou * @package pages */ class page_quiz extends page_generic_activity { function init_quick($data) { if (empty($data->pageid)) { error('Cannot quickly initialize page: empty course id'); } $this->activityname = 'quiz'; parent::init_quick($data); } function get_type() { return PAGE_QUIZ_VIEW; } }
* * @author Mark Nielsen * @version $Id$ * @package format_page **/ require_once $CFG->libdir . '/pagelib.php'; require_once $CFG->dirroot . '/course/lib.php'; // Needed for some blocks if (!defined('BLOCK_POS_CENTER')) { define('BLOCK_POS_CENTER', 'c'); } /** * Remapping PAGE_COURSE_VIEW to format_page class * **/ page_map_class(PAGE_COURSE_VIEW, 'format_page'); /** * Add the page types defined in this file * **/ $DEFINEDPAGES = array(PAGE_COURSE_VIEW); /** * Class that models the behavior of a format page * * @package format_page **/ class format_page extends page_course { /** * Full format_page db record *
<?php require_once $CFG->libdir . '/pagelib.php'; require_once $CFG->dirroot . '/course/lib.php'; // needed for some blocks define('PAGE_FORUMNG_VIEW', 'mod-forumng-view'); page_map_class(PAGE_FORUMNG_VIEW, 'page_forumng_view'); $DEFINEDPAGES = array(PAGE_FORUMNG_VIEW); class page_forumng_view extends page_generic_activity { function get_type() { return PAGE_FORUMNG_VIEW; } function init_quick($data) { if (empty($data->pageid)) { error('Cannot quickly initialize page: empty course id'); } $this->activityname = 'forumng'; parent::init_quick($data); } function init_full() { global $CURRENTFORUM; if ($this->full_init_done) { return; } $this->modulerecord = $CURRENTFORUM->get_course_module(); $this->modulerecord->section = get_field('course_modules', 'section', 'id', $this->modulerecord->id); $this->courserecord = $CURRENTFORUM->get_course();
// Bounds for block widths // more flexible for theme designers taken from theme config.php $lmin = empty($THEME->block_l_min_width) ? 160 : $THEME->block_l_min_width; $lmax = empty($THEME->block_l_max_width) ? 210 : $THEME->block_l_max_width; $rmin = empty($THEME->block_r_min_width) ? 160 : $THEME->block_r_min_width; $rmax = empty($THEME->block_r_max_width) ? 210 : $THEME->block_r_max_width; define('BLOCK_L_MIN_WIDTH', $lmin); define('BLOCK_L_MAX_WIDTH', $lmax); define('BLOCK_R_MIN_WIDTH', $rmin); define('BLOCK_R_MAX_WIDTH', $rmax); //_____________ new page class code ________ $pagetype = PAGE_BLOG_VIEW; $pageclass = 'page_blog'; // map our page identifier to the actual name // of the class which will be handling its operations. page_map_class($pagetype, $pageclass); // Now, create our page object. if (empty($USER->id)) { $PAGE = page_create_object($pagetype); } else { $PAGE = page_create_object($pagetype, $USER->id); } $PAGE->courseid = $courseid; $PAGE->filtertype = $filtertype; $PAGE->filterselect = $filterselect; $PAGE->tagid = $tagid; $PAGE->init_full(); //init the BlogInfo object and the courserecord object $editing = false; if ($PAGE->user_allowed_editing()) { $editing = $PAGE->user_is_editing();
<?php // $Id: pagelib.php,v 1.10 2007/07/05 04:41:07 mattc-catalyst Exp $ require_once $CFG->libdir . '/pagelib.php'; require_once $CFG->dirroot . '/course/lib.php'; // needed for some blocks define('PAGE_DATA_VIEW', 'mod-data-view'); page_map_class(PAGE_DATA_VIEW, 'page_data'); $DEFINEDPAGES = array(PAGE_DATA_VIEW); /* */ /** * Class that models the behavior of a data * * @author Jon Papaioannou * @package pages */ class page_data extends page_generic_activity { function init_quick($data) { if (empty($data->pageid)) { error('Cannot quickly initialize page: empty course id'); } $this->activityname = 'data'; parent::init_quick($data); } function print_header($title, $morenavlinks = NULL, $meta) { parent::print_header($title, $morenavlinks, '', $meta); }
* (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details: * * * * http://www.gnu.org/copyleft/gpl.html * * * * * * * ************************************************************************** */ require_once $CFG->libdir . '/pagelib.php'; define('PAGE_dimdim_VIEW', 'mod-dimdim-view'); page_map_class(PAGE_dimdim_VIEW, 'page_dimdim'); $DEFINEDPAGES = array(PAGE_dimdim_VIEW); /** * Class that models the behavior of a dimdim * * @author Jon Papaioannou * @package pages */ class page_dimdim extends page_generic_activity { function init_quick($data) { if (empty($data->pageid)) { error('Cannot quickly initialize page: empty course id'); } $this->activityname = 'dimdim';
/** * Initialise admin page - this function does require login and permission * checks specified in page definition. * This function must be called on each admin page before other code. * @param string $section name of page */ function admin_externalpage_setup($section) { global $CFG, $PAGE, $USER; require_once $CFG->libdir . '/blocklib.php'; require_once $CFG->dirroot . '/' . $CFG->admin . '/pagelib.php'; if ($site = get_site()) { require_login(); } else { redirect($CFG->wwwroot . '/' . $CFG->admin . '/index.php'); die; } $adminroot =& admin_get_root(false, false); // settings not required for external pages $extpage =& $adminroot->locate($section); if (empty($extpage) or !is_a($extpage, 'admin_externalpage')) { error(get_string('sectionerror', 'admin'), "{$CFG->wwwroot}/{$CFG->admin}/"); die; } // this eliminates our need to authenticate on the actual pages if (!$extpage->check_access()) { error(get_string('accessdenied', 'admin')); die; } page_map_class(PAGE_ADMIN, 'page_admin'); $PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id number $PAGE->init_extra($section); // hack alert! $adminediting = optional_param('adminedit', -1, PARAM_BOOL); if (!isset($USER->adminediting)) { $USER->adminediting = false; } if ($PAGE->user_allowed_editing()) { if ($adminediting == 1) { $USER->adminediting = true; } elseif ($adminediting == 0) { $USER->adminediting = false; } } }
<?php //$Id: pagelib.php,v 1.8 2008/08/25 08:20:28 pigui Exp $ //html functions require_once $CFG->dirroot . '/mod/wiki/weblib.php'; require_once $CFG->libdir . '/pagelib.php'; define('PAGE_WIKI_VIEW', 'mod-wiki-view'); page_map_class(PAGE_WIKI_VIEW, 'page_wiki'); $DEFINEDPAGES = array(PAGE_WIKI_VIEW); class page_wiki extends page_generic_activity { //it overrides blocks_move_position(), to move blocks in a wiki activity function blocks_move_position(&$instance, $move) { if ($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) { return BLOCK_POS_RIGHT; } else { if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) { return BLOCK_POS_LEFT; } } return $instance->position; } //it returns the type class (future elimination) function get_type() { return PAGE_WIKI_VIEW; } // Do any validation of the officially recognized bits of the data and forward to parent. // Do NOT load up "expensive" resouces (e.g. SQL data) here! function init_quick($data)
case 'site': redirect("{$CFG->wwwroot}/"); case 'admin': redirect("{$CFG->wwwroot}/{$CFG->admin}/"); } } else { $errormsg = get_string('errorwithsettings', 'admin'); $firsterror = reset($adminroot->errors); $focus = $firsterror->id; } $adminroot =& admin_get_root(true); //reload tree $page =& $adminroot->locate($section); } /// very hacky page setup page_map_class(PAGE_ADMIN, 'page_admin'); $PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id number $PAGE->init_extra($section); $CFG->pagepath = 'admin/setting/' . $section; if (!isset($USER->adminediting)) { $USER->adminediting = false; } if ($PAGE->user_allowed_editing()) { if ($adminediting == 1) { $USER->adminediting = true; } elseif ($adminediting == 0) { $USER->adminediting = false; } } /// print header stuff ------------------------------------------------------------
<?php // $Id: pagelib.php,v 1.14.4.1 2007/11/02 16:19:58 tjhunt Exp $ require_once $CFG->libdir . '/pagelib.php'; require_once $CFG->dirroot . '/course/lib.php'; // needed for some blocks define('PAGE_QUIZ_VIEW_EMBEDDED', 'mod-quiz-view-embedded'); page_map_class(PAGE_QUIZ_VIEW_EMBEDDED, 'page_quiz_embedded'); $DEFINEDPAGES = array(PAGE_QUIZ_VIEW_EMBEDDED); /** * Class that models the behavior of an embedded quiz * * @author Jon Papaioannou * @package pages */ class page_quiz_embedded extends page_generic_activity { function init_quick($data) { if (empty($data->pageid)) { error('Cannot quickly initialize page: empty course id'); } $this->activityname = 'quiz'; parent::init_quick($data); } function get_type() { return PAGE_QUIZ_VIEW_EMBEDDED; } }
} } function blocks_default_position() { return BLOCK_POS_LEFT; } function blocks_get_positions() { return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT); } function blocks_move_position(&$instance, $move) { if ($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) { return BLOCK_POS_RIGHT; } else { if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) { return BLOCK_POS_LEFT; } } return $instance->position; } function get_format_name() { return MY_MOODLE_FORMAT; } } define('PAGE_MY_MOODLE', 'my-index'); define('MY_MOODLE_FORMAT', 'my'); //doing this so we don't run into problems with applicable formats. page_map_class(PAGE_MY_MOODLE, 'page_my_moodle');
<?php require_once $CFG->libdir . '/pagelib.php'; require_once $CFG->dirroot . '/course/lib.php'; // needed for some blocks define('PAGE_OUBLOG_VIEW', 'mod-oublog-view'); //define('PAGE_FORUM_DISCUSS', 'mod-forum-discuss'); page_map_class(PAGE_OUBLOG_VIEW, 'page_oublog_view'); //page_map_class(PAGE_FORUM_DISCUSS,'page_forum_discuss'); //$DEFINEDPAGES = array(PAGE_FORUM_VIEW,PAGE_FORUM_DISCUSS); $DEFINEDPAGES = array(PAGE_OUBLOG_VIEW); class page_oublog_view extends page_generic_activity { var $navblockinstance = NULL; function get_type() { return PAGE_OUBLOG_VIEW; } function init_quick($data) { if (empty($data->pageid)) { error('Cannot quickly initialize page: empty course id'); } $this->activityname = 'oublog'; parent::init_quick($data); } }