diff --git a/theme/clean/classes/core_renderer.php b/theme/clean/classes/core_renderer.php index 14f8eeb900e..ff09b25e5e5 100644 --- a/theme/clean/classes/core_renderer.php +++ b/theme/clean/classes/core_renderer.php @@ -56,7 +56,8 @@ class theme_clean_core_renderer extends theme_bootstrapbase_core_renderer { // Only render the logo if we're on the front page or login page // and the theme has a logo. - if ($headinglevel == 1 && !empty($this->page->theme->settings->logo)) { + $logo = $this->get_logo_url(); + if ($headinglevel == 1 && !empty($logo)) { if ($PAGE->pagelayout == 'frontpage' || $PAGE->pagelayout == 'login') { return true; } @@ -76,11 +77,11 @@ class theme_clean_core_renderer extends theme_bootstrapbase_core_renderer { public function navbar_home($returnlink = true) { global $CFG; - if ($this->should_render_logo() || empty($this->page->theme->settings->smalllogo)) { + $imageurl = $this->get_compact_logo_url(null, 35); + if ($this->should_render_logo() || empty($imageurl)) { // If there is no small logo we always show the site name. return $this->get_home_ref($returnlink); } - $imageurl = $this->page->theme->setting_file_url('smalllogo', 'smalllogo'); $image = html_writer::img($imageurl, get_string('sitelogo', 'theme_' . $this->page->theme->name), array('class' => 'small-logo')); @@ -118,4 +119,37 @@ class theme_clean_core_renderer extends theme_bootstrapbase_core_renderer { return html_writer::tag('span', $sitename, array('class' => 'brand')); } + + /** + * Return the theme logo URL, else the site's logo URL, if any. + * + * Note that maximum sizes are not applied to the theme logo. + * + * @param int $maxwidth The maximum width, or null when the maximum width does not matter. + * @param int $maxheight The maximum height, or null when the maximum height does not matter. + * @return moodle_url|false + */ + public function get_logo_url($maxwidth = null, $maxheight = 100) { + if (!empty($this->page->theme->settings->logo)) { + return $this->page->theme->setting_file_url('logo', 'logo'); + } + return parent::get_logo_url($maxwidth, $maxheight); + } + + /** + * Return the theme's compact logo URL, else the site's compact logo URL, if any. + * + * Note that maximum sizes are not applied to the theme logo. + * + * @param int $maxwidth The maximum width, or null when the maximum width does not matter. + * @param int $maxheight The maximum height, or null when the maximum height does not matter. + * @return moodle_url|false + */ + public function get_compact_logo_url($maxwidth = 100, $maxheight = 100) { + if (!empty($this->page->theme->settings->smalllogo)) { + return $this->page->theme->setting_file_url('smalllogo', 'smalllogo'); + } + return parent::get_compact_logo_url($maxwidth, $maxheight); + } + } diff --git a/theme/clean/lang/en/theme_clean.php b/theme/clean/lang/en/theme_clean.php index 97c6cc13451..45aa332f224 100644 --- a/theme/clean/lang/en/theme_clean.php +++ b/theme/clean/lang/en/theme_clean.php @@ -57,7 +57,7 @@ $string['invert'] = 'Invert navbar'; $string['invertdesc'] = 'Swaps text and background for the navbar at the top of the page between black and white.'; $string['logo'] = 'Logo'; -$string['logodesc'] = 'The logo is only displayed in the header of the front page and login page.
If the height of your logo is more than 75px add div.logo {height: 100px;} to the Custom CSS box below, amending accordingly if the height is other than 100px.'; +$string['logodesc'] = 'The logo is only displayed in the header of the front page and login page.
If the height of your logo is more than 75px add div.logo {height: 100px;} to the Custom CSS box below, amending accordingly if the height is other than 100px. Note that when not set, the logo from \'Appearance > Branding\' will be used.'; $string['pluginname'] = 'Clean'; @@ -68,4 +68,4 @@ $string['sitelogo'] = 'Site logo'; $string['sitename'] = 'Display site name along with small logo'; $string['sitenamedesc'] = 'If there is no small logo, the site name is always displayed in the navigation bar. If a small logo is set, it may be displayed with or without the site name.'; $string['smalllogo'] = 'Small logo'; -$string['smalllogodesc'] = 'The small logo is displayed in the navigation bar. If there is a header logo for the front page and login page, the small logo is not displayed on these pages.'; +$string['smalllogodesc'] = 'The small logo is displayed in the navigation bar. If there is a header logo for the front page and login page, the small logo is not displayed on these pages. Note that when not set, the compact logo from \'Appearance > Branding\' will be used.'; diff --git a/theme/clean/lib.php b/theme/clean/lib.php index 889c9aea064..f7a5202c7e6 100644 --- a/theme/clean/lib.php +++ b/theme/clean/lib.php @@ -38,9 +38,10 @@ * @return string The parsed CSS The parsed CSS. */ function theme_clean_process_css($css, $theme) { + global $OUTPUT; // Set the background image for the logo. - $logo = $theme->setting_file_url('logo', 'logo'); + $logo = $OUTPUT->get_logo_url(null, 75); $css = theme_clean_set_logo($css, $logo); // Set custom CSS. diff --git a/theme/more/lang/en/theme_more.php b/theme/more/lang/en/theme_more.php index acd7bb6ac8e..e5fa4ca0111 100644 --- a/theme/more/lang/en/theme_more.php +++ b/theme/more/lang/en/theme_more.php @@ -64,7 +64,7 @@ $string['invertdesc'] = 'Swaps text and background for the navbar at the top of $string['linkcolor'] = 'Link colour'; $string['linkcolor_desc'] = 'The colour of the links.'; $string['logo'] = 'Logo'; -$string['logodesc'] = 'The logo is only displayed in the header of the front page and login page.
If the height of your logo is more than 75px add div.logo {height: 100px;} to the Custom CSS box below, amending accordingly if the height is other than 100px.'; +$string['logodesc'] = 'The logo is only displayed in the header of the front page and login page.
If the height of your logo is more than 75px add div.logo {height: 100px;} to the Custom CSS box below, amending accordingly if the height is other than 100px. Note that when not set, the logo from \'Appearance > Branding\' will be used.'; $string['pluginname'] = 'More'; @@ -76,7 +76,7 @@ $string['sitelogo'] = 'Site logo'; $string['sitename'] = 'Display site name along with small logo'; $string['sitenamedesc'] = 'If there is no small logo, the site name is always displayed in the navigation bar. If a small logo is set, it may be displayed with or without the site name.'; $string['smalllogo'] = 'Small logo'; -$string['smalllogodesc'] = 'The small logo is displayed in the navigation bar. If there is a header logo for the front page and login page, the small logo is not displayed on these pages.'; +$string['smalllogodesc'] = 'The small logo is displayed in the navigation bar. If there is a header logo for the front page and login page, the small logo is not displayed on these pages. Note that when not set, the compact logo from \'Appearance > Branding\' will be used.'; $string['textcolor'] = 'Text colour'; $string['textcolor_desc'] = 'The colour of the text.'; diff --git a/theme/more/lib.php b/theme/more/lib.php index b1f6f45b66d..0162903e511 100644 --- a/theme/more/lib.php +++ b/theme/more/lib.php @@ -99,9 +99,10 @@ function theme_more_less_variables($theme) { * @return string The parsed CSS The parsed CSS. */ function theme_more_process_css($css, $theme) { + global $OUTPUT; // Set the background image for the logo. - $logo = $theme->setting_file_url('logo', 'logo'); + $logo = $OUTPUT->get_logo_url(null, 100); $css = theme_more_set_logo($css, $logo); // Set custom CSS.