本文整理汇总了PHP中moodle_page::set_generaltype方法的典型用法代码示例。如果您正苦于以下问题:PHP moodle_page::set_generaltype方法的具体用法?PHP moodle_page::set_generaltype怎么用?PHP moodle_page::set_generaltype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moodle_page
的用法示例。
在下文中一共展示了moodle_page::set_generaltype方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
$blockid = optional_param('bui_editid', null, PARAM_INTEGER);
if (!$blockid) {
return false;
}
confirm_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_generaltype('form');
$editpage->set_course($this->page->course);
$editpage->set_context($block->context);
$editurlbase = str_replace($CFG->wwwroot . '/', '', $this->page->url->out(true));
$editurlparams = $this->page->url->params();
$editurlparams['bui_editid'] = $blockid;
$editpage->set_url($editurlbase, $editurlparams);
$editpage->_block_actions_done = true;
// 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';
} 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->showinsubcontexts = $data->bui_showinsubcontexts;
$bi->pagetypepattern = $data->bui_pagetypepattern;
if (empty($data->bui_subpagepattern) || $data->bui_subpagepattern == '%@NULL@%') {
$bi->subpagepattern = null;
} else {
$bi->subpagepattern = $data->bui_subpagepattern;
}
$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;
$bp->weight = $data->bui_weight;
$needbprecord = !$data->bui_visible || $data->bui_region != $data->bui_defaultregion || $data->bui_weight != $data->bui_defaultweight;
if ($block->instance->blockpositionid && !$needbprecord) {
$DB->delete_records('block_positions', array('id' => $block->instance->blockpositionid));
} else {
if ($block->instance->blockpositionid && $needbprecord) {
$bp->id = $block->instance->blockpositionid;
$DB->update_record('block_positions', $bp);
} else {
if ($needbprecord) {
$bp->blockinstanceid = $block->instance->id;
$bp->contextid = $this->page->context->id;
$bp->pagetype = $this->page->pagetype;
if ($this->page->subpage) {
$bp->subpage = $this->page->subpage;
} else {
$bp->subpage = '';
}
$DB->insert_record('block_positions', $bp);
}
}
}
redirect($this->page->url);
} else {
$strheading = get_string('editinga', $block->name());
if (strpos($strheading, '[[') === 0) {
$strheading = get_string('blockconfiga', 'moodle', $block->get_title());
}
$editpage->set_title($strheading);
//.........这里部分代码省略.........