mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-50661 theme_clean: New small logo setting
Introduces new settings to set a small logo in the navbar next to the site name on pages where the logo is not displayed.
This commit is contained in:
parent
c18acb8997
commit
c08b52aa74
@ -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'));
|
||||
}
|
||||
}
|
||||
|
@ -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.';
|
||||
|
@ -41,9 +41,7 @@ echo $OUTPUT->doctype() ?>
|
||||
<header role="banner" class="navbar navbar-fixed-top<?php echo $html->navbarclass ?> moodle-has-zindex">
|
||||
<nav role="navigation" class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="brand" href="<?php echo $CFG->wwwroot;?>"><?php echo
|
||||
format_string($SITE->shortname, true, array('context' => context_course::instance(SITEID)));
|
||||
?></a>
|
||||
<?php echo $OUTPUT->navbar_home(); ?>
|
||||
<?php echo $OUTPUT->navbar_button(); ?>
|
||||
<?php echo $OUTPUT->user_menu(); ?>
|
||||
<div class="nav-collapse collapse">
|
||||
|
@ -50,9 +50,7 @@ echo $OUTPUT->doctype() ?>
|
||||
<header role="banner" class="navbar navbar-fixed-top<?php echo $html->navbarclass ?> moodle-has-zindex">
|
||||
<nav role="navigation" class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="brand" href="<?php echo $CFG->wwwroot;?>"><?php echo
|
||||
format_string($SITE->shortname, true, array('context' => context_course::instance(SITEID)));
|
||||
?></a>
|
||||
<?php echo $OUTPUT->navbar_home(); ?>
|
||||
<?php echo $OUTPUT->navbar_button(); ?>
|
||||
<?php echo $OUTPUT->user_menu(); ?>
|
||||
<div class="nav-collapse collapse">
|
||||
|
@ -60,9 +60,7 @@ echo $OUTPUT->doctype() ?>
|
||||
<header role="banner" class="navbar navbar-fixed-top<?php echo $html->navbarclass ?> moodle-has-zindex">
|
||||
<nav role="navigation" class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="brand" href="<?php echo $CFG->wwwroot;?>"><?php echo
|
||||
format_string($SITE->shortname, true, array('context' => context_course::instance(SITEID)));
|
||||
?></a>
|
||||
<?php echo $OUTPUT->navbar_home(); ?>
|
||||
<?php echo $OUTPUT->navbar_button(); ?>
|
||||
<?php echo $OUTPUT->user_menu(); ?>
|
||||
<div class="nav-collapse collapse">
|
||||
|
@ -54,9 +54,7 @@ echo $OUTPUT->doctype() ?>
|
||||
<header role="banner" class="navbar navbar-fixed-top moodle-has-zindex">
|
||||
<nav role="navigation" class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<span class="brand"><?php echo
|
||||
format_string($SITE->shortname, true, array('context' => context_course::instance(SITEID)));
|
||||
?></span>
|
||||
<?php echo $OUTPUT->navbar_home(false); ?>
|
||||
<?php echo $OUTPUT->navbar_button(); ?>
|
||||
<div class="nav-collapse collapse">
|
||||
<ul class="nav pull-right">
|
||||
|
@ -86,13 +86,13 @@ function theme_clean_set_logo($css, $logo) {
|
||||
* @return bool
|
||||
*/
|
||||
function theme_clean_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM and $filearea === 'logo') {
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM and ($filearea === 'logo' || $filearea === 'smalllogo')) {
|
||||
$theme = theme_config::load('clean');
|
||||
// By default, theme files must be cache-able by both browsers and proxies.
|
||||
if (!array_key_exists('cacheability', $options)) {
|
||||
$options['cacheability'] = 'public';
|
||||
}
|
||||
return $theme->setting_file_serve('logo', $args, $forcedownload, $options);
|
||||
return $theme->setting_file_serve($filearea, $args, $forcedownload, $options);
|
||||
} else {
|
||||
send_file_not_found();
|
||||
}
|
||||
|
@ -48,6 +48,22 @@ if ($ADMIN->fulltree) {
|
||||
$setting->set_updatedcallback('theme_reset_all_caches');
|
||||
$settings->add($setting);
|
||||
|
||||
// Small logo file setting.
|
||||
$name = 'theme_clean/smalllogo';
|
||||
$title = get_string('smalllogo', 'theme_clean');
|
||||
$description = get_string('smalllogodesc', 'theme_clean');
|
||||
$setting = new admin_setting_configstoredfile($name, $title, $description, 'smalllogo');
|
||||
$setting->set_updatedcallback('theme_reset_all_caches');
|
||||
$settings->add($setting);
|
||||
|
||||
// Show site name along with small logo.
|
||||
$name = 'theme_clean/sitename';
|
||||
$title = get_string('sitename', 'theme_clean');
|
||||
$description = get_string('sitenamedesc', 'theme_clean');
|
||||
$setting = new admin_setting_configcheckbox($name, $title, $description, 1);
|
||||
$setting->set_updatedcallback('theme_reset_all_caches');
|
||||
$settings->add($setting);
|
||||
|
||||
// Custom CSS file.
|
||||
$name = 'theme_clean/customcss';
|
||||
$title = get_string('customcss', 'theme_clean');
|
||||
|
@ -16,6 +16,37 @@ div.logo {
|
||||
float: right;
|
||||
}
|
||||
|
||||
img.small-logo {
|
||||
float: left;
|
||||
height: 35px;
|
||||
margin: 3px 10px 3px 0;
|
||||
}
|
||||
|
||||
.dir-rtl img.small-logo {
|
||||
float: right;
|
||||
margin: 3px 0 3px 10px;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.dir-rtl img.small-logo,
|
||||
img.small-logo {
|
||||
margin: 3px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.navbar img.small-logo {
|
||||
max-width: 150px;
|
||||
}
|
||||
/* Applying accesshide styles */
|
||||
.navbar .small-logo-container + .brand {
|
||||
position: absolute;
|
||||
left: -10000px;
|
||||
font-size: 1em;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
|
||||
/* Custom CSS Settings
|
||||
-------------------------*/
|
||||
[[setting:customcss]]
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$plugin->version = 2015111600;
|
||||
$plugin->version = 2015111601;
|
||||
$plugin->requires = 2015111000;
|
||||
$plugin->component = 'theme_clean';
|
||||
$plugin->dependencies = array(
|
||||
|
@ -14,6 +14,9 @@ information provided here is intended especially for theme designer.
|
||||
themes extending bootstrapbase and overriding its layouts can call replace their "a.btn-navbar"
|
||||
node for a call to this function.
|
||||
* Themes Clean and More page header logo only displays on front page and login page.
|
||||
* A new function navbar_home has been added to theme_clean and theme_more to display the navigation bar link
|
||||
to the site home. Two new settings have been added to control if the link should be a small logo image, text
|
||||
or both. It defaults to the current behaviour, only a text link.
|
||||
|
||||
=== 2.9 ===
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user