Skip to content

Commit

Permalink
MDL-63694 block_html: Implement get_content_for_external
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyva authored and stronk7 committed Oct 25, 2018
1 parent 96d9a6e commit a9732b8
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions blocks/html/block_html.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,41 @@ function get_content() {
return $this->content;
}

public function get_content_for_external($output) {
global $CFG;
require_once($CFG->libdir . '/externallib.php');

$bc = new stdClass;
$bc->title = null;
$bc->content = '';
$bc->contenformat = FORMAT_MOODLE;
$bc->footer = '';
$bc->files = [];

if (!$this->hide_header()) {
$bc->title = $this->title;
}

if (isset($this->config->text)) {
$filteropt = new stdClass;
if ($this->content_is_trusted()) {
// Fancy html allowed only on course, category and system blocks.
$filteropt->noclean = true;
}

$format = FORMAT_HTML;
// Check to see if the format has been properly set on the config.
if (isset($this->config->format)) {
$format = $this->config->format;
}
list($bc->content, $bc->contentformat) =
external_format_text($this->config->text, $format, $this->context, 'block_html', 'content', null, $filteropt);
$bc->files = external_util::get_area_files($this->context->id, 'block_html', 'content', false, false);

}
return $bc;
}


/**
* Serialize and store config data
Expand Down

0 comments on commit a9732b8

Please sign in to comment.