本文整理汇总了PHP中moodle_page类的典型用法代码示例。如果您正苦于以下问题:PHP moodle_page类的具体用法?PHP moodle_page怎么用?PHP moodle_page使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了moodle_page类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_customusersetthemectx
/**
* Test custom userset theme assignment.
*/
public function test_customusersetthemectx()
{
$this->load_csv_data();
// ELIS user with the associated moodle user.
$user = new user(103);
$muser = $user->get_moodleuser();
// Userset with a custom theme.
$userset = new userset(1);
$userset->field__elis_userset_theme = 'formal_white';
$userset->field__elis_userset_themepriority = 1;
$userset->save();
// Assign the user to the user set.
$usersetassign = new clusterassignment();
$usersetassign->userid = $user->id;
$usersetassign->clusterid = $userset->id;
$usersetassign->save();
// Pretend to be that user.
$this->setUser($muser->id);
// Initialize page.
$page = new moodle_page();
$page->initialise_theme_and_output();
// Assert we have our theme.
$this->assertEquals('formal_white', $page->theme->name);
$this->setUser(null);
}
示例2: xmldb_block_calendar_month_upgrade
/**
* Upgrade the calendar_month block
* @param int $oldversion
* @param object $block
*/
function xmldb_block_calendar_month_upgrade($oldversion, $block)
{
global $DB;
if ($oldversion < 2014062600) {
// Add this block the default blocks on /my.
$blockname = 'calendar_month';
// Do not try to add the block if we cannot find the default my_pages entry.
// Private => 1 refers to MY_PAGE_PRIVATE.
if ($systempage = $DB->get_record('my_pages', array('userid' => null, 'private' => 1))) {
$page = new moodle_page();
$page->set_context(context_system::instance());
// Check to see if this block is already on the default /my page.
$criteria = array('blockname' => $blockname, 'parentcontextid' => $page->context->id, 'pagetypepattern' => 'my-index', 'subpagepattern' => $systempage->id);
if (!$DB->record_exists('block_instances', $criteria)) {
// Add the block to the default /my.
$page->blocks->add_region(BLOCK_POS_RIGHT);
$page->blocks->add_block($blockname, BLOCK_POS_RIGHT, 0, false, 'my-index', $systempage->id);
}
}
upgrade_block_savepoint(true, 2014062600, $blockname);
}
// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.
return true;
}
示例3: get_block_manager
/**
* Returns the block manager for a given course.
*/
private function get_block_manager($course)
{
$page = new \moodle_page();
$page->set_context(\context_course::instance($course->id));
$page->set_pagetype('course-view-*');
return new \block_manager($page);
}
示例4: get_format_renderer
/**
* @param moodle_page the page we are outputting to.
* @return qtype_poodllrecording_format_renderer_base the response-format-specific renderer.
*/
public function get_format_renderer(moodle_page $page)
{
//Nadav reported a possible problem here, I can't reproduce it, but hope this fixes it.
//https://github.com/justinhunt/moodle-qtype_poodllrecording/issues/1
if ($this->responseformat == 'editor') {
$this->responseformat = 'picture';
}
return $page->get_renderer('qtype_poodllrecording', 'format_' . $this->responseformat);
}
示例5: xmldb_block_eexcess_install
/**
* Adds eexcess block on eexcess user settings pages.
*/
function xmldb_block_eexcess_install()
{
$page = new moodle_page();
$page->set_context(context_system::instance());
$page->blocks->add_region(BLOCK_POS_LEFT);
$page->blocks->add_block('eexcess', BLOCK_POS_LEFT, 0, false, 'blocks-eexcess-eexcess_citation', null);
$page->blocks->add_block('eexcess', BLOCK_POS_LEFT, 0, false, 'blocks-eexcess-eexcess_interests', null);
$page->blocks->add_block('eexcess', BLOCK_POS_LEFT, 0, false, 'blocks-eexcess-eexcess_image_license', null);
}
示例6: testDisplayIndex
function testDisplayIndex()
{
global $USER;
$this->resetAfterTest(true);
$PAGE = new moodle_page();
$PAGE->set_context(context_system::instance());
$this->setAdminUser();
$USER->editing = 1;
$out = "";
$this->assertContains("something", $out);
}
示例7: page_set_course
/**
* Allows course format to execute code on moodle_page::set_course()
*
* If user is on course view page and there is no scorm module added to the course
* and the user has 'moodle/course:update' capability, redirect to create module
* form. This function is executed before the output starts
*
* @param moodle_page $page instance of page calling set_course
*/
public function page_set_course(moodle_page $page)
{
global $PAGE;
if ($PAGE == $page && $page->has_set_url() && $page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
$modinfo = get_fast_modinfo($this->courseid);
if (empty($modinfo->instances['scorm']) && has_capability('moodle/course:update', context_course::instance($this->courseid))) {
// Redirect to create a new activity
$url = new moodle_url('/course/modedit.php', array('course' => $this->courseid, 'section' => 0, 'add' => 'scorm'));
redirect($url);
}
}
}
示例8: xmldb_local_iomad_dashboard_install
function xmldb_local_iomad_dashboard_install()
{
global $SITE;
// Add some default blocks to the dashboard
// yes, I know this isn't really what this is for!!
$systemcontext = context_system::instance();
$page = new moodle_page();
$page->set_context($systemcontext);
$page->set_pagetype('local-iomad-dashboard-index');
$page->set_pagelayout('mydashboard');
$page->blocks->add_region('content');
$defaultblocks = array('side_pre' => array('course_list'), 'content' => array('iomad_company_admin', 'iomad_reports'), 'side_post' => array('news_items'));
$page->blocks->add_blocks($defaultblocks);
return true;
}
示例9: test_update_user_profile_image
/**
* Test the update user profile image function.
*/
public function test_update_user_profile_image()
{
global $DB, $CFG;
// Set the profile image.
\enrol_lti\helper::update_user_profile_image($this->user1->id, $this->getExternalTestFileUrl('/test.jpg'));
// Get the new user record.
$this->user1 = $DB->get_record('user', array('id' => $this->user1->id));
// Set the page details.
$page = new moodle_page();
$page->set_url('/user/profile.php');
$page->set_context(context_system::instance());
$renderer = $page->get_renderer('core');
$usercontext = context_user::instance($this->user1->id);
// Get the user's profile picture and make sure it is correct.
$userpicture = new user_picture($this->user1);
$this->assertSame($CFG->wwwroot . '/pluginfile.php/' . $usercontext->id . '/user/icon/clean/f2?rev=' . $this->user1->picture, $userpicture->get_url($page, $renderer)->out(false));
}
示例10: __construct
/**
* Constructor
*
* The constructor takes two arguments. The first is the page that the renderer
* has been created to assist with, and the second is the target.
* The target is an additional identifier that can be used to load different
* renderers for different options.
*
* In order to create and initialize the appropriate arrays for resources, activities, assignments and icons,
* we must update the declared constructor of the parent class, and since we can't just update it, we declare it again
* adding the appropriate commands that suit our purpose.
*
* @param moodle_page $page the page we are doing output for.
* @param string $target one of rendering target constants
* @see core:renderer::__construct()
*/
public function __construct(moodle_page $page, $target)
{
// Find and update course modules ids.
global $DB;
$this->chatmoduleid = $DB->get_field_sql('SELECT id FROM {modules} WHERE name="chat"', null);
$this->forummoduleid = $DB->get_field_sql('SELECT id FROM {modules} WHERE name="forum"', null);
$this->oldassignmoduleid = $DB->get_field_sql('SELECT id FROM {modules} WHERE name="assignment"', null);
$this->newassignmoduleid = $DB->get_field_sql('SELECT id FROM {modules} WHERE name="assign"', null);
$this->labelmoduleid = $DB->get_field_sql('SELECT id FROM {modules} WHERE name="label"', null);
// Use the Label module id, to exclude it from course resources.
$this->output = $page->get_renderer('core', null, $target);
parent::__construct($page, $target);
// These are needed for the enriched rubric renderer construction.
$this->resources = $this->get_modules_array('resources', $this->moduleicon);
$this->assignments = $this->get_modules_array('assignments', $this->moduleicon);
$this->activities = $this->get_modules_array('activities', $this->moduleicon);
}
示例11: xmldb_block_badges_upgrade
/**
* Upgrade the badges block
* @param int $oldversion
* @param object $block
*/
function xmldb_block_badges_upgrade($oldversion, $block)
{
global $DB;
if ($oldversion < 2014062600) {
// Add this block the default blocks on /my.
$blockname = 'badges';
$page = new moodle_page();
$page->set_context(context_system::instance());
// Check to see if this block is already on the default /my page.
$criteria = array('blockname' => $blockname, 'parentcontextid' => $page->context->id, 'pagetypepattern' => 'my-index');
if (!$DB->record_exists('block_instances', $criteria)) {
// Add the block to the default /my.
$page->blocks->add_region(BLOCK_POS_RIGHT);
$page->blocks->add_block($blockname, BLOCK_POS_RIGHT, 0, false, 'my-index');
}
upgrade_block_savepoint(true, 2014062600, $blockname);
}
return true;
}
示例12: get_renderer
/**
* @param moodle_page $page the page to render for.
* @return qbehaviour_renderer get the appropriate renderer to use for this model.
*/
public function get_renderer(moodle_page $page) {
return $page->get_renderer(get_class($this));
}
示例13: get_renderer
public function get_renderer(moodle_page $page)
{
return $page->get_renderer('qtype_multichoice', 'multi');
}
示例14: init_requirements_data
/**
* Initialise with the bits of JavaScript that every Moodle page should have.
*
* @param moodle_page $page
* @param core_renderer $renderer
*/
protected function init_requirements_data(moodle_page $page, core_renderer $renderer)
{
global $CFG;
// JavaScript should always work with $CFG->httpswwwroot rather than $CFG->wwwroot.
// Otherwise, in some situations, users will get warnings about insecure content
// on secure pages from their web browser.
$this->M_cfg = array('wwwroot' => $CFG->httpswwwroot, 'sesskey' => sesskey(), 'loadingicon' => $renderer->pix_url('i/loading_small', 'moodle')->out(false), 'themerev' => theme_get_revision(), 'slasharguments' => (int) (!empty($CFG->slasharguments)), 'theme' => $page->theme->name, 'jsrev' => (empty($CFG->cachejs) or empty($CFG->jsrev)) ? -1 : $CFG->jsrev, 'svgicons' => $page->theme->use_svg_icons());
if (debugging('', DEBUG_DEVELOPER)) {
$this->M_cfg['developerdebug'] = true;
}
if (defined('BEHAT_SITE_RUNNING')) {
$this->M_cfg['behatsiterunning'] = true;
}
// Accessibility stuff.
$this->skip_link_to('maincontent', get_string('tocontent', 'access'));
// Add strings used on many pages.
$this->string_for_js('confirmation', 'admin');
$this->string_for_js('cancel', 'moodle');
$this->string_for_js('yes', 'moodle');
// Alter links in top frame to break out of frames.
if ($page->pagelayout === 'frametop') {
$this->js_init_call('M.util.init_frametop');
}
// Include block drag/drop if editing is on
if ($page->user_is_editing()) {
$params = array('courseid' => $page->course->id, 'pagetype' => $page->pagetype, 'pagelayout' => $page->pagelayout, 'subpage' => $page->subpage, 'regions' => $page->blocks->get_regions(), 'contextid' => $page->context->id);
if (!empty($page->cm->id)) {
$params['cmid'] = $page->cm->id;
}
$page->requires->yui_module('moodle-core-blocks', 'M.core_blocks.init_dragdrop', array($params), null, true);
}
}
示例15: unset
unset($SESSION->theme);
if ($reset and confirm_sesskey()) {
theme_reset_all_caches();
} else if ($choose && $device && !$unsettheme && confirm_sesskey()) {
// Load the theme to make sure it is valid.
$theme = theme_config::load($choose);
// Get the config argument for the chosen device.
$themename = get_device_cfg_var_name($device);
set_config($themename, $theme->name);
// Create a new page for the display of the themes readme.
// This ensures that the readme page is shown using the new theme.
$confirmpage = new moodle_page();
$confirmpage->set_context($PAGE->context);
$confirmpage->set_url($PAGE->url);
$confirmpage->set_pagelayout($PAGE->pagelayout);
$confirmpage->set_pagetype($PAGE->pagetype);
$confirmpage->set_title($PAGE->title);
$confirmpage->set_heading($PAGE->heading);
// Get the core renderer for the new theme.
$output = $confirmpage->get_renderer('core');
echo $output->header();
echo $output->heading(get_string('themesaved'));
echo $output->box_start();
echo format_text(get_string('choosereadme', 'theme_'.$theme->name), FORMAT_MOODLE);
echo $output->box_end();