Commit a9732b89 authored by Juan Leyva's avatar Juan Leyva Committed by Eloy Lafuente
Browse files

MDL-63694 block_html: Implement get_content_for_external

parent 96d9a6e4
......@@ -86,6 +86,41 @@ class block_html extends block_base {
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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment