diff --git a/theme/noname/classes/output/core_renderer.php b/theme/noname/classes/output/core_renderer.php index cd1609b81ec..9b82b116aa1 100644 --- a/theme/noname/classes/output/core_renderer.php +++ b/theme/noname/classes/output/core_renderer.php @@ -32,6 +32,7 @@ use single_button; use single_select; use paging_bar; use url_select; +use context_course; defined('MOODLE_INTERNAL') || die; @@ -76,6 +77,64 @@ class core_renderer extends \core_renderer { return $this->render_from_template('core/navbar', $this->page->navbar); } + /** + * Override to inject the logo. + * + * @param array $headerinfo The header info. + * @param int $headinglevel What level the 'h' tag will be. + * @return string HTML for the header bar. + */ + public function context_header($headerinfo = null, $headinglevel = 1) { + global $SITE; + + if ($this->should_display_main_logo($headinglevel)) { + $sitename = format_string($SITE->fullname, true, array('context' => context_course::instance(SITEID))); + return html_writer::div(html_writer::empty_tag('img', [ + 'src' => $this->get_logo_url(null, 75), 'alt' => $sitename]), 'logo'); + } + + return parent::context_header($headerinfo, $headinglevel); + } + + /** + * Get the compact logo URL. + * + * @return string + */ + public function get_compact_logo_url($maxwidth = 100, $maxheight = 100) { + return parent::get_compact_logo_url(null, 43); + } + + /** + * Whether we should display the main logo. + * + * @return bool + */ + public function should_display_main_logo($headinglevel = 1) { + global $PAGE; + + // Only render the logo if we're on the front page or login page and the we have a logo. + $logo = $this->get_logo_url(); + if ($headinglevel == 1 && !empty($logo)) { + if ($PAGE->pagelayout == 'frontpage' || $PAGE->pagelayout == 'login') { + return true; + } + } + + return false; + } + /** + * Whether we should display the logo in the navbar. + * + * We will when there are no main logos, and we have compact logo. + * + * @return bool + */ + public function should_display_navbar_logo() { + $logo = $this->get_compact_logo_url(); + return !empty($logo) && !$this->should_display_main_logo(); + } + /* * Overriding the custom_menu function ensures the custom menu is * always shown, even if no menu items are configured in the global diff --git a/theme/noname/scss/moodle/core.scss b/theme/noname/scss/moodle/core.scss index ee6f715b0ff..92f04c72cd7 100644 --- a/theme/noname/scss/moodle/core.scss +++ b/theme/noname/scss/moodle/core.scss @@ -1615,6 +1615,26 @@ img#persona_signin { } .breadcrumb-nav .breadcrumb { margin: 0; + +} +/** Navbar */ +.navbar-brand { + .logo { + display: inline-block; + margin-top: -$navbar-brand-padding-y; + } + .site-name { + display: inline-block; + margin-left: $spacer/2; + } + height: 43px; +} + +/** Page header */ +#page-header { + .logo { + margin: $spacer 0; + } } /** Header-bar styles **/ diff --git a/theme/noname/templates/columns1.mustache b/theme/noname/templates/columns1.mustache index ae220cf97f4..8de1d06ebb3 100644 --- a/theme/noname/templates/columns1.mustache +++ b/theme/noname/templates/columns1.mustache @@ -15,7 +15,16 @@
- {{{ sitename }}} + + + {{# output.should_display_navbar_logo }} + + {{/ output.should_display_navbar_logo }} +
{{{ sitename }}}
+
+ {{{ output.user_menu }}} diff --git a/theme/noname/templates/columns2.mustache b/theme/noname/templates/columns2.mustache index 1eda87c97f7..bd58e8e7b42 100644 --- a/theme/noname/templates/columns2.mustache +++ b/theme/noname/templates/columns2.mustache @@ -15,7 +15,16 @@
- {{{ sitename }}} + + + {{# output.should_display_navbar_logo }} + + {{/ output.should_display_navbar_logo }} +
{{{ sitename }}}
+
+ {{{ output.user_menu }}} diff --git a/theme/noname/templates/columns3.mustache b/theme/noname/templates/columns3.mustache index ce82ed48d43..abd818d78e2 100644 --- a/theme/noname/templates/columns3.mustache +++ b/theme/noname/templates/columns3.mustache @@ -15,7 +15,16 @@
- {{{ sitename }}} + + + {{# output.should_display_navbar_logo }} + + {{/ output.should_display_navbar_logo }} +
{{{ sitename }}}
+
+ {{{ output.user_menu }}} diff --git a/theme/noname/templates/secure.mustache b/theme/noname/templates/secure.mustache index 2e616adb921..252414aaec9 100644 --- a/theme/noname/templates/secure.mustache +++ b/theme/noname/templates/secure.mustache @@ -15,7 +15,15 @@
- {{{ sitename }}} + + + {{# output.should_display_navbar_logo }} + + {{/ output.should_display_navbar_logo }} +
{{{ sitename }}}
+