Merge branch 'install_20_STABLE' of git://github.com/amosbot/moodle into MOODLE_20_STABLE
[moodle.git] / theme / nimble / lib.php
blobbcbbda8a5c47a86b413566d74b1e97e8987f1eb3
1 <?php
3 /**
4 * Makes our changes to the CSS
6 * @param string $css
7 * @param theme_config $theme
8 * @return string
9 */
10 function nimble_process_css($css, $theme) {
12 // Set the link color
13 if (!empty($theme->settings->linkcolor)) {
14 $linkcolor = $theme->settings->linkcolor;
15 } else {
16 $linkcolor = null;
18 $css = nimble_set_linkcolor($css, $linkcolor);
20 // Set the link hover color
21 if (!empty($theme->settings->linkhover)) {
22 $linkhover = $theme->settings->linkhover;
23 } else {
24 $linkhover = null;
26 $css = nimble_set_linkhover($css, $linkhover);
29 // Set the background color
30 if (!empty($theme->settings->backgroundcolor)) {
31 $backgroundcolor = $theme->settings->backgroundcolor;
32 } else {
33 $backgroundcolor = null;
35 $css = nimble_set_backgroundcolor($css, $backgroundcolor);
40 // Return the CSS
41 return $css;
44 /**
45 * Sets the link color variable in CSS
48 function nimble_set_linkcolor($css, $linkcolor) {
49 $tag = '[[setting:linkcolor]]';
50 $replacement = $linkcolor;
51 if (is_null($replacement)) {
52 $replacement = '#2a65b1';
54 $css = str_replace($tag, $replacement, $css);
55 return $css;
58 function nimble_set_linkhover($css, $linkhover) {
59 $tag = '[[setting:linkhover]]';
60 $replacement = $linkhover;
61 if (is_null($replacement)) {
62 $replacement = '#222222';
64 $css = str_replace($tag, $replacement, $css);
65 return $css;
69 function nimble_set_backgroundcolor($css, $backgroundcolor) {
70 $tag = '[[setting:backgroundcolor]]';
71 $replacement = $backgroundcolor;
72 if (is_null($replacement)) {
73 $replacement = '#454545';
75 $css = str_replace($tag, $replacement, $css);
76 return $css;