diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 88bf930e180..60cd2dd934a 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -4261,6 +4261,14 @@ EOD; public function full_header() { global $PAGE; + if ($PAGE->include_region_main_settings_in_header_actions()) { + $PAGE->add_header_action(html_writer::div( + $this->region_main_settings_menu(), + 'd-print-none', + ['id' => 'region-main-settings-menu'] + )); + } + $header = new stdClass(); $header->settingsmenu = $this->context_header_settings_menu(); $header->contextheader = $this->context_header(); @@ -4268,6 +4276,7 @@ EOD; $header->navbar = $this->navbar(); $header->pageheadingbutton = $this->page_heading_button(); $header->courseheader = $this->course_header(); + $header->headeractions = $PAGE->get_header_actions(); return $this->render_from_template('core/full_header', $header); } diff --git a/lib/pagelib.php b/lib/pagelib.php index 97d185d8851..1447623977d 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -353,6 +353,16 @@ class moodle_page { */ protected $_forcesettingsmenu = false; + /** + * @var array Array of header actions HTML to add to the page header actions menu. + */ + protected $_headeractions = []; + + /** + * @var bool Should the region main settings menu be rendered in the header. + */ + protected $_regionmainsettingsinheader = false; + /** * Force the settings menu to be displayed on this page. This will only force the * settings menu on an activity / resource page that is being displayed on a theme that @@ -2032,4 +2042,42 @@ class moodle_page { // Finally add the report to the navigation tree. $reportnode->add($nodeinfo['name'], $nodeinfo['url'], navigation_node::TYPE_COURSE); } + + /** + * Add some HTML to the list of actions to render in the header actions menu. + * + * @param string $html The HTML to add. + */ + public function add_header_action(string $html) : void { + $this->_headeractions[] = $html; + } + + /** + * Get the list of HTML for actions to render in the header actions menu. + * + * @return string[] + */ + public function get_header_actions() : array { + return $this->_headeractions; + } + + /** + * Set the flag to indicate if the region main settings should be rendered as an action + * in the header actions menu rather than at the top of the content. + * + * @param bool $value If the settings should be in the header. + */ + public function set_include_region_main_settings_in_header_actions(bool $value) : void { + $this->_regionmainsettingsinheader = $value; + } + + /** + * Check if the region main settings should be rendered as an action in the header actions + * menu rather than at the top of the content. + * + * @return bool + */ + public function include_region_main_settings_in_header_actions() : bool { + return $this->_regionmainsettingsinheader; + } } diff --git a/lib/templates/full_header.mustache b/lib/templates/full_header.mustache index 1954bb2984e..c1feb3ef7c7 100644 --- a/lib/templates/full_header.mustache +++ b/lib/templates/full_header.mustache @@ -32,7 +32,7 @@