Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Commit

Permalink
New: #652.
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Apr 19, 2016
1 parent c6e7d0c commit 493a902
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 46 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ New in 3.0.1.2
- FIX: Missing '$setting->set_updatedcallback('theme_reset_all_caches');' on logo width setting.
- FIX/NEW: Issue #646: Implement MDL-53147 from M3.1 - 'Reading message screen broken when reading one message and have another unread'.
- NEW: Issue #647: Navigation bar in course: without course category links. Thanks to Christian Niemczik for supporting and funding the work on the Essential Theme.
- NEW: Issue #652: Header logo and background refinements.
- NEW: Have the 'This course' menu appear on other course related pages.
- NEW: Tidy up licenses.
- NEW: Tidy up Font Awesome CSS as WOFF2 support was only an issue in M2.8.
- NEW: Logo dimension validation.
- NEW: Update to FontAwesome 4.6.1.
- NEW: Add 'usesiteicon' setting to allow the site icon not to be shown if desired.

New in 3.0.1.1
==============
Expand Down
24 changes: 22 additions & 2 deletions classes/toolbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -492,11 +492,31 @@ static private function hex2rgba($hex, $alpha) {

static public function set_headerbackground($css, $headerbackground) {
$tag = '[[setting:headerbackground]]';

$headerbackgroundstyle = self::get_setting('headerbackgroundstyle');
$replacement = '#page-header {';
$replacement .= 'background-image: url(\'';
if ($headerbackground) {
$replacement = $headerbackground;
$replacement .= $headerbackground;
} else {
$replacement = self::pix_url('bg/header', 'theme');
$replacement .= self::pix_url('bg/header', 'theme');
$headerbackgroundstyle = 'tiled';
}
$replacement .= '\');';

if ($headerbackground) {
$replacement .= 'background-size: contain;';
}

if ($headerbackgroundstyle == 'tiled') {
$replacement .= 'background-repeat: repeat;';
} else {
$replacement .= 'background-repeat: no-repeat;';
$replacement .= 'background-position: center;';
}

$replacement .= '}';

$css = str_replace($tag, $replacement, $css);
return $css;
}
Expand Down
38 changes: 23 additions & 15 deletions lang/en/theme_essential.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@
$string['generalheadingsub'] = 'General settings';
$string['generalheadingdesc'] = 'Configure the general settings for the theme here.';

$string['pagebackground'] = 'Page background image';
$string['pagebackgrounddesc'] = 'Upload your own background image. Select the style of the image below.';
$string['pagebackgroundstyle'] = 'Page background style';
$string['pagebackgroundstyledesc'] = 'Select the style for the uploaded image.';
$string['stylefixed'] = 'Fixed';
$string['styletiled'] = 'Tiled';
$string['stylestretch'] = 'Stretch';

$string['customcss'] = 'Custom CSS';
$string['customcssdesc'] = 'Whatever CSS rules you add to this text area will be reflected in every page, making for easier customisation of this theme.';

Expand All @@ -170,9 +178,6 @@
$string['contactinfo'] = 'Contact information';
$string['contactinfodesc'] = 'Enter your contact information';

$string['siteicon'] = 'Site icon';
$string['siteicondesc'] = 'Do not have a logo? Enter the name of the icon you wish to use. List is <a href="http://fortawesome.github.io/Font-Awesome/cheatsheet/" target="_new">here</a>. Just enter what is after the "fa-". ';

$string['favicon'] = 'Custom favicon';
$string['favicondesc'] = 'Upload your own favicon. It should be an .ico file.';

Expand Down Expand Up @@ -312,18 +317,6 @@
$string['footerblockhovercolour'] = 'Footer block link hover colour';
$string['footerblockhovercolourdesc'] = 'Set the colour for your linked block text when hovered over in the footer.';

$string['headerbackground'] = 'Header background image';
$string['headerbackgrounddesc'] = 'Upload your own background image.';
$string['headertextcolor'] = 'Header text colour';
$string['headertextcolordesc'] = 'Set the text colour for the header.';
$string['pagebackground'] = 'Page background image';
$string['pagebackgrounddesc'] = 'Upload your own background image. Select the style of the image below.';
$string['pagebackgroundstyle'] = 'Page background style';
$string['pagebackgroundstyledesc'] = 'Select the style for the uploaded image.';
$string['backgroundstylefixed'] = 'Fixed';
$string['backgroundstyletiled'] = 'Tiled';
$string['backgroundstylestretch'] = 'Stretch';

// Alternate Colour Switcher.
$string['themecolors'] = 'Theme colours';
$string['defaultcolors'] = 'Default colours';
Expand Down Expand Up @@ -599,6 +592,21 @@
$string['oldnavbar'] = 'Use the old navbar position';
$string['oldnavbardesc'] = 'Enable this option to use the old navbar position, placing it below the header.';

$string['usesiteicon'] = 'Use site icon';
$string['usesiteicondesc'] = 'Use the site icon if there is no logo.';

$string['siteicon'] = 'Site icon';
$string['siteicondesc'] = 'Do not have a logo? Enter the name of the icon you wish to use. List is <a href="http://fortawesome.github.io/Font-Awesome/cheatsheet/" target="_new">here</a>. Just enter what is after the "fa-".';

$string['headertextcolor'] = 'Header text colour';
$string['headertextcolordesc'] = 'Set the text colour for the header.';

$string['headerbackground'] = 'Header background image';
$string['headerbackgrounddesc'] = 'Upload your own background image.';

$string['headerbackgroundstyle'] = 'Header background style';
$string['headerbackgroundstyledesc'] = 'Select the style for the header background.';

$string['editingmenu'] = 'Page editing switch';
$string['editingmenudesc'] = 'Displays a button to switch the editing of the current page on/off if the user is allowed to edit the page. The same functionality as the normal page editing button.';
$string['displayeditingmenu'] = 'Display editing button';
Expand Down
20 changes: 14 additions & 6 deletions layout/tiles/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,20 @@
<div class="<?php echo (!$left) ? 'pull-right' : 'pull-left'; ?>">
<?php
if (!$haslogo) {
echo '<a class="textlogo" href="';
echo preg_replace("(https?:)", "", $CFG->wwwroot);
echo '">';
echo '<span id="headerlogo" aria-hidden="true" class="fa fa-'.\theme_essential\toolbox::get_setting('siteicon').'"></span>';
echo '<div class="titlearea">'.$OUTPUT->get_title('header').'</div>';
echo '</a>';
$usesiteicon = \theme_essential\toolbox::get_setting('usesiteicon');
$headertitle = $OUTPUT->get_title('header');
if ($usesiteicon || $headertitle) {
echo '<a class="textlogo" href="';
echo preg_replace("(https?:)", "", $CFG->wwwroot);
echo '">';
if ($usesiteicon) {
echo '<span id="headerlogo" aria-hidden="true" class="fa fa-'.\theme_essential\toolbox::get_setting('siteicon').'"></span>';
}
if ($headertitle) {
echo '<div class="titlearea">'.$headertitle.'</div>';
}
echo '</a>';
}
} else {
echo '<a class="logo" href="'.preg_replace("(https?:)", "", $CFG->wwwroot).'" title="'.get_string('home').'"></a>';
}
Expand Down
1 change: 0 additions & 1 deletion less/essential/settings/header.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
max-height: 52px;
}
color: ~"[[setting:headertextcolor]]";
background: url(~"'[[setting:headerbackground]]'") repeat;

