Skip to content
Snippets Groups Projects
Commit ba27f6db authored by Kathrin Osswald's avatar Kathrin Osswald Committed by Alexander Bias
Browse files

Initial creation of a Boost Campus child theme

parent 7ff6dde6
No related branches found
No related tags found
No related merge requests found
language: php
sudo: false
addons:
firefox: "47.0.1"
postgresql: "9.3"
apt:
packages:
- oracle-java8-installer
- oracle-java8-set-default
cache:
directories:
- $HOME/.composer/cache
- $HOME/.npm
php:
- 5.6
- 7.0
- 7.1
env:
global:
- MOODLE_BRANCH=MOODLE_32_STABLE
matrix:
- DB=pgsql
- DB=mysqli
before_install:
- phpenv config-rm xdebug.ini
- nvm install 8.9
- nvm use 8.9
- cd ../..
- composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^2
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
install:
- moodle-plugin-ci install
script:
- moodle-plugin-ci phplint
- moodle-plugin-ci phpcpd
- moodle-plugin-ci phpmd
- moodle-plugin-ci codechecker
- moodle-plugin-ci validate
- moodle-plugin-ci savepoints
- moodle-plugin-ci mustache
- moodle-plugin-ci grunt
- moodle-plugin-ci phpunit
- moodle-plugin-ci behat --dump
moodle-theme_boost_campus_child
===============================
Changes
-------
### Unreleased
* 2017-11-15 - Initial creation of a Boost Campus child theme
# moodle-theme_boost_campus_child
Moodle Boost Campus child theme which delivers the full Boost Campus features, but can be configured with different brand colors or adding additional SCSS to support corporate identity purposes of certain institutions on campus.
moodle-theme_boost_campus_child
===============================
[![Build Status](https://travis-ci.org/moodleuulm/moodle-theme_boost_campus_child.svg?branch=master)](https://travis-ci.org/moodleuulm/moodle-theme_boost_campus_child)
Moodle Boost Campus child theme which is intended to get the full Boost Campus features but easy to change in color and adding additional SCSS for example for delivering several identical based themes for different users.
Requirements
------------
This plugin requires Moodle 3.2+
Motivation for this theme
-------------------------
We implemented this Boost Campus child theme for easy delivering several identical based themes for different users.
Installation
------------
Install the plugin like any other theme to folder
/theme/boost_campus_child
See http://docs.moodle.org/en/Installing_plugins for details on installing Moodle plugins
Usage & Settings
----------------
After installing the theme, it does not do anything to Moodle yet.
To configure the theme and its behaviour, please visit:
Site administration -> Appearance -> Themes -> Boost Campus Child.
There, you find multiple settings tabs:
### 1. Tab "General Settings"
In this tab there are the following settings:
#### Theme presets
##### Theme preset
This setting is already available in the Moodle core theme Boost. For more information how to use it, please have a look at the official Moodle documentation: http://docs.moodle.org/en/Boost_theme
##### Additional theme preset files
This setting is already available in the Moodle core theme Boost. For more information how to use it, please have a look at the official Moodle documentation: http://docs.moodle.org/en/Boost_theme
#### Brand colors
##### Brand color
This setting is already available in the Moodle core theme Boost. For more information how to use it, please have a look at the official Moodle documentation: http://docs.moodle.org/en/Boost_theme
##### Brand success color
This color is used for example in regards to form validations.
##### Brand info color
This color is used for example for availability information of course activities or resources.
##### Brand warning color
This color is used for example for warning texts.
##### Brand danger color
This color is used for example in regards to form validations.
### 2. Tab "Advanced Settings"
In this tab there are the following settings:
#### Raw initial SCSS
This setting is already available in the Moodle core theme Boost. For more information how to use it, please have a look at the official Moodle documentation: http://docs.moodle.org/en/Boost_theme
#### Raw SCSS
This setting is already available in the Moodle core theme Boost. For more information how to use it, please have a look at the official Moodle documentation: http://docs.moodle.org/en/Boost_theme
How this theme works
--------------------
This Boost Campus child theme is implemented with minimal code duplication in mind. It inherits / requires as much code as possible from theme_boost and theme_boost_campus.
All settings and the entire design (SCSS - pre and post as well as the Raw SCSS part) is completely inherited from theme_boost_campus. So you get a functional and optical duplicate of your existing Boost Campus theme with the possibility to alter or extend it.
How to clone this theme for just another child theme instance
-------------------------------------------------------------
* Copy the directoy /theme/boost_campus_child to /theme/boost_campus/foo
* Search and replace the string "theme_boost_campus_child" within this directory with "theme_boost_campus_foo"
* Rename the file /theme/boost_campus_child/lang/en/theme_boost_campus_child.php to /theme/boost_campus_foo/lang/en/theme_boost_campus_foo.php
* Modify the strings "pluginname" and "configtitle" in /theme/boost_campus_foo/lang/en/theme_boost_campus_foo.php according to your needs
Plugin repositories
-------------------
This plugin is not published in the Moodle plugins repository.
The latest development version can be found on Github:
https://github.com/moodleuulm/moodle-theme_boost_campus_child
Bug and problem reports / Support requests
------------------------------------------
This plugin is carefully developed and thoroughly tested, but bugs and problems can always appear.
Please report bugs and problems on Github:
https://github.com/moodleuulm/moodle-theme_boost_campus_child/issues
We will do our best to solve your problems, but please note that due to limited resources we can't always provide per-case support.
Feature proposals
-----------------
Due to limited resources, the functionality of this plugin is primarily implemented for our own local needs and published as-is to the community. We are aware that members of the community will have other needs and would love to see them solved by this plugin.
Please issue feature proposals on Github:
https://github.com/moodleuulm/moodle-theme_boost_campus_child/issues
Please create pull requests on Github:
https://github.com/moodleuulm/moodle-theme_boost_campus_child/pulls
We are always interested to read about your feature proposals or even get a pull request from you, but please accept that we can handle your issues only as feature _proposals_ and not as feature _requests_.
Moodle release support
----------------------
Due to limited resources, this plugin is only maintained for the most recent major release of Moodle. However, previous versions of this plugin which work in legacy major releases of Moodle are still available as-is without any further updates in the Moodle Plugins repository.
There may be several weeks after a new major release of Moodle has been published until we can do a compatibility check and fix problems if necessary. If you encounter problems with a new major release of Moodle - or can confirm that this plugin still works with a new major relase - please let us know on Github.
If you are running a legacy version of Moodle, but want or need to run the latest version of this plugin, you can get the latest version of the plugin, remove the line starting with $plugin->requires from version.php and use this latest plugin version then on your legacy Moodle. However, please note that you will run this setup completely at your own risk. We can't support this approach in any way and there is a undeniable risk for erratic behavior.
Translating this plugin
-----------------------
This child theme does not contain any strings which are visible to a Moodle student / teacher and it can't be translated on AMOS as it is not published in the Moodle plugins repository. In our point of view, translating this plugin is not necessary.
Right-to-left support
---------------------
This plugin has not been tested with Moodle's support for right-to-left (RTL) languages.
If you want to use this plugin with a RTL language and it doesn't work as-is, you are free to send us a pull request on Github with modifications.
PHP7 Support
------------
Since Moodle 3.0, Moodle core basically supports PHP7.
Please note that PHP7 support is on our roadmap for this plugin, but it has not yet been thoroughly tested for PHP7 support and we are still running it in production on PHP5.
If you encounter any success or failure with this plugin and PHP7, please let us know.
Copyright
---------
Ulm University
kiz - Media Department
Team Web & Teaching Support
Kathrin Osswald
<?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 - Theme config
*
* @package theme_boost_campus_child
* @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();
$THEME->name = 'boost_campus_child';
$THEME->parents = ['boost_campus', 'boost'];
$THEME->editor_sheets = [];
$THEME->scss = function($theme) {
return theme_boost_campus_child_get_main_scss_content($theme);
};
$THEME->enable_dock = false;
$THEME->extrascsscallback = 'theme_boost_campus_child_get_extra_scss';
$THEME->prescsscallback = 'theme_boost_campus_child_get_pre_scss';
$THEME->yuicssmodules = array();
$THEME->rendererfactory = 'theme_overridden_renderer_factory';
$THEME->requiredblocks = ' ';
$THEME->addblockposition = BLOCK_ADDBLOCK_POSITION_DEFAULT;
<?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 Med - Language pack
*
* @package theme_boost_campus_child
* @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();
// GENERAL.
$string['pluginname'] = 'Boost Campus Child';
$string['choosereadme'] = 'Theme Boost Campus Child is a child theme of Boost Campus and used to use all features of the theme Boost Campus but with the possibility to change colors easily and add own SCSS.';
// SETTINGS.
$string['configtitle'] = 'Boost Campus Child settings';
lib.php 0 → 100644
<?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 Med - Library
*
* @package theme_boost_campus_child
* @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();
/**
* Inject additional SCSS.
*
* @param theme_config $theme The theme config object.
* @return string
*/
function theme_boost_campus_child_get_extra_scss($theme) {
// MODIFICATION START: Add the variables from the theme Boost Campus settings.
// We need to work with stdclass here because the function expects the parameter to have a certain data structure.
// We rebuild this data structure here.
$boostcampusconfig = new stdclass();
// Get the config.
$boostcampusconfig->settings = get_config('theme_boost_campus');
// Get the pre scss from the parent theme Boost Campus.
$boostcampusrawscss = theme_boost_get_extra_scss($boostcampusconfig);
if (!empty($theme->settings->scss) || !empty($boostcampusrawscss)) {
// Return the Raw SCSS from Boost Campus and Boost Campus Child.
return $boostcampusrawscss . $theme->settings->scss;
} else {
return '';
}
// MODIFICATION END.
/* ORIGINAL START.
return !empty($theme->settings->scss) ? $theme->settings->scss : '';
ORIGINAL END. */
}
/**
* Returns the main SCSS content.
*
* @param theme_config $theme The theme config object.
* @return string
*/
function theme_boost_campus_child_get_main_scss_content($theme) {
global $CFG;
$scss = '';
$filename = !empty($theme->settings->preset) ? $theme->settings->preset : null;
$fs = get_file_storage();
$context = context_system::instance();
if ($filename == 'default.scss') {
// We still load the default preset files directly from the boost theme. No sense in duplicating them.
$scss .= file_get_contents($CFG->dirroot . '/theme/boost/scss/preset/default.scss');
} else if ($filename == 'plain.scss') {
// We still load the default preset files directly from the boost theme. No sense in duplicating them.
$scss .= file_get_contents($CFG->dirroot . '/theme/boost/scss/preset/plain.scss');
} else if ($filename && ($presetfile = $fs->get_file($context->id, 'theme_boost_campus_child', 'preset', 0, '/', $filename))) {
// This preset file was fetched from the file area for theme_boost_campus_child and not theme_boost (see the line above).
$scss .= $presetfile->get_content();
} else {
// Safety fallback - maybe new installs etc.
$scss .= file_get_contents($CFG->dirroot . '/theme/boost/scss/preset/default.scss');
}
// Pre CSS - this is loaded AFTER any prescss from the setting but before the main scss.
$pre = file_get_contents($CFG->dirroot . '/theme/boost_campus_child/scss/pre.scss');
// MODIFICATION START: Add the PRE SCSS from the parent theme Boost Campus.
$preboostcampus = file_get_contents($CFG->dirroot . '/theme/boost_campus/scss/pre.scss');
// MODIFICATION END.
// Post CSS - this is loaded AFTER the main scss but before the extra scss from the setting.
$post = file_get_contents($CFG->dirroot . '/theme/boost_campus_child/scss/post.scss');
// MODIFICATION START: Add the POST SCSS from the parent theme Boost Campus.
$postboostcampus = file_get_contents($CFG->dirroot . '/theme/boost_campus/scss/post.scss');
// MODIFICATION END.
// Combine them together.
// MODIFICATION START: Add all SCSS content together.
return $preboostcampus . "\n" . $pre . "\n" . $scss . "\n" . $postboostcampus ."\n" . $post;
// MODIFICATION END.
/* OROGINAL START
return $pre . "\n" . $scss . "\n" . $post;
ORIGINAL END */
}
/**
* Override to add CSS values from settings to pre scss file.
*
* Get SCSS to prepend.
*
* @param theme_config $theme The theme config object.
* @return array
*/
function theme_boost_campus_child_get_pre_scss($theme) {
// MODIFICATION START: Add the variables from the theme Boost Campus settings.
// We need to work with stdclass here because the function expects the parameter to have a certain data structure.
// We rebuild this data structure here.
$boostcampusconfig = new stdclass();
// Get the config.
$boostcampusconfig->settings = get_config('theme_boost_campus');
// Get the pre scss from the parent theme Boost Campus.
$boostcampusprescss = theme_boost_campus_get_pre_scss($boostcampusconfig);
// MODIFICATION END.
$scss = '';
$configurable = [
// Config key => [variableName, ...].
'brandcolor' => ['brand-primary'],
// MODIFICATION START: Add own variables.
'brandsuccesscolor' => ['brand-success'],
'brandinfocolor' => ['brand-info'],
'brandwarningcolor' => ['brand-warning'],
'branddangercolor' => ['brand-danger'],
// MODIFICATION END.
];
// Prepend variables first.
foreach ($configurable as $configkey => $targets) {
$value = isset($theme->settings->{$configkey}) ? $theme->settings->{$configkey} : null;
if (empty($value)) {
continue;
}
array_map(function($target) use (&$scss, $value) {
$scss = '$' . $target . ': ' . $value . ";\n";
}, (array) $targets);
}
// Prepend pre-scss.
if (!empty($theme->settings->scsspre)) {
$scss .= $theme->settings->scsspre;
}
// MODIFICATION START: Return the target value entries for the Boost Campus settings, too.
return $boostcampusprescss . $scss;
// MODIFICATION END.
/* ORIGINAL START.
return $scss;
ORIGINAL END. */
}
/* This file is empty by purpose.
You can add your SCSS code here if you really need to. */
/* This file is empty by purpose.
You can add your SCSS code here if you really need to. */
<?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 Med - Settings file
*
* @package theme_boost_campus_child
* @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();
if ($ADMIN->fulltree) {
// Create settings page with tabs.
$settings = new theme_boost_admin_settingspage_tabs('themesettingboost_campus_child',
get_string('configtitle', 'theme_boost_campus_child', null, true));
// Create general tab.
$page = new admin_settingpage('theme_boost_campus_child_general', get_string('generalsettings', 'theme_boost', null, true));
// Settings title to group preset related settings together with a common heading. We don't want a description here.
$name = 'theme_boost_campus_child/presetheading';
$title = get_string('presetheadingsetting', 'theme_boost_campus', null, true);
$setting = new admin_setting_heading($name, $title, null);
$page->add($setting);
// Replicate the preset setting from theme_boost.
$name = 'theme_boost_campus_child/preset';
$title = get_string('preset', 'theme_boost', null, true);
$description = get_string('preset_desc', 'theme_boost', null, true);
$default = 'default.scss';
// We list files in our own file area to add to the drop down. We will provide our own function to
// load all the presets from the correct paths.
$context = context_system::instance();
$fs = get_file_storage();
$files = $fs->get_area_files($context->id, 'theme_boost_campus_child', 'preset', 0, 'itemid, filepath, filename', false);
$choices = [];
foreach ($files as $file) {
$choices[$file->get_filename()] = $file->get_filename();
}
// These are the built in presets from Boost.
$choices['default.scss'] = 'default.scss';
$choices['plain.scss'] = 'plain.scss';
$setting = new admin_setting_configselect($name, $title, $description, $default, $choices);
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Preset files setting.
$name = 'theme_boost_campus_child/presetfiles';
$title = get_string('presetfiles', 'theme_boost', null, true);
$description = get_string('presetfiles_desc', 'theme_boost', null, true);
$setting = new admin_setting_configstoredfile($name, $title, $description, 'preset', 0,
array('maxfiles' => 20, 'accepted_types' => array('.scss')));
$page->add($setting);
// Settings title to group brand color related settings together with a common heading. We don't want a description here.
$name = 'theme_boost_campus_child/brandcolorheading';
$title = get_string('brandcolorheadingsetting', 'theme_boost_campus', null, true);
$setting = new admin_setting_heading($name, $title, null);
$page->add($setting);
// Variable $brand-color.
// We use an empty default value because the default colour should come from the preset.
$name = 'theme_boost_campus_child/brandcolor';
$title = get_string('brandcolor', 'theme_boost', null, true);
$description = get_string('brandcolor_desc', 'theme_boost', null, true);
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Variable $brand-succes-color.
$name = 'theme_boost_campus_child/brandsuccesscolor';
$title = get_string('brandsuccesscolorsetting', 'theme_boost_campus', null, true);
$description = get_string('brandsuccesscolorsetting_desc', 'theme_boost_campus', null, true);
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Variable $brand-info-color.
$name = 'theme_boost_campus_child/brandinfocolor';
$title = get_string('brandinfocolorsetting', 'theme_boost_campus', null, true);
$description = get_string('brandinfocolorsetting_desc', 'theme_boost_campus', null, true);
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Variable $brand-warning-color.
$name = 'theme_boost_campus_child/brandwarningcolor';
$title = get_string('brandwarningcolorsetting', 'theme_boost_campus', null, true);
$description = get_string('brandwarningcolorsetting_desc', 'theme_boost_campus', null, true);
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Variable $brand-warning-color.
$name = 'theme_boost_campus_child/branddangercolor';
$title = get_string('branddangercolorsetting', 'theme_boost_campus', null, true);
$description = get_string('branddangercolorsetting_desc', 'theme_boost_campus', null, true);
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Add tab to settings page.
$settings->add($page);
// Create advanced settings tab.
$page = new admin_settingpage('theme_boost_campus_child_advanced', get_string('advancedsettings', 'theme_boost', null, true));
// Raw SCSS to include before the content.
$name = 'theme_boost_campus_child/scsspre';
$title = get_string('rawscsspre', 'theme_boost', null, true);
$description = get_string('rawscsspre_desc', 'theme_boost', null, true);
$setting = new admin_setting_configtextarea($name, $title, $description, '', PARAM_RAW);
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Raw SCSS to include after the content.
$name = 'theme_boost_campus_child/scss';
$title = get_string('rawscss', 'theme_boost', null, true);
$description = get_string('rawscss_desc', 'theme_boost', null, true);
$setting = new admin_setting_configtextarea($name, $title, $description, '', PARAM_RAW);
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Add tab to settings page.
$settings->add($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 - Version file
*
* @package theme_boost_campus_child
* @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();
$plugin->component = 'theme_boost_campus_child';
$plugin->version = 2017111500;
$plugin->release = 'v3.2-r1';
$plugin->requires = 2016120503.05;
$plugin->maturity = MATURITY_STABLE;
$plugin->dependencies = array('theme_boost' => 2016102100, 'theme_boost_campus' => 2017090800);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment