• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP moodle_page类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中moodle_page的典型用法代码示例。如果您正苦于以下问题:PHP moodle_page类的具体用法?PHP moodle_page怎么用?PHP moodle_page使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了moodle_page类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:28,代码来源:customusersettheme_test.php


示例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;
}
开发者ID:evltuma,项目名称:moodle,代码行数:36,代码来源:upgrade.php


示例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);
 }
开发者ID:unikent,项目名称:moodle-tool_cat,代码行数:10,代码来源:block_region.php


示例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);
 }
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:13,代码来源:question.php


示例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);
}
开发者ID:EEXCESS,项目名称:moodle-block_eexcess,代码行数:12,代码来源:install.php


示例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);
 }
开发者ID:matlow,项目名称:taxonomy,代码行数:11,代码来源:indexTest.php


示例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);
         }
     }
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:21,代码来源:lib.php


示例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;
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:15,代码来源:install.php


示例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));
 }
开发者ID:janeklb,项目名称:moodle,代码行数:20,代码来源:helper_test.php


示例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);
 }
开发者ID:johndimopoulos,项目名称:moodle-gradingform_erubric,代码行数:33,代码来源:renderer.php


示例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;
}
开发者ID:abhilash1994,项目名称:moodle,代码行数:24,代码来源:upgrade.php


示例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));
 }
开发者ID:nigeli,项目名称:moodle,代码行数:7,代码来源:behaviourbase.php


示例13: get_renderer

 public function get_renderer(moodle_page $page)
 {
     return $page->get_renderer('qtype_multichoice', 'multi');
 }
开发者ID:evltuma,项目名称:moodle,代码行数:4,代码来源:question.php


示例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);
     }
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:38,代码来源:outputrequirementslib.php


示例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();
开发者ID:verbazend,项目名称:AWFA,代码行数:30,代码来源:index.php


