本文整理汇总了PHP中page_create_instance函数的典型用法代码示例。如果您正苦于以下问题:PHP page_create_instance函数的具体用法?PHP page_create_instance怎么用?PHP page_create_instance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了page_create_instance函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: print_header
/**
* Prints the page header.
*/
function print_header()
{
global $CFG, $USER, $PAGE;
require_once $CFG->libdir . '/blocklib.php';
require_once $CFG->dirroot . '/course/lib.php';
require_once $CFG->dirroot . '/my/pagelib.php';
/// My Moodle arguments:
$edit = optional_param('edit', -1, PARAM_BOOL);
$blockaction = optional_param('blockaction', '', PARAM_ALPHA);
$mymoodlestr = get_string('mymoodle', 'my');
if (isguest()) {
$wwwroot = $CFG->wwwroot . '/login/index.php';
if (!empty($CFG->loginhttps)) {
$wwwroot = str_replace('http:', 'https:', $wwwroot);
}
print_header($mymoodlestr);
notice_yesno(get_string('noguest', 'my') . '<br /><br />' . get_string('liketologin'), $wwwroot, $CFG->wwwroot);
print_footer();
die;
}
/// Add curriculum stylesheets...
if (file_exists($CFG->dirroot . '/curriculum/styles.css')) {
$CFG->stylesheets[] = $CFG->wwwroot . '/curriculum/styles.css';
}
/// Fool the page library into thinking we're in My Moodle.
$CFG->pagepath = $CFG->wwwroot . '/my/index.php';
$PAGE = page_create_instance($USER->id);
if ($section = optional_param('section', '', PARAM_ALPHAEXT)) {
$PAGE->section = $section;
}
$this->pageblocks = blocks_setup($PAGE, BLOCKS_PINNED_BOTH);
/// Make sure that the curriculum block is actually on this
/// user's My Moodle page instance.
if ($cablockid = get_field('block', 'id', 'name', 'curr_admin')) {
if (!record_exists('block_pinned', 'blockid', $cablockid, 'pagetype', 'my-index')) {
blocks_execute_action($PAGE, $this->pageblocks, 'add', (int) $cablockid, true, false);
}
}
if ($edit != -1 and $PAGE->user_allowed_editing()) {
$USER->editing = $edit;
}
//$PAGE->print_header($mymoodlestr);
$title = $this->get_title();
print_header($title, $title, build_navigation($this->get_navigation()));
echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
echo '<tr valign="top">';
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($this->pageblocks[BLOCK_POS_LEFT]), 210);
if (blocks_have_content($this->pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing()) {
echo '<td style="vertical-align: top; width: ' . $blocks_preferred_width . 'px;" id="left-column">';
blocks_print_group($PAGE, $this->pageblocks, BLOCK_POS_LEFT);
echo '</td>';
}
echo '<td valign="top" id="middle-column">';
if (blocks_have_content($this->pageblocks, BLOCK_POS_CENTRE) || $PAGE->user_is_editing()) {
blocks_print_group($PAGE, $this->pageblocks, BLOCK_POS_CENTRE);
}
}
示例2: optional_param
$SESSION->dataprefs[$data->id]['sort'] = $sort;
// Make it sticky
$order = optional_param('order', $SESSION->dataprefs[$data->id]['order'], PARAM_ALPHA) == 'ASC' ? 'ASC' : 'DESC';
$SESSION->dataprefs[$data->id]['order'] = $order;
// Make it sticky
$oldperpage = get_user_preferences('data_perpage_' . $data->id, 10);
$perpage = optional_param('perpage', $oldperpage, PARAM_INT);
if ($perpage < 2) {
$perpage = 2;
}
if ($perpage != $oldperpage) {
set_user_preference('data_perpage_' . $data->id, $perpage);
}
add_to_log($course->id, 'data', 'view', "view.php?id={$cm->id}", $data->id, $cm->id);
// Initialize $PAGE, compute blocks
$PAGE = page_create_instance($data->id);
$pageblocks = blocks_setup($PAGE);
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
if ($edit != -1 and $PAGE->user_allowed_editing()) {
$USER->editing = $edit;
}
/// RSS and CSS and JS meta
$meta = '';
if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) {
$rsspath = rss_get_url($course->id, $USER->id, 'data', $data->id);
$meta .= '<link rel="alternate" type="application/rss+xml" ';
$meta .= 'title ="' . format_string($course->shortname) . ': %fullname%" href="' . $rsspath . '" />';
}
if ($data->csstemplate) {
$meta .= '<link rel="stylesheet" type="text/css" href="' . $CFG->wwwroot . '/mod/data/css.php?d=' . $data->id . '" /> ';
}
示例3: build_navigation
if (isguestuser()) {
$navigation = build_navigation('', $cm);
print_header_simple(format_string($chat->name), '', $navigation, '', '', true, '', navmenu($course, $cm));
$wwwroot = $CFG->wwwroot . '/login/index.php';
if (!empty($CFG->loginhttps)) {
$wwwroot = str_replace('http:', 'https:', $wwwroot);
}
notice_yesno(get_string('noguests', 'chat') . '<br /><br />' . get_string('liketologin'), $wwwroot, $CFG->wwwroot . '/course/view.php?id=' . $course->id);
print_footer($course);
exit;
} else {
require_capability('mod/chat:chat', $context);
}
add_to_log($course->id, 'chat', 'view', "view.php?id={$cm->id}", $chat->id, $cm->id);
// Initialize $PAGE, compute blocks
$PAGE = page_create_instance($chat->id);
$pageblocks = blocks_setup($PAGE);
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
/// Print the page header
$strenterchat = get_string('enterchat', 'chat');
$stridle = get_string('idle', 'chat');
$strcurrentusers = get_string('currentusers', 'chat');
$strnextsession = get_string('nextsession', 'chat');
if ($edit != -1 and $PAGE->user_allowed_editing()) {
$USER->editing = $edit;
}
$PAGE->print_header($course->shortname . ': %fullname%');
echo '<table id="layout-table"><tr>';
$lt = empty($THEME->layouttable) ? array('left', 'middle', 'right') : $THEME->layouttable;
foreach ($lt as $column) {
switch ($column) {
示例4: require_login
}
$game->showtimetaken = 1;
//check bdaloukas
$game->timelimit = 0;
//check bdaloukas
$game->timeclose = 0;
//check bdaloukas
// Check login and get context.
require_login($course->id, false, $cm);
if ($USER->username == 'guest') {
redirect("{$CFG->wwwroot}/mod/game/attempt.php?id={$id}");
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
add_to_log($course->id, "game", "view", "view.php?id={$cm->id}", $game->id, $cm->id);
// Initialize $PAGE, compute blocks
$PAGE = page_create_instance($game->id);
$pageblocks = blocks_setup($PAGE);
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
// Print the page header
if ($edit != -1 and $PAGE->user_allowed_editing()) {
$USER->editing = $edit;
}
//only check pop ups if the user is not a teacher, and popup is set
if (function_exists('build_navigation')) {
//for version 1.9
$navigation = build_navigation('', $cm);
$PAGE->print_header($course->shortname . ': %fullname%', '', $navigation);
} else {
if ($course->category) {
$navigation = "<a href=\"{$CFG->wwwroot}/course/view.php?id={$course->id}\">{$course->shortname}</a> ->";
} else {
示例5: error
error("The course with id {$quiz->course} that the quiz with id {$q} belongs to is missing");
}
if (!($cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id))) {
error("The course module for the quiz with id {$q} is missing");
}
}
// Check login and get context.
require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
// if no questions have been set up yet redirect to edit.php
if (!$quiz->questions and has_capability('mod/quiz:manage', $context)) {
redirect($CFG->wwwroot . '/mod/quiz/edit.php?cmid=' . $cm->id);
}
add_to_log($course->id, "quiz", "view", "view.php?id={$cm->id}", $quiz->id, $cm->id);
// Initialize $PAGE, compute blocks
$PAGE = page_create_instance($quiz->id);
$pageblocks = blocks_setup($PAGE);
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
// Print the page header
if ($edit != -1 and $PAGE->user_allowed_editing()) {
$USER->editing = $edit;
}
//only check pop ups if the user is not a teacher, and popup is set
$bodytags = has_capability('mod/quiz:attempt', $context) && $quiz->popup ? 'onload="popupchecker(\'' . get_string('popupblockerwarning', 'quiz') . '\');"' : '';
$PAGE->print_header($course->shortname . ': %fullname%', '', $bodytags);
echo '<table id="layout-table"><tr>';
if (!empty($CFG->showblocksonmodpages) && (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing())) {
echo '<td style="width: ' . $blocks_preferred_width . 'px;" id="left-column">';
print_container_start();
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
print_container_end();
示例6: error
// bigbluebutton_update_bigbluebutton_times($c);
if (!($bigbluebutton = get_record('bigbluebutton', 'id', $c))) {
error('The course module ID is incorrect.');
}
if (!($course = get_record('course', 'id', $bigbluebutton->course))) {
error('The course is misconfigured.');
}
if (!($cm = get_coursemodule_from_instance('bigbluebutton', $bigbluebutton->id, $course->id))) {
error('The module ID is incorrect.');
}
}
require_course_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
add_to_log($course->id, 'bigbluebutton', 'view', "view.php?id={$cm->id}", $bigbluebutton->id, $cm->id);
/// Initialize $PAGE
$PAGE = page_create_instance($bigbluebutton->id);
$pageblocks = blocks_setup($PAGE);
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
/// Print the page header
$strnextsession = get_string('nextsession', 'bigbluebutton');
if (!empty($edit) && $PAGE->user_allowed_editing()) {
if ($edit == 'on') {
$USER->editing = true;
} else {
if ($edit == 'off') {
$USER->editing = false;
}
}
}
$PAGE->print_header($course->shortname . ': %fullname%');
echo '<table id="layout-table"><tr>';
示例7: get_string
// Get update button, if allowed for current user
$strforum = get_string("modulename", "forum");
$buttontext = $forum->display_search_form();
// Atom header meta tag
$feedtype = $forum->get_effective_feed_option();
if ($feedtype == forum::FEEDTYPE_DISCUSSIONS || $feedtype == forum::FEEDTYPE_ALL_POSTS && $forum->can_view_discussions()) {
$atomurl = $forum->get_feed_url(forum::FEEDFORMAT_ATOM, $groupid);
$meta = '<link rel="alternate" type="application/atom+xml" ' . 'title="Atom feed" href="' . htmlspecialchars($atomurl) . '" />';
} else {
$meta = '';
}
// Initialize $PAGE, compute blocks
require_once $CFG->dirroot . '/mod/forumng/pagelib.php';
global $CURRENTFORUM;
$CURRENTFORUM = $forum;
$PAGE = page_create_instance($forum->get_id());
$pageblocks = blocks_setup($PAGE);
if (class_exists('ouflags') && ou_get_is_mobile()) {
ou_mobile_configure_theme();
}
// Check for editing on/off button presses
if ($PAGE->user_allowed_editing()) {
$edit = optional_param('edit', -1, PARAM_BOOL);
$goback = false;
if (class_exists('ouflags')) {
// OU only: support edit locking and per-course editing
$resetlock = optional_param('resetlock', 0, PARAM_BOOL);
if ($edit != -1 || $resetlock == 1) {
// Update user editing status
updateediting($edit, $resetlock, $course);
$goback = true;
示例8: stdClass
if ($gradeinfo->attempts) {
if ($gradeinfo->nquestions < $lesson->minquestions) {
$a = new stdClass();
$a->nquestions = $gradeinfo->nquestions;
$a->minquestions = $lesson->minquestions;
lesson_set_message(get_string('numberofpagesviewednotice', 'lesson', $a));
}
lesson_set_message(get_string("numberofcorrectanswers", "lesson", $gradeinfo->earned), 'notify');
$a = new stdClass();
$a->grade = number_format($gradeinfo->grade * $lesson->grade / 100, 1);
$a->total = $lesson->grade;
lesson_set_message(get_string('yourcurrentgradeisoutof', 'lesson', $a), 'notify');
}
}
}
$PAGE = page_create_instance($lesson->id);
$PAGE->set_lessonpageid($page->id);
$pageblocks = blocks_setup($PAGE);
$leftcolumnwidth = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
$rightcolumnwidth = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
if ($edit != -1 and $PAGE->user_allowed_editing()) {
$USER->editing = $edit;
}
/// Print the page header, heading and tabs
$PAGE->print_header();
if ($attemptflag) {
print_heading(get_string('attempt', 'lesson', $retries + 1));
}
/// This calculates and prints the ongoing score
if ($lesson->ongoing and !empty($pageid)) {
lesson_print_ongoing_score($lesson);
示例9: print_header
// to users who can post
$hideunusedblog = !$posts && !$canpost && !$canaudit;
if ($hideunusedblog) {
print_header();
} else {
$navigation = oublog_build_navigation($cm, $oublog, $oubloginstance, $oubloguser, $extranav);
print_header_simple(format_string($oublog->name), "", $navigation, "", oublog_get_meta_tags($oublog, $oubloginstance, $currentgroup, $cm), true, $buttontext, navmenu($course, $cm));
}
} else {
$navigation = oublog_build_navigation($cm, $oublog, $oubloginstance, null, $extranav);
print_header_simple(format_string($oublog->name), "", $navigation, "", oublog_get_meta_tags($oublog, $oubloginstance, $currentgroup, $cm), true, $buttontext, navmenu($course, $cm));
}
print '<div class="oublog-topofpage"></div>';
require_once dirname(__FILE__) . '/pagelib.php';
// Initialize $PAGE, compute blocks
$PAGE = page_create_instance($oublog->id);
$pageblocks = blocks_setup($PAGE);
$editing = isediting($cm->course);
if (class_exists('ouflags') && ou_get_is_mobile() && $blogdets == 'show') {
print '<div id="middle-column">';
ou_print_mobile_navigation($id, $blogdets, null, $user);
} else {
// The left column ...
if ($hasleft = !empty($CFG->showblocksonmodpages) && (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing)) {
print '<div id="left-column">';
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
print '</div>';
}
print '</div>';
// fix mixed columns in rtl mode and editing mode (nadavkav patch)
// The right column, BEFORE the middle-column.
示例10: dimdim_update_dimdim_times
dimdim_update_dimdim_times($c);
if (!($dimdim = get_record('dimdim', 'id', $c))) {
error('Course module is incorrect');
}
if (!($course = get_record('course', 'id', $dimdim->course))) {
error('Course is misconfigured');
}
if (!($cm = get_coursemodule_from_instance('dimdim', $dimdim->id, $course->id))) {
error('Course Module ID was incorrect');
}
}
require_course_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
add_to_log($course->id, 'dimdim', 'view', "view.php?id={$cm->id}", $dimdim->id, $cm->id);
// Initialize $PAGE, compute blocks
$PAGE = page_create_instance($dimdim->id);
$pageblocks = blocks_setup($PAGE);
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
/// Print the page header
$strnextsession = get_string('nextsession', 'dimdim');
if (!empty($edit) && $PAGE->user_allowed_editing()) {
if ($edit == 'on') {
$USER->editing = true;
} else {
if ($edit == 'off') {
$USER->editing = false;
}
}
}
$PAGE->print_header($course->shortname . ': %fullname%');
echo '<table id="layout-table"><tr>';