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


PHP moodle_page::set_block_actions_done方法代码示例

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


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

示例1: process_url_edit

 /**
  * Handle showing/processing the submission from the block editing form.
  * @return boolean true if the form was submitted and the new config saved. Does not
  *      return if the editing form was displayed. False otherwise.
  */
 public function process_url_edit()
 {
     global $CFG, $DB, $PAGE, $OUTPUT;
     $blockid = optional_param('bui_editid', null, PARAM_INT);
     if (!$blockid) {
         return false;
     }
     require_sesskey();
     require_once $CFG->dirroot . '/blocks/edit_form.php';
     $block = $this->find_instance($blockid);
     if (!$block->user_can_edit() && !$this->page->user_can_edit_blocks()) {
         throw new moodle_exception('nopermissions', '', $this->page->url->out(), get_string('editblock'));
     }
     $editpage = new moodle_page();
     $editpage->set_pagelayout('admin');
     $editpage->set_course($this->page->course);
     //$editpage->set_context($block->context);
     $editpage->set_context($this->page->context);
     if ($this->page->cm) {
         $editpage->set_cm($this->page->cm);
     }
     $editurlbase = str_replace($CFG->wwwroot . '/', '/', $this->page->url->out_omit_querystring());
     $editurlparams = $this->page->url->params();
     $editurlparams['bui_editid'] = $blockid;
     $editpage->set_url($editurlbase, $editurlparams);
     $editpage->set_block_actions_done();
     // At this point we are either going to redirect, or display the form, so
     // overwrite global $PAGE ready for this. (Formslib refers to it.)
     $PAGE = $editpage;
     //some functions like MoodleQuickForm::addHelpButton use $OUTPUT so we need to replace that to
     $output = $editpage->get_renderer('core');
     $OUTPUT = $output;
     $formfile = $CFG->dirroot . '/blocks/' . $block->name() . '/edit_form.php';
     if (is_readable($formfile)) {
         require_once $formfile;
         $classname = 'block_' . $block->name() . '_edit_form';
         if (!class_exists($classname)) {
             $classname = 'block_edit_form';
         }
     } else {
         $classname = 'block_edit_form';
     }
     $mform = new $classname($editpage->url, $block, $this->page);
     $mform->set_data($block->instance);
     if ($mform->is_cancelled()) {
         redirect($this->page->url);
     } else {
         if ($data = $mform->get_data()) {
             $bi = new stdClass();
             $bi->id = $block->instance->id;
             // This may get overwritten by the special case handling below.
             $bi->pagetypepattern = $data->bui_pagetypepattern;
             $bi->showinsubcontexts = (bool) $data->bui_contexts;
             if (empty($data->bui_subpagepattern) || $data->bui_subpagepattern == '%@NULL@%') {
                 $bi->subpagepattern = null;
             } else {
                 $bi->subpagepattern = $data->bui_subpagepattern;
             }
             $systemcontext = context_system::instance();
             $frontpagecontext = context_course::instance(SITEID);
             $parentcontext = context::instance_by_id($data->bui_parentcontextid);
             // Updating stickiness and contexts.  See MDL-21375 for details.
             if (has_capability('moodle/site:manageblocks', $parentcontext)) {
                 // Check permissions in destination
                 // Explicitly set the default context
                 $bi->parentcontextid = $parentcontext->id;
                 if ($data->bui_editingatfrontpage) {
                     // The block is being edited on the front page
                     // The interface here is a special case because the pagetype pattern is
                     // totally derived from the context menu.  Here are the excpetions.   MDL-30340
                     switch ($data->bui_contexts) {
                         case BUI_CONTEXTS_ENTIRE_SITE:
                             // The user wants to show the block across the entire site
                             $bi->parentcontextid = $systemcontext->id;
                             $bi->showinsubcontexts = true;
                             $bi->pagetypepattern = '*';
                             break;
                         case BUI_CONTEXTS_FRONTPAGE_SUBS:
                             // The user wants the block shown on the front page and all subcontexts
                             $bi->parentcontextid = $frontpagecontext->id;
                             $bi->showinsubcontexts = true;
                             $bi->pagetypepattern = '*';
                             break;
                         case BUI_CONTEXTS_FRONTPAGE_ONLY:
                             // The user want to show the front page on the frontpage only
                             $bi->parentcontextid = $frontpagecontext->id;
                             $bi->showinsubcontexts = false;
                             $bi->pagetypepattern = 'site-index';
                             // This is the only relevant page type anyway but we'll set it explicitly just
                             // in case the front page grows site-index-* subpages of its own later
                             break;
                     }
                 }
             }
             $bits = explode('-', $bi->pagetypepattern);
//.........这里部分代码省略.........
开发者ID:Burick,项目名称:moodle,代码行数:101,代码来源:blocklib.php

示例2: process_url_edit

 /**
  * Handle showing/processing the submission from the block editing form.
  * @return boolean true if the form was submitted and the new config saved. Does not
  *      return if the editing form was displayed. False otherwise.
  */
 public function process_url_edit()
 {
     global $CFG, $DB, $PAGE;
     $blockid = optional_param('bui_editid', null, PARAM_INTEGER);
     if (!$blockid) {
         return false;
     }
     require_sesskey();
     require_once $CFG->dirroot . '/blocks/edit_form.php';
     $block = $this->find_instance($blockid);
     if (!$block->user_can_edit() && !$this->page->user_can_edit_blocks()) {
         throw new moodle_exception('nopermissions', '', $this->page->url->out(), get_string('editblock'));
     }
     $editpage = new moodle_page();
     $editpage->set_pagelayout('admin');
     $editpage->set_course($this->page->course);
     $editpage->set_context($block->context);
     if ($this->page->cm) {
         $editpage->set_cm($this->page->cm);
     }
     $editurlbase = str_replace($CFG->wwwroot . '/', '/', $this->page->url->out_omit_querystring());
     $editurlparams = $this->page->url->params();
     $editurlparams['bui_editid'] = $blockid;
     $editpage->set_url($editurlbase, $editurlparams);
     $editpage->set_block_actions_done();
     // At this point we are either going to redirect, or display the form, so
     // overwrite global $PAGE ready for this. (Formslib refers to it.)
     $PAGE = $editpage;
     $formfile = $CFG->dirroot . '/blocks/' . $block->name() . '/edit_form.php';
     if (is_readable($formfile)) {
         require_once $formfile;
         $classname = 'block_' . $block->name() . '_edit_form';
         if (!class_exists($classname)) {
             $classname = 'block_edit_form';
         }
     } else {
         $classname = 'block_edit_form';
     }
     $mform = new $classname($editpage->url, $block, $this->page);
     $mform->set_data($block->instance);
     if ($mform->is_cancelled()) {
         redirect($this->page->url);
     } else {
         if ($data = $mform->get_data()) {
             $bi = new stdClass();
             $bi->id = $block->instance->id;
             $bi->pagetypepattern = $data->bui_pagetypepattern;
             if (empty($data->bui_subpagepattern) || $data->bui_subpagepattern == '%@NULL@%') {
                 $bi->subpagepattern = null;
             } else {
                 $bi->subpagepattern = $data->bui_subpagepattern;
             }
             $parentcontext = get_context_instance_by_id($data->bui_parentcontextid);
             $systemcontext = get_context_instance(CONTEXT_SYSTEM);
             // Updating stickiness and contexts.  See MDL-21375 for details.
             if (has_capability('moodle/site:manageblocks', $parentcontext)) {
                 // Check permissions in destination
                 // Explicitly set the context
                 $bi->parentcontextid = $parentcontext->id;
                 // If the context type is > 0 then we'll explicitly set the block as sticky, otherwise not
                 $bi->showinsubcontexts = (int) (!empty($data->bui_contexts));
                 // If the block wants to be system-wide, then explicitly set that
                 if ($data->bui_contexts == 2) {
                     // Only possible on a frontpage or system page
                     $bi->parentcontextid = $systemcontext->id;
                 } else {
                     // The block doesn't want to be system-wide, so let's ensure that
                     if ($parentcontext->id == $systemcontext->id) {
                         // We need to move it to the front page
                         $frontpagecontext = get_context_instance(CONTEXT_COURSE, SITEID);
                         $bi->parentcontextid = $frontpagecontext->id;
                         $bi->pagetypepattern = '*';
                         // Just in case
                     }
                 }
             }
             $bi->defaultregion = $data->bui_defaultregion;
             $bi->defaultweight = $data->bui_defaultweight;
             $DB->update_record('block_instances', $bi);
             if (!empty($block->config)) {
                 $config = clone $block->config;
             } else {
                 $config = new stdClass();
             }
             foreach ($data as $configfield => $value) {
                 if (strpos($configfield, 'config_') !== 0) {
                     continue;
                 }
                 $field = substr($configfield, 7);
                 $config->{$field} = $value;
             }
             $block->instance_config_save($config);
             $bp = new stdClass();
             $bp->visible = $data->bui_visible;
             $bp->region = $data->bui_region;
//.........这里部分代码省略.........
开发者ID:vuchannguyen,项目名称:web,代码行数:101,代码来源:blocklib.php


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