diff --git a/blocks/html/block_html.php b/blocks/html/block_html.php index 44eec676beb..b491166d82f 100755 --- a/blocks/html/block_html.php +++ b/blocks/html/block_html.php @@ -58,8 +58,8 @@ class block_html extends block_base { $this->content->footer = ''; if (isset($this->config->text)) { // rewrite url - $this->config->text['text'] = file_rewrite_pluginfile_urls($this->config->text['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->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, $this->config->format, $filteropt); } else { $this->content->text = ''; } @@ -76,10 +76,12 @@ class block_html extends block_base { function instance_config_save($data, $nolongerused = false) { global $DB; + $config = clone($data); // 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() { diff --git a/blocks/html/edit_form.php b/blocks/html/edit_form.php index e8ef73af8a4..089d3458ad6 100644 --- a/blocks/html/edit_form.php +++ b/blocks/html/edit_form.php @@ -45,13 +45,19 @@ class block_html_edit_form extends block_edit_form { function set_data($defaults) { $block = $this->block; $draftid_editor = file_get_submitted_draft_itemid('config_text'); - if (empty($block->config->text['text'])) { - $currenttext = ''; - } else { - $currenttext = $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 = ''; + } else { + $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['itemid'] = $draftid_editor; + $block->config->text['format'] = $data->format; + unset($data); } - $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; parent::set_data($defaults); } }