diff --git a/theme/clean/classes/core_renderer.php b/theme/clean/classes/core_renderer.php index 4b27144879c..74e7b073c43 100644 --- a/theme/clean/classes/core_renderer.php +++ b/theme/clean/classes/core_renderer.php @@ -64,4 +64,58 @@ class theme_clean_core_renderer extends theme_bootstrapbase_core_renderer { return false; } + + /** + * Returns the navigation bar home reference. + * + * The small logo is only rendered on pages where the logo is not displayed. + * + * @param bool $returnlink Whether to wrap the icon and the site name in links or not + * @return string The site name, the small logo or both depending on the theme settings. + */ + public function navbar_home($returnlink = true) { + global $CFG; + + if ($this->should_render_logo() || empty($this->page->theme->settings->smalllogo)) { + // 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')); + + if ($returnlink) { + $logocontainer = html_writer::link($CFG->wwwroot, $image, + array('class' => 'small-logo-container', 'title' => get_string('home'))); + } else { + $logocontainer = html_writer::tag('span', $image, array('class' => 'small-logo-container')); + } + + // Sitename setting defaults to true. + if (!isset($this->page->theme->settings->sitename) || !empty($this->page->theme->settings->sitename)) { + return $logocontainer . $this->get_home_ref($returnlink); + } + + return $logocontainer; + } + + /** + * Returns a reference to the site home. + * + * It can be either a link or a span. + * + * @param bool $returnlink + * @return string + */ + protected function get_home_ref($returnlink = true) { + global $CFG, $SITE; + + $sitename = format_string($SITE->shortname, true, array('context' => context_course::instance(SITEID))); + + if ($returnlink) { + return html_writer::link($CFG->wwwroot, $sitename, array('class' => 'brand', 'title' => get_string('home'))); + } + + return html_writer::tag('span', $sitename, array('class' => 'brand')); + } } diff --git a/theme/clean/lang/en/theme_clean.php b/theme/clean/lang/en/theme_clean.php index 8904259221a..f98117d8f4d 100644 --- a/theme/clean/lang/en/theme_clean.php +++ b/theme/clean/lang/en/theme_clean.php @@ -64,3 +64,8 @@ $string['pluginname'] = 'Clean'; $string['region-side-post'] = 'Right'; $string['region-side-pre'] = 'Left'; +$string['sitelogo'] = 'Site logo'; +$string['sitename'] = 'Display site name along with small logo'; +$string['sitenamedesc'] = 'This setting is only applied if a "Small logo" is set. If no small logo is set the site name is always displayed in the navigation bar, but if it is you can use this setting to display it or not.'; +$string['smalllogo'] = 'Small logo'; +$string['smalllogodesc'] = 'This logo is displayed in the navbar next to the site name, if a "Logo" is set, then it is only displayed on the pages where the logo is not displayed.'; diff --git a/theme/clean/layout/columns1.php b/theme/clean/layout/columns1.php index 1258e048e89..ab4e25ade0e 100644 --- a/theme/clean/layout/columns1.php +++ b/theme/clean/layout/columns1.php @@ -41,9 +41,7 @@ echo $OUTPUT->doctype() ?>