mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 18:36:42 +02:00
MDL-44357 theme_more: New customizable theme
AMOS BEGIN CPY [choosereadme,theme_clean],[choosereadme,theme_more] CPY [configtitle,theme_clean],[configtitle,theme_more] CPY [customcss,theme_clean],[customcss,theme_more] CPY [customcssdesc,theme_clean],[customcssdesc,theme_more] CPY [footnote,theme_clean],[footnote,theme_more] CPY [footnotedesc,theme_clean],[footnotedesc,theme_more] CPY [invert,theme_clean],[invert,theme_more] CPY [invertdesc,theme_clean],[invertdesc,theme_more] CPY [logo,theme_clean],[logo,theme_more] CPY [logodesc,theme_clean],[logodesc,theme_more] CPY [pluginname,theme_clean],[pluginname,theme_more] CPY [region-side-post,theme_clean],[region-side-post,theme_more] CPY [region-side-pre,theme_clean],[region-side-pre,theme_more] AMOS END
This commit is contained in:
parent
08823e5f03
commit
833511a005
12 changed files with 328 additions and 4 deletions
108
theme/more/lib.php
Normal file
108
theme/more/lib.php
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?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 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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue