mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-23196, fixed block config structure
This commit is contained in:
parent
97ce18fbcf
commit
ce1629146d
2 changed files with 18 additions and 10 deletions
|
@ -58,8 +58,8 @@ class block_html extends block_base {
|
||||||
$this->content->footer = '';
|
$this->content->footer = '';
|
||||||
if (isset($this->config->text)) {
|
if (isset($this->config->text)) {
|
||||||
// rewrite url
|
// rewrite url
|
||||||
$this->config->text['text'] = file_rewrite_pluginfile_urls($this->config->text['text'], 'pluginfile.php', $this->context->id, 'block_html', 'content', NULL);
|
$this->config->text = file_rewrite_pluginfile_urls($this->config->text, 'pluginfile.php', $this->context->id, 'block_html', 'content', NULL);
|
||||||
$this->content->text = format_text($this->config->text['text'], $this->config->text['format'], $filteropt);
|
$this->content->text = format_text($this->config->text, $this->config->format, $filteropt);
|
||||||
} else {
|
} else {
|
||||||
$this->content->text = '';
|
$this->content->text = '';
|
||||||
}
|
}
|
||||||
|
@ -76,10 +76,12 @@ class block_html extends block_base {
|
||||||
function instance_config_save($data, $nolongerused = false) {
|
function instance_config_save($data, $nolongerused = false) {
|
||||||
global $DB;
|
global $DB;
|
||||||
|
|
||||||
|
$config = clone($data);
|
||||||
// Move embedded files into a proper filearea and adjust HTML links to match
|
// Move embedded files into a proper filearea and adjust HTML links to match
|
||||||
$data->text['text'] = file_save_draft_area_files($data->text['itemid'], $this->context->id, 'block_html', 'content', 0, array('subdirs'=>true), $data->text['text']);
|
$config->text = file_save_draft_area_files($data->text['itemid'], $this->context->id, 'block_html', 'content', 0, array('subdirs'=>true), $data->text['text']);
|
||||||
|
$config->format = $data->text['format'];
|
||||||
|
|
||||||
parent::instance_config_save($data, $nolongerused);
|
parent::instance_config_save($config, $nolongerused);
|
||||||
}
|
}
|
||||||
|
|
||||||
function instance_delete() {
|
function instance_delete() {
|
||||||
|
|
|
@ -45,13 +45,19 @@ class block_html_edit_form extends block_edit_form {
|
||||||
function set_data($defaults) {
|
function set_data($defaults) {
|
||||||
$block = $this->block;
|
$block = $this->block;
|
||||||
$draftid_editor = file_get_submitted_draft_itemid('config_text');
|
$draftid_editor = file_get_submitted_draft_itemid('config_text');
|
||||||
if (empty($block->config->text['text'])) {
|
if (!empty($block->config) && is_object($block->config)) {
|
||||||
|
$data = clone($block->config);
|
||||||
|
$block->config->text = array();
|
||||||
|
if (empty($data->text)) {
|
||||||
$currenttext = '';
|
$currenttext = '';
|
||||||
} else {
|
} else {
|
||||||
$currenttext = $block->config->text['text'];
|
$currenttext = $data->text;
|
||||||
}
|
}
|
||||||
$block->config->text['text'] = file_prepare_draft_area($draftid_editor, $block->context->id, 'block_html', 'content', 0, array('subdirs'=>true), $currenttext);
|
$block->config->text['text'] = file_prepare_draft_area($draftid_editor, $block->context->id, 'block_html', 'content', 0, array('subdirs'=>true), $currenttext);
|
||||||
$block->config->text['itemid'] = $draftid_editor;
|
$block->config->text['itemid'] = $draftid_editor;
|
||||||
|
$block->config->text['format'] = $data->format;
|
||||||
|
unset($data);
|
||||||
|
}
|
||||||
parent::set_data($defaults);
|
parent::set_data($defaults);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue