Skip to content
Snippets Groups Projects
Commit 219fe920 authored by Kathrin Osswald's avatar Kathrin Osswald
Browse files

Settings to be able to add additional regions beneath the page footer.

parent bf580f5d
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ Changes
### Unreleased
* 2017-06-04 - Settings to be able to add additional regions beneath the page footer.
* 2017-05-22 - Added some section separator lines to the footer.
* 2017-05-22 - Adding the possibility to give additional classes to the list group items of the flat navigation.
* 2017-05-16 - Changed naming and reference of mustache template that renders the login form.
......
......@@ -107,6 +107,26 @@ With this setting you can add an additional course edit on / off button to the c
Moodle provides some default links in the footer: Link to the Moodle docs, login information, and a link to the webpage start. With these three settings you can decide if you want to hide specific links because you think that your users won't need them in your instance. If checked, the link will not be displayed in the footer. If not checked (default), it will be shown.
### Badge area items
With this widget you can upload your images that will be displayed in the additional badge area region. The images will be sorted and displayed alphabetically by the filename. To remove this region, simply delete all uploaded images.
### Badge area item links
With this optional setting you can add links to your uploaded images.
Each line consists of the file identifier (the file name) the a link URL, separated by pipe characters. Each link declaration needs to be written in a new line.
For example:
``moodle.jpg|http://moodle.org``
You can declare links for a abitrary amount of your uploaded images. The links will be added only to those badges that match their filename with the identifier declared in this setting.
### Badge area items maximal height
With this setting you can change the height in pixels for your uploaded badges. All images will have the same maximum height and their width will be resized proportionally. The default value is set to 100 pixels.
### Footnote
Whatever you add to this textarea will be displayed beneath the footer on every page that renders the theme standard footer (for layouts "columns2", "login" and "maintenance"). Content in this area could be for example the copyright, the terms of use and the name of your organisation.
### 4. Tab "Design Settings"
#### Background images for login page
......
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Theme Boost Campus - Cache file.
*
* @package theme_boost_campus
* @copyright 2017 Kathrin Osswald, Ulm University kathrin.osswald@uni-ulm.de
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$definitions = array(
'badgearea' => array(
'mode' => cache_store::MODE_APPLICATION,
'staticacceleration' => true,
)
);
......@@ -102,3 +102,19 @@ $string['branddangercolorsetting_desc'] = 'This color is used for example in reg
$string['navbardesignheadingsetting'] = 'Navbar';
$string['darknavbarsetting'] = 'Dark navbar';
$string['darknavbarsetting_desc'] = 'By checking this setting you can invert the default light navbar to a dark one with white links.';
$string['addionalregionslayoutheadingsetting'] = 'Addional regions';
$string['badgeareaheadingsetting'] = 'The following settings allow to add an additional region for displaying images like badges or logos. This region will be added beneath the standard footer and above the optional footnote region. If images are uploaded this are will be displayed on all sites that use the columns2 layout.';
$string['badgeareaitemssetting'] = 'Badge area items';
$string['badgeareaitemssetting_desc'] = 'With this widget you can upload your images that will be displayed in the additional badge area region. The images will be sorted and displayed alphabetically by the filename. To remove this region, simply delete all uploaded images.';
$string['badgeareaitemslinksetting'] = 'Badge area item links';
$string['badgeareaitemslinksetting_desc'] = 'With this optional setting you can add links to your uplaoded images.<br/>
Each line consists of the file identifier (the file name) the a link URL, separated by pipe characters. Each link declaration needs to be written in a new line. <br/>
For example:<br/>
moodle.jpg|http://moodle.org<br/>
You can declare links for a abitrary amount of your uplaoded images. The links will be added only to those badges that match their filename with the identifier declared in this setting.';
$string['badgeareaitemsmaxheightsetting'] = 'Badge area items maximal height';
$string['badgeareaitemsmaxheightsetting_desc'] = 'With this setting you can change the height in pixels for your uploaded badges. All images will have the same maximum height and their width will be resized proportionally. The default value is set to 100 pixels.';
$string['footnoteheadingsetting'] = 'The following setting allows to add an additional region for displaying a footnote.';
$string['footnotesetting'] = 'Footnote';
$string['footnotesetting_desc'] = 'Whatever you add to this textarea will be displayed at the end of the footer on every page that renders the theme standard footer (for the layouts "columns2" and "login"). Content in this area could be for example the copyright, the terms of use and the name of your organisation. <br/> If you want to remove the footnote again, just empty the text area.';
......@@ -54,7 +54,10 @@ $templatecontext = [
$templatecontext['flatnavigation'] = $PAGE->flatnav;
echo $OUTPUT->render_from_template('theme_boost_campus/columns2', $templatecontext);
/* Add own layouted footer. */
// Add footer blocks and standard footer.
require_once(dirname(__FILE__).'/includes/footer.php');
// Add badgearea.
require_once(dirname(__FILE__).'/includes/badgearea.php');
// Add footnote.
require_once(dirname(__FILE__).'/includes/footnote.php');
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Theme Boost Campus - Layout file for badgearea.
*
* @package theme_boost_campus
* @copyright 2017 Kathrin Osswald, Ulm University kathrin.osswald@uni-ulm.de
* @copyright based on code from theme_boost by Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/theme/boost_campus/locallib.php');
$badgeareafiles = theme_boost_campus_get_badgeareacontent();
// Only proceed with sorting if received array is not empty.
if (!empty($badgeareafiles)) {
$templatecontext['badgeareafiles'] = $badgeareafiles;
echo $OUTPUT->render_from_template('theme_boost_campus/badgearea', $templatecontext);
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Theme Boost Campus - Layout file for footnote.
*
* @package theme_boost_campus
* @copyright 2017 Kathrin Osswald, Ulm University kathrin.osswald@uni-ulm.de
* @copyright based on code from theme_boost by Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$footnotesetting = get_config('theme_boost_campus', 'footnote');
// Only proceed if text area does not only contains empty tags.
if (!html_is_blank($footnotesetting)) {
// Use format_string function to enable multilanguage filtering.
$footnotesetting = format_text($footnotesetting);
$templatecontext['footnotesetting'] = $footnotesetting;
echo $OUTPUT->render_from_template('theme_boost_campus/footnote', $templatecontext);
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
/*
* Theme Boost Campus Login - Layout file.
*
* @package theme_boost_campus
* @copyright 2017 Kathrin Osswald, Ulm University kathrin.osswald@uni-ulm.de
* @copyright based on code from theme_boost by Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$bodyattributes = $OUTPUT->body_attributes();
$templatecontext = [
'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
'output' => $OUTPUT,
'bodyattributes' => $bodyattributes
];
echo $OUTPUT->render_from_template('theme_boost/login', $templatecontext);
/* MOFIFICATION START:
* Include own layout file for the footnote region.
* The theme_boost/login template already renders the standard footer.
* The footer blocks and the badge area are currently not shown on the login page.
* Here, we add the footnote only. */
require_once(dirname(__FILE__).'/includes/footnote.php');
/* MODIFICATION END. */
......@@ -88,6 +88,7 @@ function theme_boost_campus_get_pre_scss($theme) {
'branddangercolor' => ['brand-danger'],
'darknavbar' => ['darknavbar'],
'footerblocks' => ['footerblocks'],
'badgeareaitemsmaxheight' => ['badgeareaitemsmaxheight'],
/* MODIFICATION END */
];
......@@ -135,6 +136,8 @@ function theme_boost_campus_pluginfile($course, $cm, $context, $filearea, $args,
return $theme->setting_file_serve('loginbackgroundimage', $args, $forcedownload, $options);
} else if ($filearea === 'fontfiles') {
return $theme->setting_file_serve('fontfiles', $args, $forcedownload, $options);
} else if ($filearea === 'badgeareaitems') {
return $theme->setting_file_serve('badgeareaitems', $args, $forcedownload, $options);
} else {
send_file_not_found();
}
......@@ -142,3 +145,16 @@ function theme_boost_campus_pluginfile($course, $cm, $context, $filearea, $args,
send_file_not_found();
}
}
/**
* If setting is updated, use this callback to clear the theme_boost_campus' own application cache.
*/
function theme_boost_campus_reset_app_cache() {
// Get the cache from area.
$themeboostcampuscache = cache::make('theme_boost_campus', 'badgearea');
// Delete the cache for the badgearea.
$themeboostcampuscache->delete('badgeareadata');
// To be safe and because there can only be one callback function added to a plugin setting,
// we also delete the complete theme cache here.
theme_reset_all_caches();
}
......@@ -86,3 +86,79 @@ function theme_boost_campus_get_loginbackgroundimage_scss() {
return $scss;
}
/**
* Create information needed for the badgearea.mustache file.
*
* @return array
*/
function theme_boost_campus_get_badgeareacontent() {
// Get cache.
$themeboostcampuscache = cache::make('theme_boost_campus', 'badgearea');
// If cache is filled, return the cache.
$cachecontent = $themeboostcampuscache->get('badgeareadata');
if (!empty($cachecontent)) {
return $cachecontent;
} else { // Create cache.
// Fetch context.
$systemcontext = \context_system::instance();
// Get filearea.
$fs = get_file_storage();
// Get all files from filearea.
$files = $fs->get_area_files($systemcontext->id, 'theme_boost_campus', 'badgeareaitems', false, 'itemid', false);
// Only continue processing if there are files in the filearea.
if (!empty($files)) {
// Get the content from the setting badgeareaitemslink and explode it to an array by the delimiter "new line".
// The string contains: the image identifier (uploaded file name) and the corresponding link URL.
$lines = explode("\n", get_config('theme_boost_campus', 'badgeareaitemslink'));
// Parse item settings.
foreach ($lines as $line) {
$line = trim($line);
// If the setting is empty.
if (strlen($line) == 0) {
// Create an array with a dummy entry because the function array_key_exists need a
// not empty array for parameter 2.
$links = array('foo');
continue;
} else {
$settings = explode("|", $line);
// Check if both parameters are set.
if (!empty($settings[1])) {
// The name of the image is the key for the URL that will be set.
$links[$settings[0]] = $settings[1];
}
}
}
// Traverse the files.
foreach ($files as $file) {
// Get the Moodle url for each file.
$url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(),
$file->get_itemid(), $file->get_filepath(), $file->get_filename());
// Get the path to the file.
$filepath = $url->get_path();
// Get the filename.
$filename = $file->get_filename();
// If filename and key value from the badgeareaitemslink setting entry match.
if (array_key_exists($filename, $links)) {
// Set the file and the corresponding link.
$badgeareacache[] = array('filepath' => $filepath, 'linkpath' => $links[$filename]);
// Fill the cache.
$themeboostcampuscache->set('badgeareadata', $badgeareacache);
} else { // Just add the file without a link.
$badgeareacache[] = array('filepath' => $filepath);
// Fill the cache.
$themeboostcampuscache->set('badgeareadata', $badgeareacache);
}
}
// Sort array alphabetically ascending to the key "filepath".
usort($badgeareacache, function($a, $b) {
return strcmp($a["filepath"], $b["filepath"]);
});
return $badgeareacache;
} else { // If no images are uploaded, then cache an empty array.
return $themeboostcampuscache->set('badgeareadata', array());
}
}
}
......@@ -681,6 +681,39 @@ a[href^="mailto"]::before {
bottom: 15px;
}
/*------------------------------------
Additional Regions
-------------------------------------*/
/*
* Badgearea.
*/
.badgearea {
text-align: center;
background-color: $gray-dark;
border-top: 1px solid #fff;
img {
/* If setting badgeareaitemsmaxheight is not empty. */
@if variable-exists(badgeareaitemsmaxheight) {
/* set the value. */
max-height: #{$badgeareaitemsmaxheight}px;
}
width: auto;
padding-left: 1rem;
padding-right: 1rem;
}
}
/*
* Footnote.
*/
.footnote {
min-height: 40px;
color: #fff;
border-top: 1px solid #fff;
background-color: $gray-dark;
}
/*------------------------------------
Additional Elements
......
......@@ -244,6 +244,50 @@ if ($ADMIN->fulltree) {
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Settings title to group additional regions settings for the footer together with a common heading.
// We don't want a description here.
$setting = new admin_setting_heading('theme_boost_campus/addionalregionslayoutheading',
get_string('addionalregionslayoutheadingsetting', 'theme_boost_campus', null, true), null);
$page->add($setting);
// We want to divide the badgearea setting from the footnote setting. Use a description without a title.
$setting = new admin_setting_heading('theme_boost_campus/badgeareaheading',
null, get_string('badgeareaheadingsetting', 'theme_boost_campus', null, true));
$page->add($setting);
// Badgearea setting.
$name = 'theme_boost_campus/badgeareaitems';
$title = get_string('badgeareaitemssetting', 'theme_boost_campus');
$description = get_string('badgeareaitemssetting_desc', 'theme_boost_campus');
$setting = new admin_setting_configstoredfile($name, $title, $description, 'badgeareaitems', 0, array('maxfiles' => 100,
'accepted_types' => array('web_image'), 'subdirs' => 0));
$setting->set_updatedcallback('theme_boost_campus_reset_app_cache');
$page->add($setting);
$setting = new admin_setting_configtextarea('theme_boost_campus/badgeareaitemslink',
get_string('badgeareaitemslinksetting', 'theme_boost_campus'),
get_string('badgeareaitemslinksetting_desc', 'theme_boost_campus'), null, PARAM_TEXT);
$setting->set_updatedcallback('theme_boost_campus_reset_app_cache');
$page->add($setting);
$setting = new admin_setting_configtext_with_maxlength('theme_boost_campus/badgeareaitemsmaxheight',
get_string('badgeareaitemsmaxheightsetting', 'theme_boost_campus'),
get_string('badgeareaitemsmaxheightsetting_desc', 'theme_boost_campus'), 100, PARAM_INT, null, 3);
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// We want to divide the badgearea seeting from the footnote setting. Use a description without a title.
$setting = new admin_setting_heading('theme_boost_campus/footnoteheading',
null, get_string('footnoteheadingsetting', 'theme_boost_campus', null, true));
$page->add($setting);
// Footnote setting.
$setting = new admin_setting_confightmleditor('theme_boost_campus/footnote',
get_string('footnotesetting', 'theme_boost_campus', null, true),
get_string('footnotesetting_desc', 'theme_boost_campus', null, true), '');
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Add tab to settings page.
$settings->add($page);
......
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template theme_boost_campus/badgearea
Boost_campus badgearea layout template.
Context variables required for this template:
* badgeareafiles - array of uploaded images.
* linkpath - true if image has a link defined in setting badgeareaitemslink.
* filepath - the path where the uploaded image is stored.
Example context (json):
{
"badgeareafiles": {
"filepath": "pix_url('i/course', 'moodle')",
"linkpath": "http://moodle.org"
}
}
}}
<div class="badgearea p-y-1">
<div class="container-fluid">
<div class="row-fluid">
{{#badgeareafiles}}
{{#linkpath}}<a href="{{linkpath}}">{{/linkpath}}
<img src="{{filepath}}">
{{#linkpath}}</a>{{/linkpath}}
{{/badgeareafiles}}
</div>
</div>
</div>
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template theme_boost_campus/footnote
Boost_campus footnote layout template.
Context variables required for this template:
* footnotesetting - The text entered in the setting widget.
Example context (json):
{
"footnotesetting": "<a href='URL to the terms of use'>Terms of use</a>"
}
}}
<div class="footnote p-y-1">
<div class="container-fluid">
<div class="row-fluid">
{{{ footnotesetting }}}
</div>
</div>
</div>
......@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'theme_boost_campus';
$plugin->version = 2017050400;
$plugin->version = 2017060400;
$plugin->release = 'v3.2-r1';
$plugin->requires = 2016070700;
$plugin->maturity = MATURITY_STABLE;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment