当前位置: 首页>>代码示例>>PHP>>正文


PHP moodle_page::initialise_theme_and_output方法代码示例

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


在下文中一共展示了moodle_page::initialise_theme_and_output方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: load_blocks

 /**
  * This method actually loads the blocks for our page from the database.
  *
  * @param boolean|null $includeinvisible
  *      null (default) - load hidden blocks if $this->page->user_is_editing();
  *      true - load hidden blocks.
  *      false - don't load hidden blocks.
  */
 public function load_blocks($includeinvisible = null)
 {
     global $DB, $CFG;
     if (!is_null($this->birecordsbyregion)) {
         // Already done.
         return;
     }
     if ($CFG->version < 2009050619) {
         // Upgrade/install not complete. Don't try too show any blocks.
         $this->birecordsbyregion = array();
         return;
     }
     // Ensure we have been initialised.
     if (is_null($this->defaultregion)) {
         $this->page->initialise_theme_and_output();
         // If there are still no block regions, then there are no blocks on this page.
         if (empty($this->regions)) {
             $this->birecordsbyregion = array();
             return;
         }
     }
     // Check if we need to load normal blocks
     if ($this->fakeblocksonly) {
         $this->birecordsbyregion = $this->prepare_per_region_arrays();
         return;
     }
     if (is_null($includeinvisible)) {
         $includeinvisible = $this->page->user_is_editing();
     }
     if ($includeinvisible) {
         $visiblecheck = '';
     } else {
         $visiblecheck = 'AND (bp.visible = 1 OR bp.visible IS NULL)';
     }
     $context = $this->page->context;
     $contexttest = 'bi.parentcontextid = :contextid2';
     $parentcontextparams = array();
     $parentcontextids = get_parent_contexts($context);
     if ($parentcontextids) {
         list($parentcontexttest, $parentcontextparams) = $DB->get_in_or_equal($parentcontextids, SQL_PARAMS_NAMED, 'parentcontext');
         $contexttest = "({$contexttest} OR (bi.showinsubcontexts = 1 AND bi.parentcontextid {$parentcontexttest}))";
     }
     $pagetypepatterns = matching_page_type_patterns($this->page->pagetype);
     list($pagetypepatterntest, $pagetypepatternparams) = $DB->get_in_or_equal($pagetypepatterns, SQL_PARAMS_NAMED, 'pagetypepatterntest');
     list($ccselect, $ccjoin) = context_instance_preload_sql('bi.id', CONTEXT_BLOCK, 'ctx');
     $params = array('subpage1' => $this->page->subpage, 'subpage2' => $this->page->subpage, 'contextid1' => $context->id, 'contextid2' => $context->id, 'pagetype' => $this->page->pagetype);
     if ($this->page->subpage === '') {
         $params['subpage1'] = $DB->sql_empty();
         $params['subpage2'] = $DB->sql_empty();
     }
     $sql = "SELECT\n                    bi.id,\n                    bp.id AS blockpositionid,\n                    bi.blockname,\n                    bi.parentcontextid,\n                    bi.showinsubcontexts,\n                    bi.pagetypepattern,\n                    bi.subpagepattern,\n                    bi.defaultregion,\n                    bi.defaultweight,\n                    COALESCE(bp.visible, 1) AS visible,\n                    COALESCE(bp.region, bi.defaultregion) AS region,\n                    COALESCE(bp.weight, bi.defaultweight) AS weight,\n                    bi.configdata\n                    {$ccselect}\n\n                FROM {block_instances} bi\n                JOIN {block} b ON bi.blockname = b.name\n                LEFT JOIN {block_positions} bp ON bp.blockinstanceid = bi.id\n                                                  AND bp.contextid = :contextid1\n                                                  AND bp.pagetype = :pagetype\n                                                  AND bp.subpage = :subpage1\n                {$ccjoin}\n\n                WHERE\n                {$contexttest}\n                AND bi.pagetypepattern {$pagetypepatterntest}\n                AND (bi.subpagepattern IS NULL OR bi.subpagepattern = :subpage2)\n                {$visiblecheck}\n                AND b.visible = 1\n\n                ORDER BY\n                    COALESCE(bp.region, bi.defaultregion),\n                    COALESCE(bp.weight, bi.defaultweight),\n                    bi.id";
     $blockinstances = $DB->get_recordset_sql($sql, $params + $parentcontextparams + $pagetypepatternparams);
     $this->birecordsbyregion = $this->prepare_per_region_arrays();
     $unknown = array();
     foreach ($blockinstances as $bi) {
         context_instance_preload($bi);
         if ($this->is_known_region($bi->region)) {
             $this->birecordsbyregion[$bi->region][] = $bi;
         } else {
             $unknown[] = $bi;
         }
     }
     // Pages don't necessarily have a defaultregion. The  one time this can
     // happen is when there are no theme block regions, but the script itself
     // has a block region in the main content area.
     if (!empty($this->defaultregion)) {
         $this->birecordsbyregion[$this->defaultregion] = array_merge($this->birecordsbyregion[$this->defaultregion], $unknown);
     }
 }
