mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
91 lines
2.2 KiB
PHP
91 lines
2.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Makes our changes to the CSS
|
|
*
|
|
* @param string $css
|
|
* @param theme_config $theme
|
|
* @return string
|
|
*/
|
|
function formalwhite_process_css($css, $theme) {
|
|
|
|
// Set the background color
|
|
if (!empty($theme->settings->backgroundcolor)) {
|
|
$backgroundcolor = $theme->settings->backgroundcolor;
|
|
} else {
|
|
$backgroundcolor = null;
|
|
}
|
|
$css = formalwhite_set_backgroundcolor($css, $backgroundcolor);
|
|
|
|
// Set the region width
|
|
if (!empty($theme->settings->regionwidth)) {
|
|
$regionwidth = $theme->settings->regionwidth;
|
|
} else {
|
|
$regionwidth = null;
|
|
}
|
|
$css = formalwhite_set_regionwidth($css, $regionwidth);
|
|
|
|
// Set the custom CSS
|
|
if (!empty($theme->settings->customcss)) {
|
|
$customcss = $theme->settings->customcss;
|
|
} else {
|
|
$customcss = null;
|
|
}
|
|
$css = formalwhite_set_customcss($css, $customcss);
|
|
|
|
// Return the CSS
|
|
return $css;
|
|
}
|
|
|
|
/**
|
|
* Sets the background colour variable in CSS
|
|
*
|
|
* @param string $css
|
|
* @param mixed $backgroundcolor
|
|
* @return string
|
|
*/
|
|
function formalwhite_set_backgroundcolor($css, $backgroundcolor) {
|
|
$tag = '[[setting:backgroundcolor]]';
|
|
$replacement = $backgroundcolor;
|
|
if (is_null($replacement)) {
|
|
$replacement = '#F7F6F1';
|
|
}
|
|
$css = str_replace($tag, $replacement, $css);
|
|
return $css;
|
|
}
|
|
|
|
/**
|
|
* Sets the region width variable in CSS
|
|
*
|
|
* @param string $css
|
|
* @param mixed $regionwidth
|
|
* @return string
|
|
*/
|
|
function formalwhite_set_regionwidth($css, $regionwidth) {
|
|
$tag = '[[setting:regionwidth]]';
|
|
$doubletag = '[[setting:regionwidthdouble]]';
|
|
$replacement = $regionwidth;
|
|
if (is_null($replacement)) {
|
|
$replacement = 200;
|
|
}
|
|
$css = str_replace($tag, $replacement.'px', $css);
|
|
$css = str_replace($doubletag, ($replacement*2).'px', $css);
|
|
return $css;
|
|
}
|
|
|
|
/**
|
|
* Sets the custom css variable in CSS
|
|
*
|
|
* @param string $css
|
|
* @param mixed $customcss
|
|
* @return string
|
|
*/
|
|
function formalwhite_set_customcss($css, $customcss) {
|
|
$tag = '[[setting:customcss]]';
|
|
$replacement = $customcss;
|
|
if (is_null($replacement)) {
|
|
$replacement = '';
|
|
}
|
|
$css = str_replace($tag, $replacement, $css);
|
|
return $css;
|
|
} |