h1#title {
color: ~"[[setting:headertextcolor]]";
Expand Down
61 changes: 42 additions & 19 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
$default = 'fixed';
$setting = new admin_setting_configselect($name, $title, $description, $default,
array(
'fixed' => get_string('backgroundstylefixed', 'theme_essential'),
'tiled' => get_string('backgroundstyletiled', 'theme_essential'),
'stretch' => get_string('backgroundstylestretch', 'theme_essential')
'fixed' => get_string('stylefixed', 'theme_essential'),
'tiled' => get_string('styletiled', 'theme_essential'),
'stretch' => get_string('stylestretch', 'theme_essential')
)
);
$setting->set_updatedcallback('theme_reset_all_caches');
Expand Down Expand Up @@ -676,6 +676,15 @@
$setting->set_updatedcallback('theme_reset_all_caches');
$essentialsettingsheader->add($setting);

// Use the site icon if there is no logo.
$name = 'theme_essential/usesiteicon';
$title = get_string('usesiteicon', 'theme_essential');
$description = get_string('usesiteicondesc', 'theme_essential');
$default = true;
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false);
$setting->set_updatedcallback('theme_reset_all_caches');
$essentialsettingsheader->add($setting);

// Default Site icon setting.
$name = 'theme_essential/siteicon';
$title = get_string('siteicon', 'theme_essential');
Expand All @@ -684,6 +693,22 @@
$setting = new admin_setting_configtext($name, $title, $description, $default);
$essentialsettingsheader->add($setting);

