/theme/formal_white/lib.php
PHP | 92 lines | 52 code | 8 blank | 32 comment | 9 complexity | 2ada744b8fd0bee8b17138fa6c14fa6b MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1, BSD-3-Clause
- <?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);
- $css = str_replace($tag, ($replacement+10).'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;
- }