mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-53978 core: Added callbacks for all major render stages
This commit is contained in:
parent
0f59b6dd75
commit
5ebd1fb976
@ -513,9 +513,30 @@ class core_renderer extends renderer_base {
|
||||
*/
|
||||
public function htmlattributes() {
|
||||
$return = get_html_lang(true);
|
||||
$attributes = array();
|
||||
if ($this->page->theme->doctype !== 'html5') {
|
||||
$return .= ' xmlns="http://www.w3.org/1999/xhtml"';
|
||||
$attributes['xmlns'] = 'http://www.w3.org/1999/xhtml';
|
||||
}
|
||||
|
||||
// Give plugins an opportunity to add things like xml namespaces to the html element.
|
||||
// This function should return an array of html attribute names => values.
|
||||
$pluginswithfunction = get_plugins_with_function('add_htmlattributes', 'lib.php');
|
||||
foreach ($pluginswithfunction as $plugins) {
|
||||
foreach ($plugins as $function) {
|
||||
$newattrs = $function();
|
||||
unset($newattrs['dir']);
|
||||
unset($newattrs['lang']);
|
||||
unset($newattrs['xmlns']);
|
||||
unset($newattrs['xml:lang']);
|
||||
$attributes += $newattrs;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($attributes as $key => $val) {
|
||||
$val = s($val);
|
||||
$return .= " $key=\"$val\"";
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
@ -540,6 +561,15 @@ class core_renderer extends renderer_base {
|
||||
|
||||
$output = '';
|
||||
|
||||
// Give plugins an opportunity to add any head elements. The callback
|
||||
// must always return a string containing valid html head content.
|
||||
$pluginswithfunction = get_plugins_with_function('before_standard_html_head', 'lib.php');
|
||||
foreach ($pluginswithfunction as $plugins) {
|
||||
foreach ($plugins as $function) {
|
||||
$output .= $function();
|
||||
}
|
||||
}
|
||||
|
||||
// Allow a url_rewrite plugin to setup any dynamic head content.
|
||||
if (isset($CFG->urlrewriteclass) && !isset($CFG->upgraderunning)) {
|
||||
$class = $CFG->urlrewriteclass;
|
||||
@ -628,7 +658,18 @@ class core_renderer extends renderer_base {
|
||||
if ($this->page->pagelayout !== 'embedded' && !empty($CFG->additionalhtmltopofbody)) {
|
||||
$output .= "\n".$CFG->additionalhtmltopofbody;
|
||||
}
|
||||
|
||||
// Give plugins an opportunity to inject extra html content. The callback
|
||||
// must always return a string containing valid html.
|
||||
$pluginswithfunction = get_plugins_with_function('before_standard_top_of_body_html', 'lib.php');
|
||||
foreach ($pluginswithfunction as $plugins) {
|
||||
foreach ($plugins as $function) {
|
||||
$output .= $function();
|
||||
}
|
||||
}
|
||||
|
||||
$output .= $this->maintenance_warning();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
@ -1001,6 +1042,15 @@ class core_renderer extends renderer_base {
|
||||
public function header() {
|
||||
global $USER, $CFG, $SESSION;
|
||||
|
||||
// Give plugins an opportunity touch things before the http headers are sent
|
||||
// such as adding additional headers. The return value is ignored.
|
||||
$pluginswithfunction = get_plugins_with_function('before_http_headers', 'lib.php');
|
||||
foreach ($pluginswithfunction as $plugins) {
|
||||
foreach ($plugins as $function) {
|
||||
$function();
|
||||
}
|
||||
}
|
||||
|
||||
if (\core\session\manager::is_loggedinas()) {
|
||||
$this->page->add_body_class('userloggedinas');
|
||||
}
|
||||
@ -1112,6 +1162,14 @@ class core_renderer extends renderer_base {
|
||||
public function footer() {
|
||||
global $CFG, $DB, $PAGE;
|
||||
|
||||
// Give plugins an opportunity to touch the page before JS is finalized.
|
||||
$pluginswithfunction = get_plugins_with_function('before_footer', 'lib.php');
|
||||
foreach ($pluginswithfunction as $plugins) {
|
||||
foreach ($plugins as $function) {
|
||||
$function();
|
||||
}
|
||||
}
|
||||
|
||||
$output = $this->container_end_all(true);
|
||||
|
||||
$footer = $this->opencontainers->pop('header/footer');
|
||||
|
Loading…
x
Reference in New Issue
Block a user