forked from danmarsden/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.php
123 lines (100 loc) · 2.96 KB
/
lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
function brick_set_linkcolor($css, $linkcolor) {
$tag = '[[setting:linkcolor]]';
$replacement = $linkcolor;
if (is_null($replacement)) {
$replacement = '#06365b';
}
$css = str_replace($tag, $replacement, $css);
return $css;
}
function brick_set_linkhover($css, $linkhover) {
$tag = '[[setting:linkhover]]';
$replacement = $linkhover;
if (is_null($replacement)) {
$replacement = '#5487ad';
}
$css = str_replace($tag, $replacement, $css);
return $css;
}
function brick_set_maincolor($css, $maincolor) {
$tag = '[[setting:maincolor]]';
$replacement = $maincolor;
if (is_null($replacement)) {
$replacement = '#8e2800';
}
$css = str_replace($tag, $replacement, $css);
return $css;
}
function brick_set_maincolorlink($css, $maincolorlink) {
$tag = '[[setting:maincolorlink]]';
$replacement = $maincolorlink;
if (is_null($replacement)) {
$replacement = '#fff0a5';
}
$css = str_replace($tag, $replacement, $css);
return $css;
}
function brick_set_headingcolor($css, $headingcolor) {
$tag = '[[setting:headingcolor]]';
$replacement = $headingcolor;
if (is_null($replacement)) {
$replacement = '#5c3500';
}
$css = str_replace($tag, $replacement, $css);
return $css;
}
function brick_set_logo($css, $logo) {
global $OUTPUT;
$tag = '[[setting:logo]]';
$replacement = $logo;
if (is_null($replacement)) {
$replacement = $OUTPUT->pix_url('logo', 'theme');
}
$css = str_replace($tag, $replacement, $css);
return $css;
}
function brick_process_css($css, $theme) {
if (!empty($theme->settings->linkcolor)) {
$linkcolor = $theme->settings->linkcolor;
} else {
$linkcolor = null;
}
$css = brick_set_linkcolor($css, $linkcolor);
// Set the link hover color
if (!empty($theme->settings->linkhover)) {
$linkhover = $theme->settings->linkhover;
} else {
$linkhover = null;
}
$css = brick_set_linkhover($css, $linkhover);
// Set the main color
if (!empty($theme->settings->maincolor)) {
$maincolor = $theme->settings->maincolor;
} else {
$maincolor = null;
}
$css = brick_set_maincolor($css, $maincolor);
// Set the main accent color
if (!empty($theme->settings->maincolorlink)) {
$maincolorlink = $theme->settings->maincolorlink;
} else {
$maincolorlink = null;
}
$css = brick_set_maincolorlink($css, $maincolorlink);
// Set the main headings color
if (!empty($theme->settings->headingcolor)) {
$headingcolor = $theme->settings->headingcolor;
} else {
$headingcolor = null;
}
$css = brick_set_headingcolor($css, $headingcolor);
// Set the logo image
if (!empty($theme->settings->logo)) {
$logo = $theme->settings->logo;
} else {
$logo = null;
}
$css = brick_set_logo($css, $logo);
return $css;
}