Merge branch 'MDL-50661_master' of git://github.com/dmonllao/moodle

This commit is contained in:
Dan Poltawski
2015-11-30 13:50:22 +00:00
16 changed files with 173 additions and 19 deletions
+54
View File
@@ -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'));
}
}
+5
View File
@@ -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.';
+1 -3
View File
@@ -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">
+1 -3
View File
@@ -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">
+1 -3
View File
@@ -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">
+2 -4
View File
@@ -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">
@@ -90,4 +88,4 @@ echo $OUTPUT->doctype() ?>
</div>
</body>
</html>
</html>
+2 -2
View File
@@ -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();
}
+16
View File
@@ -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');
+31
View File
@@ -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]]
+1 -1
View File
@@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2015111600;
$plugin->version = 2015111601;
$plugin->requires = 2015111000;
$plugin->component = 'theme_clean';
$plugin->dependencies = array(
+5
View File
@@ -72,6 +72,11 @@ $string['region-side-post'] = 'Right';
$string['region-side-pre'] = 'Left';
$string['secondarybackground'] = 'Secondary background colour';
$string['secondarybackground_desc'] = 'The background colour of any secondary content, such as blocks.';
$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.';
$string['textcolor'] = 'Text colour';
$string['textcolor_desc'] = 'The colour of the text.';
+2 -1
View File
@@ -147,7 +147,8 @@ function theme_more_set_logo($css, $logo) {
* @return bool
*/
function theme_more_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
if ($context->contextlevel == CONTEXT_SYSTEM && ($filearea === 'logo' || $filearea === 'backgroundimage')) {
if ($context->contextlevel == CONTEXT_SYSTEM &&
($filearea === 'logo' || $filearea === 'smalllogo' || $filearea === 'backgroundimage')) {
$theme = theme_config::load('more');
// By default, theme files must be cache-able by both browsers and proxies.
if (!array_key_exists('cacheability', $options)) {
+16
View File
@@ -149,6 +149,22 @@ if ($ADMIN->fulltree) {
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);
// Small logo file setting.
$name = 'theme_more/smalllogo';
$title = get_string('smalllogo', 'theme_more');
$description = get_string('smalllogodesc', 'theme_more');
$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_more/sitename';
$title = get_string('sitename', 'theme_more');
$description = get_string('sitenamedesc', 'theme_more');
$setting = new admin_setting_configcheckbox($name, $title, $description, 1);
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);
// Custom CSS file.
$name = 'theme_more/customcss';
$title = get_string('customcss', 'theme_more');
+31
View File
@@ -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]]
+2 -2
View File
@@ -24,10 +24,10 @@
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2015111600;
$plugin->version = 2015111601;
$plugin->requires = 2015111000;
$plugin->component = 'theme_more';
$plugin->dependencies = array(
'theme_bootstrapbase' => 2015111000,
'theme_clean' => 2015111000,
'theme_clean' => 2015111601,
);
+3
View File
@@ -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 ===