开发者ID:Burick,项目名称:moodle,代码行数:77,代码来源:blocklib.php

示例3: load_blocks

    /**
     * This method actually loads the blocks for our page from the database.
     *
     * @param boolean|null $includeinvisible
     *      null (default) - load hidden blocks if $this->page->user_is_editing();
     *      true - load hidden blocks.
     *      false - don't load hidden blocks.
     */
    public function load_blocks($includeinvisible = null) {
        global $DB, $CFG;

        if (!is_null($this->birecordsbyregion)) {
            // Already done.
            return;
        }

        if ($CFG->version < 2009050619) {
            // Upgrade/install not complete. Don't try too show any blocks.
            $this->birecordsbyregion = array();
            return;
        }

        // Ensure we have been initialised.
        if (is_null($this->defaultregion)) {
            $this->page->initialise_theme_and_output();
            // If there are still no block regions, then there are no blocks on this page.
            if (empty($this->regions)) {
                $this->birecordsbyregion = array();
                return;
            }
        }

        // Check if we need to load normal blocks
        if ($this->fakeblocksonly) {
            $this->birecordsbyregion = $this->prepare_per_region_arrays();
            return;
        }

        // Exclude auto created blocks if they are not undeletable in this theme.
        $undeletable = $this->get_undeletable_block_types();
        $undeletablecheck = '';
        $undeletableparams = array();
        $undeletablenotparams = array();
        if (!empty($undeletable)) {
            list($testsql, $undeletableparams) = $DB->get_in_or_equal($undeletable, SQL_PARAMS_NAMED, 'undeletable');
            list($testnotsql, $undeletablenotparams) = $DB->get_in_or_equal($undeletable, SQL_PARAMS_NAMED, 'deletable', false);
            $undeletablecheck = 'AND ((bi.blockname ' . $testsql . ' AND bi.requiredbytheme = 1) OR ' .
                                ' (bi.blockname ' . $testnotsql . ' AND bi.requiredbytheme = 0))';
        } else {
            $undeletablecheck = 'AND (bi.requiredbytheme = 0)';
        }

        if (is_null($includeinvisible)) {
            $includeinvisible = $this->page->user_is_editing();
        }
        if ($includeinvisible) {
            $visiblecheck = '';
        } else {
            $visiblecheck = 'AND (bp.visible = 1 OR bp.visible IS NULL)';
        }

        $context = $this->page->context;
        $contexttest = 'bi.parentcontextid IN (:contextid2, :contextid3)';
        $parentcontextparams = array();
        $parentcontextids = $context->get_parent_context_ids();
        if ($parentcontextids) {
            list($parentcontexttest, $parentcontextparams) =
                    $DB->get_in_or_equal($parentcontextids, SQL_PARAMS_NAMED, 'parentcontext');
            $contexttest = "($contexttest OR (bi.showinsubcontexts = 1 AND bi.parentcontextid $parentcontexttest))";
        }

        $pagetypepatterns = matching_page_type_patterns($this->page->pagetype);
        list($pagetypepatterntest, $pagetypepatternparams) =
                $DB->get_in_or_equal($pagetypepatterns, SQL_PARAMS_NAMED, 'pagetypepatterntest');

        $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
        $ccjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = bi.id AND ctx.contextlevel = :contextlevel)";

        $systemcontext = context_system::instance();
        $params = array(
            'contextlevel' => CONTEXT_BLOCK,
            'subpage1' => $this->page->subpage,
            'subpage2' => $this->page->subpage,
            'contextid1' => $context->id,
            'contextid2' => $context->id,
            'contextid3' => $systemcontext->id,
            'pagetype' => $this->page->pagetype,
        );
        if ($this->page->subpage === '') {
            $params['subpage1'] = '';
            $params['subpage2'] = '';
        }
        $sql = "SELECT
                    bi.id,
                    bp.id AS blockpositionid,
                    bi.blockname,
                    bi.parentcontextid,
                    bi.showinsubcontexts,
                    bi.pagetypepattern,
                    bi.requiredbytheme,
//.........这里部分代码省略.........
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:101,代码来源:blocklib.php


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