mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-63694 block_html: Implement get_content_for_external
This commit is contained in:
parent
96d9a6e430
commit
a9732b8977
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user