MDL-44207 theme_nimble: fix incorrect tab.
[moodle.git] / theme / nimble / lib.php
CommitLineData
ee3b46d8 1<?php
6a0bb481
SH
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * This file contains functions specific to the needs of the Nimble theme.
19 *
20 * @package theme_nimble
21 * @copyright 2010 Patrick Malley
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
ee3b46d8 24
25/**
26 * Makes our changes to the CSS
27 *
28 * @param string $css
29 * @param theme_config $theme
30 * @return string
31 */
32function nimble_process_css($css, $theme) {
33
6a0bb481 34 // Set the link color.
ee3b46d8 35 if (!empty($theme->settings->linkcolor)) {
36 $linkcolor = $theme->settings->linkcolor;
37 } else {
38 $linkcolor = null;
39 }
40 $css = nimble_set_linkcolor($css, $linkcolor);
41
bf9c946e 42 // Set the link hover color.
ee3b46d8 43 if (!empty($theme->settings->linkhover)) {
44 $linkhover = $theme->settings->linkhover;
45 } else {
46 $linkhover = null;
47 }
48 $css = nimble_set_linkhover($css, $linkhover);
6a0bb481
SH
49
50 // Set the background color.
ee3b46d8 51 if (!empty($theme->settings->backgroundcolor)) {
52 $backgroundcolor = $theme->settings->backgroundcolor;
53 } else {
54 $backgroundcolor = null;
55 }
56 $css = nimble_set_backgroundcolor($css, $backgroundcolor);
ee3b46d8 57
6a0bb481 58 // Return the CSS.
ee3b46d8 59 return $css;
60}
61
62/**
63 * Sets the link color variable in CSS
64 *
6a0bb481
SH
65 * @param string $css
66 * @param string $linkcolor
67 * @return string
ee3b46d8 68 */
69function nimble_set_linkcolor($css, $linkcolor) {
70 $tag = '[[setting:linkcolor]]';
71 $replacement = $linkcolor;
72 if (is_null($replacement)) {
73 $replacement = '#2a65b1';
74 }
75 $css = str_replace($tag, $replacement, $css);
76 return $css;
77}
78
6a0bb481
SH
79/**
80 * Sets the link hover colour in CSS.
81 *
82 * @param string $css
83 * @param string $linkhover
84 * @return string
85 */
ee3b46d8 86function nimble_set_linkhover($css, $linkhover) {
87 $tag = '[[setting:linkhover]]';
88 $replacement = $linkhover;
89 if (is_null($replacement)) {
90 $replacement = '#222222';
91 }
92 $css = str_replace($tag, $replacement, $css);
93 return $css;
94}
95
6a0bb481
SH
96/**
97 * Sets the background colour in CSS.
98 * @param string $css
99 * @param string $backgroundcolor
100 * @return string
101 */
ee3b46d8 102function nimble_set_backgroundcolor($css, $backgroundcolor) {
103 $tag = '[[setting:backgroundcolor]]';
104 $replacement = $backgroundcolor;
105 if (is_null($replacement)) {
106 $replacement = '#454545';
107 }
108 $css = str_replace($tag, $replacement, $css);
109 return $css;
bf9c946e 110}