MDL-63694 block_html: Implement get_content_for_external

This commit is contained in:
Juan Leyva 2018-10-17 16:20:52 +02:00 committed by Eloy Lafuente (stronk7)
parent 96d9a6e430
commit a9732b8977

View File

@ -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