// Header title setting.
$name = 'theme_essential/headertitle';
$title = get_string('headertitle', 'theme_essential');
$description = get_string('headertitledesc', 'theme_essential');
$default = '1';
$choices = array(
0 => get_string('notitle', 'theme_essential'),
1 => get_string('fullname', 'theme_essential'),
2 => get_string('shortname', 'theme_essential'),
3 => get_string('fullnamesummary', 'theme_essential'),
4 => get_string('shortnamesummary', 'theme_essential')
);
$setting = new admin_setting_configselect($name, $title, $description, $default, $choices);
$setting->set_updatedcallback('theme_reset_all_caches');
$essentialsettingsheader->add($setting);

// Logo file setting.
$name = 'theme_essential/logo';
$title = get_string('logo', 'theme_essential');
Expand Down Expand Up @@ -712,22 +737,6 @@
$setting->set_updatedcallback('theme_reset_all_caches');
$essentialsettingsheader->add($setting);

// Header title setting.
$name = 'theme_essential/headertitle';
$title = get_string('headertitle', 'theme_essential');
$description = get_string('headertitledesc', 'theme_essential');
$default = '1';
$choices = array(
0 => get_string('notitle', 'theme_essential'),
1 => get_string('fullname', 'theme_essential'),
2 => get_string('shortname', 'theme_essential'),
3 => get_string('fullnamesummary', 'theme_essential'),
4 => get_string('shortnamesummary', 'theme_essential')
);
$setting = new admin_setting_configselect($name, $title, $description, $default, $choices);
$setting->set_updatedcallback('theme_reset_all_caches');
$essentialsettingsheader->add($setting);

// Navbar title setting.
$name = 'theme_essential/navbartitle';
$title = get_string('navbartitle', 'theme_essential');
Expand Down Expand Up @@ -760,6 +769,20 @@
$setting->set_updatedcallback('theme_reset_all_caches');
$essentialsettingsheader->add($setting);

// Background style.
$name = 'theme_essential/headerbackgroundstyle';
$title = get_string('headerbackgroundstyle', 'theme_essential');
$description = get_string('headerbackgroundstyledesc', 'theme_essential');
$default = 'tiled';
$setting = new admin_setting_configselect($name, $title, $description, $default,
array(
'fixed' => get_string('stylefixed', 'theme_essential'),
'tiled' => get_string('styletiled', 'theme_essential')
)
);
$setting->set_updatedcallback('theme_reset_all_caches');
$essentialsettingsheader->add($setting);

// Choose breadcrumbstyle.
$name = 'theme_essential/breadcrumbstyle';
$title = get_string('breadcrumbstyle', 'theme_essential');
Expand Down
2 changes: 2 additions & 0 deletions style/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@

[[setting:fontfilesbody]]

[[setting:headerbackground]]

[[setting:customcss]]
2 changes: 1 addition & 1 deletion style/essential-rtl_ie9.css

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion style/essential-settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,6 @@ body#page-grade-grading-pick #region-main form #fgroup_id_buttonar label {
/* @group Header */
#page-header {
color: [[setting:headertextcolor]];
background: url('[[setting:headerbackground]]') repeat;
}
#page-header.logo {
height: [[setting:logoheight]];
Expand Down
2 changes: 1 addition & 1 deletion style/essential_ie9.css

Large diffs are not rendered by default.

0 comments on commit 493a902

Please sign in to comment.