Skip to content

Commit

Permalink
MDL-23196, fixed block config structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Dongsheng Cai committed Jul 15, 2010
1 parent 97ce18f commit ce16291
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
10 changes: 6 additions & 4 deletions blocks/html/block_html.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ function get_content() {
$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 = '';
}
Expand All @@ -76,10 +76,12 @@ function get_content() {
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() {
Expand Down
18 changes: 12 additions & 6 deletions blocks/html/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,19 @@ protected function specific_definition($mform) {
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);
}
}

0 comments on commit ce16291

Please sign in to comment.