diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index 802642c85d2..1cd5b50bc34 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -1113,7 +1113,7 @@ class core_plugin_manager { 'theme' => array( 'afterburner', 'anomaly', 'arialist', 'base', 'binarius', 'bootstrapbase', 'boxxie', 'brick', 'canvas', 'clean', 'formal_white', 'formfactor', - 'fusion', 'leatherbound', 'magazine', 'nimble', + 'fusion', 'leatherbound', 'magazine', 'more', 'nimble', 'nonzero', 'overlay', 'serenity', 'sky_high', 'splash', 'standard', 'standardold' ), diff --git a/theme/clean/config.php b/theme/clean/config.php index cf1605cf6f5..84bdfd7832d 100644 --- a/theme/clean/config.php +++ b/theme/clean/config.php @@ -39,8 +39,6 @@ $THEME->name = 'clean'; $THEME->doctype = 'html5'; $THEME->parents = array('bootstrapbase'); $THEME->sheets = array('custom'); -$THEME->lessfile = 'moodle'; -$THEME->parents_exclude_sheets = array('bootstrapbase' => array('moodle')); $THEME->supportscssoptimisation = false; $THEME->yuicssmodules = array(); $THEME->enable_dock = true; @@ -52,4 +50,4 @@ $THEME->csspostprocess = 'theme_clean_process_css'; $THEME->blockrtlmanipulations = array( 'side-pre' => 'side-post', 'side-post' => 'side-pre' -); \ No newline at end of file +); diff --git a/theme/clean/lib.php b/theme/clean/lib.php index 45554dfea8a..e31a51bdfcd 100644 --- a/theme/clean/lib.php +++ b/theme/clean/lib.php @@ -116,6 +116,9 @@ function theme_clean_set_customcss($css, $customcss) { /** * Returns an object containing HTML for the areas affected by settings. * + * Do not add Clean specific logic in here, child themes should be able to + * rely on that function just by declaring settings with similar names. + * * @param renderer_base $output Pass in $OUTPUT. * @param moodle_page $page Pass in $PAGE. * @return stdClass An object with the following properties: diff --git a/theme/more/config.php b/theme/more/config.php new file mode 100644 index 00000000000..0c23e91ca91 --- /dev/null +++ b/theme/more/config.php @@ -0,0 +1,43 @@ +. + +/** + * Theme More config file. + * + * @package theme_more + * @copyright 2014 Frédéric Massart + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$THEME->name = 'more'; +$THEME->parents = array('clean', 'bootstrapbase'); + +$THEME->doctype = 'html5'; +$THEME->sheets = array('custom'); +$THEME->lessfile = 'moodle'; +$THEME->parents_exclude_sheets = array('bootstrapbase' => array('moodle'), 'clean' => array('custom')); +$THEME->supportscssoptimisation = false; +$THEME->yuicssmodules = array(); +$THEME->enable_dock = true; +$THEME->editor_sheets = array(); + +$THEME->rendererfactory = 'theme_overridden_renderer_factory'; +$THEME->csspostprocess = 'theme_more_process_css'; + +$THEME->blockrtlmanipulations = array( + 'side-pre' => 'side-post', + 'side-post' => 'side-pre' +); diff --git a/theme/more/lang/en/theme_more.php b/theme/more/lang/en/theme_more.php new file mode 100644 index 00000000000..80b2fb301c7 --- /dev/null +++ b/theme/more/lang/en/theme_more.php @@ -0,0 +1,47 @@ +. + +/** + * Theme More lang file. + * + * @package theme_more + * @copyright 2014 Frédéric Massart + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['choosereadme'] = 'More is a theme that allows you to easily customize Moodle\'s look and feel.'; + +$string['configtitle'] = 'More'; + +$string['customcss'] = 'Custom CSS'; +$string['customcssdesc'] = 'Whatever CSS rules you add to this textarea will be reflected in every page, making for easier customization of this theme.'; + +$string['footnote'] = 'Footnote'; +$string['footnotedesc'] = 'Whatever you add to this textarea will be displayed in the footer throughout your Moodle site.'; + +$string['invert'] = 'Invert navbar'; +$string['invertdesc'] = 'Swaps text and background for the navbar at the top of the page between black and white.'; + +$string['logo'] = 'Logo'; +$string['logodesc'] = 'Please upload your custom logo here if you want to add it to the header.
+If the height of your logo is more than 75px add the following CSS rule to the Custom CSS box below.
+a.logo {height: 100px;} or whatever height in pixels the logo is.'; + +$string['pluginname'] = 'More'; + +$string['region-side-post'] = 'Right'; +$string['region-side-pre'] = 'Left'; + diff --git a/theme/clean/less/moodle.less b/theme/more/less/moodle.less similarity index 100% rename from theme/clean/less/moodle.less rename to theme/more/less/moodle.less diff --git a/theme/more/lib.php b/theme/more/lib.php new file mode 100644 index 00000000000..6f70e6f4891 --- /dev/null +++ b/theme/more/lib.php @@ -0,0 +1,108 @@ +. + +/** + * Theme More lib. + * + * @package theme_more + * @copyright 2014 Frédéric Massart + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +/** + * Parses CSS before it is cached. + * + * This function can make alterations and replace patterns within the CSS. + * + * @param string $css The CSS + * @param theme_config $theme The theme config object. + * @return string The parsed CSS The parsed CSS. + */ +function theme_more_process_css($css, $theme) { + + // Set the background image for the logo. + $logo = $theme->setting_file_url('logo', 'logo'); + $css = theme_more_set_logo($css, $logo); + + // Set custom CSS. + if (!empty($theme->settings->customcss)) { + $customcss = $theme->settings->customcss; + } else { + $customcss = null; + } + $css = theme_more_set_customcss($css, $customcss); + + return $css; +} + +/** + * Adds the logo to CSS. + * + * @param string $css The CSS. + * @param string $logo The URL of the logo. + * @return string The parsed CSS + */ +function theme_more_set_logo($css, $logo) { + $tag = '[[setting:logo]]'; + $replacement = $logo; + if (is_null($replacement)) { + $replacement = ''; + } + + $css = str_replace($tag, $replacement, $css); + + return $css; +} + +/** + * Serves any files associated with the theme settings. + * + * @param stdClass $course + * @param stdClass $cm + * @param context $context + * @param string $filearea + * @param array $args + * @param bool $forcedownload + * @param array $options + * @return bool + */ +function theme_more_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) { + if ($context->contextlevel == CONTEXT_SYSTEM and $filearea === 'logo') { + $theme = theme_config::load('more'); + return $theme->setting_file_serve('logo', $args, $forcedownload, $options); + } else { + send_file_not_found(); + } +} + +/** + * Adds any custom CSS to the CSS before it is cached. + * + * @param string $css The original CSS. + * @param string $customcss The custom CSS to add. + * @return string The CSS which now contains our custom CSS. + */ +function theme_more_set_customcss($css, $customcss) { + $tag = '[[setting:customcss]]'; + $replacement = $customcss; + if (is_null($replacement)) { + $replacement = ''; + } + + $css = str_replace($tag, $replacement, $css); + + return $css; +} diff --git a/theme/more/pix/favicon.ico b/theme/more/pix/favicon.ico new file mode 100644 index 00000000000..eea02482c37 Binary files /dev/null and b/theme/more/pix/favicon.ico differ diff --git a/theme/more/pix/screenshot.jpg b/theme/more/pix/screenshot.jpg new file mode 100644 index 00000000000..e31f69fb051 Binary files /dev/null and b/theme/more/pix/screenshot.jpg differ diff --git a/theme/more/settings.php b/theme/more/settings.php new file mode 100644 index 00000000000..c60ece6e90f --- /dev/null +++ b/theme/more/settings.php @@ -0,0 +1,71 @@ +. + +/** + * Theme More settings. + * + * Each setting that is defined in the parent theme Clean should be + * defined here too, and use the exact same config name. The reason + * is that theme_more does not define any layout files to re-use the + * ones from theme_clean. But as those layout files use the function + * {@link theme_clean_get_html_for_settings} that belong to Clean, + * we have to make sure it works as expected by having the same settings + * in our theme. + * + * @see theme_clean_get_html_for_settings + * @package theme_more + * @copyright 2014 Frédéric Massart + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die; + +if ($ADMIN->fulltree) { + + // Invert Navbar to dark background. + $name = 'theme_more/invert'; + $title = get_string('invert', 'theme_more'); + $description = get_string('invertdesc', 'theme_more'); + $setting = new admin_setting_configcheckbox($name, $title, $description, 0); + $setting->set_updatedcallback('theme_reset_all_caches'); + $settings->add($setting); + + // Logo file setting. + $name = 'theme_more/logo'; + $title = get_string('logo','theme_more'); + $description = get_string('logodesc', 'theme_more'); + $setting = new admin_setting_configstoredfile($name, $title, $description, 'logo'); + $setting->set_updatedcallback('theme_reset_all_caches'); + $settings->add($setting); + + // Custom CSS file. + $name = 'theme_more/customcss'; + $title = get_string('customcss', 'theme_more'); + $description = get_string('customcssdesc', 'theme_more'); + $default = ''; + $setting = new admin_setting_configtextarea($name, $title, $description, $default); + $setting->set_updatedcallback('theme_reset_all_caches'); + $settings->add($setting); + + // Footnote setting. + $name = 'theme_more/footnote'; + $title = get_string('footnote', 'theme_more'); + $description = get_string('footnotedesc', 'theme_more'); + $default = ''; + $setting = new admin_setting_confightmleditor($name, $title, $description, $default); + $setting->set_updatedcallback('theme_reset_all_caches'); + $settings->add($setting); +} diff --git a/theme/more/style/custom.css b/theme/more/style/custom.css new file mode 100644 index 00000000000..81208d60551 --- /dev/null +++ b/theme/more/style/custom.css @@ -0,0 +1,21 @@ +/* Custom CSS +-------------------------*/ +a.logo { + background: url([[setting:logo]]) no-repeat 0 0; + display: block; + float: left; + height: 75px; + margin: 0; + padding: 0; + width: 100%; +} + +.dir-rtl a.logo { + background: url([[setting:logo]]) no-repeat 100% 0; + display: block; + float: right; +} + +/* Custom CSS Settings +-------------------------*/ +[[setting:customcss]] diff --git a/theme/more/version.php b/theme/more/version.php new file mode 100644 index 00000000000..7204646eead --- /dev/null +++ b/theme/more/version.php @@ -0,0 +1,33 @@ +. + +/** + * Theme More version file. + * + * @package theme_more + * @copyright 2014 Frédéric Massart + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die; + +$plugin->version = 2013110500; +$plugin->requires = 2013110500; +$plugin->component = 'theme_more'; +$plugin->dependencies = array( + 'theme_bootstrapbase' => 2013110500, + 'theme_clean' => 2013110500, +);