MDL-26047 - added new theme called Nimble
[moodle.git] / theme / nimble / lib.php
CommitLineData
ee3b46d8 1<?php
2
3/**
4 * Makes our changes to the CSS
5 *
6 * @param string $css
7 * @param theme_config $theme
8 * @return string
9 */
10function nimble_process_css($css, $theme) {
11
12 // Set the link color
13 if (!empty($theme->settings->linkcolor)) {
14 $linkcolor = $theme->settings->linkcolor;
15 } else {
16 $linkcolor = null;
17 }
18 $css = nimble_set_linkcolor($css, $linkcolor);
19
20 // Set the link hover color
21 if (!empty($theme->settings->linkhover)) {
22 $linkhover = $theme->settings->linkhover;
23 } else {
24 $linkhover = null;
25 }
26 $css = nimble_set_linkhover($css, $linkhover);
27
28
29 // Set the background color
30 if (!empty($theme->settings->backgroundcolor)) {
31 $backgroundcolor = $theme->settings->backgroundcolor;
32 } else {
33 $backgroundcolor = null;
34 }
35 $css = nimble_set_backgroundcolor($css, $backgroundcolor);
36
37
38
39
40 // Return the CSS
41 return $css;
42}
43
44/**
45 * Sets the link color variable in CSS
46 *
47 */
48function nimble_set_linkcolor($css, $linkcolor) {
49 $tag = '[[setting:linkcolor]]';
50 $replacement = $linkcolor;
51 if (is_null($replacement)) {
52 $replacement = '#2a65b1';
53 }
54 $css = str_replace($tag, $replacement, $css);
55 return $css;
56}
57
58function nimble_set_linkhover($css, $linkhover) {
59 $tag = '[[setting:linkhover]]';
60 $replacement = $linkhover;
61 if (is_null($replacement)) {
62 $replacement = '#222222';
63 }
64 $css = str_replace($tag, $replacement, $css);
65 return $css;
66}
67
68
69function nimble_set_backgroundcolor($css, $backgroundcolor) {
70 $tag = '[[setting:backgroundcolor]]';
71 $replacement = $backgroundcolor;
72 if (is_null($replacement)) {
73 $replacement = '#454545';
74 }
75 $css = str_replace($tag, $replacement, $css);
76 return $css;
77}
78