示例16: page_set_course

 /**
  * Allows course format to execute code on moodle_page::set_course()
  *
  * This function is executed before the output starts.
  *
  * If everything is configured correctly, user is redirected from the
  * default course view page to the activity view page.
  *
  * "Section 1" is the administrative page to manage orphaned activities
  *
  * If user is on course view page and there is no module added to the course
  * and the user has 'moodle/course:manageactivities' capability, redirect to create module
  * form.
  *
  * @param moodle_page $page instance of page calling set_course
  */
 public function page_set_course(moodle_page $page)
 {
     global $PAGE;
     $page->add_body_class('format-' . $this->get_format());
     if ($PAGE == $page && $page->has_set_url() && $page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
         $edit = optional_param('edit', -1, PARAM_BOOL);
         if (($edit == 0 || $edit == 1) && confirm_sesskey()) {
             // This is a request to turn editing mode on or off, do not redirect here, /course/view.php will do redirection.
             return;
         }
         $cm = $this->get_activity();
         $cursection = optional_param('section', null, PARAM_INT);
         if (!empty($cursection) && has_capability('moodle/course:viewhiddensections', context_course::instance($this->courseid))) {
             // Display orphaned activities (course view page, section 1).
             return;
         }
         if (!$this->get_activitytype()) {
             if (has_capability('moodle/course:update', context_course::instance($this->courseid))) {
                 // Teacher is redirected to edit course page.
                 $url = new moodle_url('/course/edit.php', array('id' => $this->courseid));
                 redirect($url, get_string('erroractivitytype', 'format_singleactivity'));
             } else {
                 // Student sees an empty course page.
                 return;
             }
         }
         if ($cm === null) {
             if ($this->can_add_activity()) {
                 // This is a user who has capability to create an activity.
                 if ($this->activity_has_subtypes()) {
                     // Activity that requires subtype can not be added automatically.
                     if (optional_param('addactivity', 0, PARAM_INT)) {
                         return;
                     } else {
                         $url = new moodle_url('/course/view.php', array('id' => $this->courseid, 'addactivity' => 1));
                         redirect($url);
                     }
                 }
                 // Redirect to the add activity form.
                 $url = new moodle_url('/course/mod.php', array('id' => $this->courseid, 'section' => 0, 'sesskey' => sesskey(), 'add' => $this->get_activitytype()));
                 redirect($url);
             } else {
                 // Student views an empty course page.
                 return;
             }
         } else {
             if (!$cm->uservisible || !$cm->get_url()) {
                 // Activity is set but not visible to current user or does not have url.
                 // Display course page (either empty or with availability restriction info).
                 return;
             } else {
                 // Everything is set up and accessible, redirect to the activity page!
                 redirect($cm->get_url());
             }
         }
     }
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:73,代码来源:lib.php


示例17: test_qualified_me

 public function test_qualified_me()
 {
     global $PAGE, $FULLME, $CFG;
     $this->resetAfterTest();
     $PAGE = new moodle_page();
     $FULLME = $CFG->wwwroot . '/course/view.php?id=1&xx=yy';
     $this->assertSame($FULLME, qualified_me());
     $PAGE->set_url('/course/view.php', array('id' => 1));
     $this->assertSame($CFG->wwwroot . '/course/view.php?id=1', qualified_me());
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:10,代码来源:weblib_test.php


示例18: test_get_url

 public function test_get_url()
 {
     global $DB, $CFG;
     $this->resetAfterTest();
     // Force SVG on so that we have predictable URL's.
     $CFG->svgicons = true;
     // verify new install contains expected defaults
     $this->assertEquals('standard', $CFG->theme);
     $this->assertEquals(1, $CFG->slasharguments);
     $this->assertEquals(1, $CFG->themerev);
     $this->assertEquals(0, $CFG->themedesignermode);
     $this->assertEquals('http://www.example.com/moodle', $CFG->wwwroot);
     $this->assertEquals($CFG->wwwroot, $CFG->httpswwwroot);
     $this->assertEquals(0, $CFG->enablegravatar);
     $this->assertEquals('mm', $CFG->gravatardefaulturl);
     // create some users
     $page = new moodle_page();
     $page->set_url('/user/profile.php');
     $page->set_context(context_system::instance());
     $renderer = $page->get_renderer('core');
     $user1 = $this->getDataGenerator()->create_user(array('picture' => 11, 'email' => '[email protected]'));
     $context1 = context_user::instance($user1->id);
     $user2 = $this->getDataGenerator()->create_user(array('picture' => 0, 'email' => '[email protected]'));
     $context2 = context_user::instance($user2->id);
     $user3 = $this->getDataGenerator()->create_user(array('picture' => 1, 'deleted' => 1, 'email' => '[email protected]'));
     $context3 = context_user::instance($user3->id, IGNORE_MISSING);
     $this->assertEquals($user3->picture, 0);
     $this->assertNotEquals($user3->email, '[email protected]');
     $this->assertFalse($context3);
     // try legacy picture == 1
     $user1->picture = 1;
     $up1 = new user_picture($user1);
     $this->assertEquals($CFG->wwwroot . '/pluginfile.php/' . $context1->id . '/user/icon/standard/f2?rev=1', $up1->get_url($page, $renderer)->out(false));
     $user1->picture = 11;
     // try valid user with picture when user context is not cached - 1 query expected
     context_helper::reset_caches();
     $reads = $DB->perf_get_reads();
     $up1 = new user_picture($user1);
     $this->assertEquals($reads, $DB->perf_get_reads());
     $this->assertEquals($CFG->wwwroot . '/pluginfile.php/' . $context1->id . '/user/icon/standard/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
     $this->assertEquals($reads + 1, $DB->perf_get_reads());
     // try valid user with contextid hint - no queries expected
     $user1->contextid = $context1->id;
     context_helper::reset_caches();
     $reads = $DB->perf_get_reads();
     $up1 = new user_picture($user1);
     $this->assertEquals($reads, $DB->perf_get_reads());
     $this->assertEquals($CFG->wwwroot . '/pluginfile.php/' . $context1->id . '/user/icon/standard/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
     $this->assertEquals($reads, $DB->perf_get_reads());
     // try valid user without image - no queries expected
     context_helper::reset_caches();
     $reads = $DB->perf_get_reads();
     $up2 = new user_picture($user2);
     $this->assertEquals($reads, $DB->perf_get_reads());
     $this->assertEquals($CFG->wwwroot . '/theme/image.php/standard/core/1/u/f2', $up2->get_url($page, $renderer)->out(false));
     $this->assertEquals($reads, $DB->perf_get_reads());
     // try guessing of deleted users - no queries expected
     unset($user3->deleted);
     context_helper::reset_caches();
     $reads = $DB->perf_get_reads();
     $up3 = new user_picture($user3);
     $this->assertEquals($reads, $DB->perf_get_reads());
     $this->assertEquals($CFG->wwwroot . '/theme/image.php/standard/core/1/u/f2', $up3->get_url($page, $renderer)->out(false));
     $this->assertEquals($reads, $DB->perf_get_reads());
     // try incorrectly deleted users (with valid email and pciture flag) - some DB reads expected
     $user3->email = '[email protected]';
     $user3->picture = 1;
     $reads = $DB->perf_get_reads();
     $up3 = new user_picture($user3);
     $this->assertEquals($reads, $DB->perf_get_reads());
     $this->assertEquals($CFG->wwwroot . '/theme/image.php/standard/core/1/u/f2', $up3->get_url($page, $renderer)->out(false));
     $this->assertTrue($reads < $DB->perf_get_reads());
     // test gravatar
     set_config('enablegravatar', 1);
     // deleted user can not have gravatar
     $user3->email = 'deleted';
     $user3->picture = 0;
     $up3 = new user_picture($user3);
     $this->assertEquals($CFG->wwwroot . '/theme/image.php/standard/core/1/u/f2', $up3->get_url($page, $renderer)->out(false));
     // verify defaults to misteryman (mm)
     $up2 = new user_picture($user2);
     $this->assertEquals('http://www.gravatar.com/avatar/ab53a2911ddf9b4817ac01ddcd3d975f?s=35&d=mm', $up2->get_url($page, $renderer)->out(false));
     // without gravatardefaulturl, verify we pick own file
     set_config('gravatardefaulturl', '');
     $up2 = new user_picture($user2);
     $this->assertEquals('http://www.gravatar.com/avatar/ab53a2911ddf9b4817ac01ddcd3d975f?s=35&d=http%3A%2F%2Fwww.example.com%2Fmoodle%2Fpix%2Fu%2Ff2.png', $up2->get_url($page, $renderer)->out(false));
     // uploaded image takes precedence before gravatar
     $up1 = new user_picture($user1);
     $this->assertEquals($CFG->wwwroot . '/pluginfile.php/' . $context1->id . '/user/icon/standard/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
     // https version
     $CFG->httpswwwroot = str_replace('http:', 'https:', $CFG->wwwroot);
     $up1 = new user_picture($user1);
     $this->assertEquals($CFG->httpswwwroot . '/pluginfile.php/' . $context1->id . '/user/icon/standard/f2?rev=11', $up1->get_url($page, $renderer)->out(false));
     $up3 = new user_picture($user3);
     $this->assertEquals($CFG->httpswwwroot . '/theme/image.php/standard/core/1/u/f2', $up3->get_url($page, $renderer)->out(false));
     $up2 = new user_picture($user2);
     $this->assertEquals('https://secure.gravatar.com/avatar/ab53a2911ddf9b4817ac01ddcd3d975f?s=35&d=https%3A%2F%2Fwww.example.com%2Fmoodle%2Fpix%2Fu%2Ff2.png', $up2->get_url($page, $renderer)->out(false));
     // now test gravatar with one theme having own images (afterburner)
     $CFG->httpswwwroot = $CFG->wwwroot;
     $this->assertTrue(file_exists("{$CFG->dirroot}/theme/afterburner/config.php"));
//.........这里部分代码省略.........
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:101,代码来源:outputcomponents_test.php


示例19: get_renderer

 /**
  * Returns the rubric plugin renderer
  *
  * @param moodle_page $page the target page
  * @return gradingform_rubric_renderer
  */
 public function get_renderer(moodle_page $page)
 {
     return $page->get_renderer('gradingform_' . $this->get_method_name());
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:10,代码来源:lib.php


示例20: get_url

 /**
  * Works out the URL for the users picture.
  *
  * This method is recommended as it avoids costly redirects of user pictures
  * if requests are made for non-existent files etc.
  *
  * @param moodle_page $page
  * @param renderer_base $renderer
  * @return moodle_url
  */
 public function get_url(moodle_page $page, renderer_base $renderer = null)
 {
     global $CFG;
     if (is_null($renderer)) {
         $renderer = $page->get_renderer('core');
     }
     // Sort out the filename and size. Size is only required for the gravatar
     // implementation presently.
     if (empty($this->size)) {
         $filename = 'f2';
         $size = 35;
     } else {
         if ($this->size === true or $this->size == 1) {
             $filename = 'f1';
             $size = 100;
         } else {
             if ($this->size > 100) {
                 $filename = 'f3';
                 $size = (int) $this->size;
             } else {
                 if ($this->size >= 50) {
                     $filename = 'f1';
                     $size = (int) $this->size;
                 } else {
                     $filename = 'f2';
                     $size = (int) $this->size;
                 }
             }
         }
     }
     $defaulturl = $renderer->pix_url('u/' . $filename);
     // default image
     if ((!empty($CFG->forcelogin) and !isloggedin()) || !empty($CFG->forceloginforprofileimage) && (!isloggedin() || isguestuser())) {
         // Protect images if login required and not logged in;
         // also if login is required for profile images and is not logged in or guest
         // do not use require_login() because it is expensive and not suitable here anyway.
         return $defaulturl;
     }
     // First try to detect deleted users - but do not read from database for performance reasons!
     if (!empty($this->user->deleted) or strpos($this->user->email, '@') === false) {
         // All deleted users should have email replaced by md5 hash,
         // all active users are expected to have valid email.
         return $defaulturl;
     }
     // Did the user upload a picture?
     if ($this->user->picture > 0) {
         if (!empty($this->user->contextid)) {
             $contextid = $this->user->contextid;
         } else {
             $context = context_user::instance($this->user->id, IGNORE_MISSING);
             if (!$context) {
                 // This must be an incorrectly deleted user, all other users have context.
                 return $defaulturl;
             }
             $contextid = $context->id;
         }
         $path = '/';
         if (clean_param($page->theme->name, PARAM_THEME) == $page->theme->name) {
             // We append the theme name to the file path if we have it so that
             // in the circumstance that the profile picture is not available
             // when the user actually requests it they still get the profile
             // picture for the correct theme.
             $path .= $page->theme->name . '/';
         }
         // Set the image URL to the URL for the uploaded file and return.
         $url = moodle_url::make_pluginfile_url($contextid, 'user', 'icon', NULL, $path, $filename);
         $url->param('rev', $this->user->picture);
         return $url;
     }
     if ($this->user->picture == 0 and !empty($CFG->enablegravatar)) {
         // Normalise the size variable to acceptable bounds
         if ($size < 1 || $size > 512) {
             $size = 35;
         }
         // Hash the users email address
         $md5 = md5(strtolower(trim($this->user->email)));
         // Build a gravatar URL with what we know.
         // Find the best default image URL we can (MDL-35669)
         if (empty($CFG->gravatardefaulturl)) {
             $absoluteimagepath = $page->theme->resolve_image_location('u/' . $filename, 'core');
             if (strpos($absoluteimagepath, $CFG->dirroot) === 0) {
                 $gravatardefault = $CFG->wwwroot . substr($absoluteimagepath, strlen($CFG->dirroot));
             } else {
                 $gravatardefault = $CFG->wwwroot . '/pix/u/' . $filename . '.png';
             }
         } else {
             $gravatardefault = $CFG->gravatardefaulturl;
         }
         // If the currently requested page is https then we'll return an
         // https gravatar page.
//.........这里部分代码省略.........
开发者ID:jtibbetts,项目名称:moodle,代码行数:101,代码来源:outputcomponents.php



注:本文中的moodle_page类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP moodle_transaction类代码示例发布时间:2022-05-23
下一篇:
PHP moodle_exception类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap