2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * Moodle's formal_white theme
20 * DO NOT MODIFY THIS THEME!
21 * COPY IT FIRST, THEN RENAME THE COPY AND MODIFY IT INSTEAD.
23 * For full information about creating Moodle themes, see:
24 * http://docs.moodle.org/dev/Themes_2.0
26 * @package theme_formal_white
27 * @copyright 2013 Mediatouch 2000, mediatouch.it
28 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31 defined('MOODLE_INTERNAL') ||
die();
34 * Makes our changes to the CSS
37 * @param theme_config $theme
40 function formal_white_user_settings($css, $theme) {
42 // Set the font reference size
43 if (empty($theme->settings
->fontsizereference
)) {
44 $fontsizereference = '13'; // default
46 $fontsizereference = $theme->settings
->fontsizereference
;
48 $css = formal_white_set_fontsizereference($css, $fontsizereference);
50 // Set the frame margin
51 if (!isset($theme->settings
->framemargin
)) {
52 $framemargin = 15; // default
54 $framemargin = $theme->settings
->framemargin
;
56 $css = formal_white_set_framemargin($css, $framemargin);
58 // Set the images according to color trend
59 if (!isset($theme->settings
->trendcolor
)) {
60 $trendcolor = 'mink'; // default
62 $trendcolor = $theme->settings
->trendcolor
;
64 $css = formal_white_set_trendcolor($css, $trendcolor);
66 // Set the page header background color
67 if (empty($theme->settings
->headerbgc
)) {
68 $headerbgc = '#E3DFD4'; // default
70 $headerbgc = $theme->settings
->headerbgc
;
72 $css = formal_white_set_headerbgc($css, $headerbgc);
74 // Set the block content background color
75 if (empty($theme->settings
->blockcontentbgc
)) {
76 $blockcontentbgc = '#F6F6F6'; // default
78 $blockcontentbgc = $theme->settings
->blockcontentbgc
;
80 $css = formal_white_set_blockcontentbgc($css, $blockcontentbgc);
82 // Set the left block column background color
83 if (empty($theme->settings
->lblockcolumnbgc
)) {
84 $lblockcolumnbgc = '#E3DFD4'; // default
86 $lblockcolumnbgc = $theme->settings
->lblockcolumnbgc
;
88 $css = formal_white_set_lblockcolumnbgc($css, $lblockcolumnbgc);
90 // Set the right block column background color
91 if (empty($theme->settings
->rblockcolumnbgc
)) {
92 $rblockcolumnbgc = $lblockcolumnbgc; // default
94 $rblockcolumnbgc = $theme->settings
->rblockcolumnbgc
;
96 $css = formal_white_set_rblockcolumnbgc($css, $rblockcolumnbgc);
98 // set the width of the two blocks columns
99 if (!empty($theme->settings
->blockcolumnwidth
)) {
100 $blockcolumnwidth = $theme->settings
->blockcolumnwidth
;
102 $blockcolumnwidth = '200'; // default
104 $css = formal_white_set_blockcolumnwidth($css, $blockcolumnwidth);
107 if (!empty($theme->settings
->blockpadding
)) {
108 $blockpadding = $theme->settings
->blockpadding
;
110 $blockpadding = '8'; // default
112 $css = formal_white_set_blockpadding($css, $blockcolumnwidth, $blockpadding);
115 if (!empty($theme->settings
->customcss
)) {
116 $customcss = $theme->settings
->customcss
;
120 $css = formal_white_set_customcss($css, $customcss);
126 * Sets the link color variable in CSS
129 function formal_white_set_fontsizereference($css, $fontsizereference) {
130 $tag = '[[setting:fontsizereference]]';
131 $css = str_replace($tag, $fontsizereference.'px', $css);
135 function formal_white_set_framemargin($css, $framemargin) {
136 $tag = '[[setting:framemargin]]';
137 $css = str_replace($tag, $framemargin.'px', $css);
139 // Set .headermenu margin
140 $calculated = $framemargin +
22; // 17px is the width of the frame; 5px to avoid to have all stuck
141 $tag = '[[calculated:headermenumargin]]';
142 $css = str_replace($tag, $calculated.'px', $css);
147 function formal_white_set_trendcolor($css, $trendcolor) {
148 // __setting_trendcolor__ is part of URLS so it is already between double square bracket.
149 // I can not enclose it between double square bracket once again otherwise images path parser get confused.
150 $tag = urlencode('__setting_trendcolor__'); // urlencode is useless but it is correct to put it here
151 $css = str_replace($tag, $trendcolor, $css);
153 // of the basis of the general choosed trend, I need some colour definition.
154 switch ($trendcolor) {
156 // .courses .coursebox
157 $tag = '[[setting:hovercolor]]';
158 $css = str_replace($tag, '#CEE5FD', $css);
161 $tag = '[[setting:pagebackground]]';
162 $css = str_replace($tag, '#DAF1FF', $css);
164 // block header background
165 $tag = '[[setting:blockheaderbackground]]';
166 $css = str_replace($tag, '#CDE2F3', $css);
169 // .courses .coursebox
170 $tag = '[[setting:hovercolor]]';
171 $css = str_replace($tag, '#FFEA68', $css);
174 $tag = '[[setting:pagebackground]]';
175 $css = str_replace($tag, '#FFEB9A', $css);
177 // block header background
178 $tag = '[[setting:blockheaderbackground]]';
179 $css = str_replace($tag, '#F7DA41', $css);
182 // .courses .coursebox
183 $tag = '[[setting:hovercolor]]';
184 $css = str_replace($tag, '#EBEDB1', $css);
187 $tag = '[[setting:pagebackground]]';
188 $css = str_replace($tag, '#F0F5BB', $css);
190 // block header background
191 $tag = '[[setting:blockheaderbackground]]';
192 $css = str_replace($tag, '#E2E499', $css);
195 // .courses .coursebox
196 $tag = '[[setting:hovercolor]]';
197 $css = str_replace($tag, '#E3DFD4', $css);
200 $tag = '[[setting:pagebackground]]';
201 $css = str_replace($tag, '#EFEFEF', $css);
203 // block header background
204 $tag = '[[setting:blockheaderbackground]]';
205 $css = str_replace($tag, '#E3DFD4', $css);
208 // .courses .coursebox
209 $tag = '[[setting:hovercolor]]';
210 $css = str_replace($tag, '#FFCF88', $css);
213 $tag = '[[setting:pagebackground]]';
214 $css = str_replace($tag, '#FFD46C', $css);
216 // block header background
217 $tag = '[[setting:blockheaderbackground]]';
218 $css = str_replace($tag, '#FDC06D', $css);
221 // .courses .coursebox
222 $tag = '[[setting:hovercolor]]';
223 $css = str_replace($tag, '#FFCEB8', $css);
226 $tag = '[[setting:pagebackground]]';
227 $css = str_replace($tag, '#FCD3BC', $css);
229 // block header background
230 $tag = '[[setting:blockheaderbackground]]';
231 $css = str_replace($tag, '#F7C099', $css);
234 // .courses .coursebox
235 $tag = '[[setting:hovercolor]]';
236 $css = str_replace($tag, '#E0DFDD', $css);
239 $tag = '[[setting:pagebackground]]';
240 $css = str_replace($tag, '#EFF0F2', $css);
242 // block header background
243 $tag = '[[setting:blockheaderbackground]]';
244 $css = str_replace($tag, '#E0DFDD', $css);
247 debugging('It seems a colour has been added to the formal_white trend colours folder but was not fully managed. The code must be updated by a developer.');
252 function formal_white_set_headerbgc($css, $headerbgc) {
253 $tag = '[[setting:headerbgc]]';
254 $css = str_replace($tag, $headerbgc, $css);
258 function formal_white_set_blockcontentbgc($css, $blockcontentbgc) {
259 $tag = '[[setting:blockcontentbgc]]';
260 $css = str_replace($tag, $blockcontentbgc, $css);
264 function formal_white_set_lblockcolumnbgc($css, $lblockcolumnbgc) {
265 $tag = '[[setting:lblockcolumnbgc]]';
266 $css = str_replace($tag, $lblockcolumnbgc, $css);
270 function formal_white_set_rblockcolumnbgc($css, $rblockcolumnbgc) {
271 $tag = '[[setting:rblockcolumnbgc]]';
272 $css = str_replace($tag, $rblockcolumnbgc, $css);
276 function formal_white_set_blockcolumnwidth($css, $blockcolumnwidth) {
277 $tag = '[[setting:blockcolumnwidth]]';
278 $css = str_replace($tag, $blockcolumnwidth.'px', $css);
280 $calculated = -2*$blockcolumnwidth;
281 $tag = '[[calculated:minusdoubleblockcolumnwidth]]';
282 $css = str_replace($tag, $calculated.'px', $css);
284 $calculated = 2*$blockcolumnwidth;
285 $tag = '[[calculated:doubleblockcolumnwidth]]';
286 $css = str_replace($tag, $calculated.'px', $css);
288 // set the min-width of the page to provide: content region min-width = block region width
289 // I do not care $framemargin because the min-width applies to #frametop that is free from $framemargin
290 // I need to add twice the width of the frame because it is inside #frametop
291 // (this code here because it HAS TO come later than $blockcolumnwidth definition)
292 $calculated = 3*$blockcolumnwidth +
34; // 34 = 2*17 (17px is the width of the frame)
293 $tag = '[[calculated:minwidth]]';
294 $css = str_replace($tag, $calculated.'px', $css);
299 function formal_white_set_blockpadding($css, $blockcolumnwidth, $blockpadding) {
300 $tag = '[[setting:blockpadding]]';
301 $css = str_replace($tag, $blockpadding.'px', $css);
303 // I need to know the field width in pixel because width:100%; and width:auto; don't work as expected
304 // once $blockcolumnwidth and $blockpadding are known, $lb_fieldswidth can be applied
305 // the process has not been optimized at all but it is executed only once
306 $lb_fieldswidth = $blockcolumnwidth;
308 // #page-content .region-content {padding:[[setting:blockpadding]] [[setting:blockpadding]] 0 [[setting:blockpadding]];} in pagelayout.css
309 $lb_fieldswidth -= 2*$blockpadding;
311 // .block {border:[[static:lb_blockborderwidth]] solid #C6BDA8; [...] }
312 $lb_fieldsborderwidth = 1;
313 $tag = '[[static:lb_blockborderwidth]]'; // It is static, it is not a setting. I just hardcoded its definition here.
314 $css = str_replace($tag, $lb_fieldsborderwidth.'px', $css);
315 $lb_fieldswidth -= 2*$lb_fieldsborderwidth;
317 // .block_login .content {padding:[[static:lb_contentpadding]];}
318 $lb_fieldspadding = 4;
319 $tag = '[[static:lb_contentpadding]]'; // It is static, it is not a setting. I just hardcoded its definition here.
320 $css = str_replace($tag, $lb_fieldspadding.'px', $css);
321 $lb_fieldswidth -= 2*$lb_fieldspadding;
323 // .block_login #login_username, .block_login #login_password {margin:4px 0 4px [[static:lb_fieldsmargin]];}
324 $lb_fieldsmargin = 14;
325 $tag = '[[static:lb_fieldsmargin]]'; // It is static, it is not a setting. I just hardcoded its definition here.
326 $css = str_replace($tag, $lb_fieldsmargin.'px', $css);
327 $lb_fieldswidth -= $lb_fieldsmargin; // without 2* because it is only left margin
329 // fields default factory border: 3px
330 $lb_fieldswidth -= 2*3;
332 // leave few pixel on the right reducing once again the field length
333 $lb_fieldswidth -= 12;
335 $tag = '[[static:lb_fieldswidth]]';
336 $css = str_replace($tag, $lb_fieldswidth.'px', $css);
340 function formal_white_set_customcss($css, $customcss) {
341 $tag = '[[setting:customcss]]';
342 $css = str_replace($tag, $customcss, $css);
347 * Serves formal white files.
349 * @param stdClass $course
350 * @param stdClass $cm
351 * @param context $context
352 * @param string $filearea
354 * @param array $forcedownload
355 * @param array $options
358 function theme_formal_white_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
359 if ($context->contextlevel
== CONTEXT_SYSTEM
and $filearea === 'customlogourl') {
360 $theme = theme_config
::load('formal_white');
361 return $theme->setting_file_serve('customlogourl', $args, $forcedownload, $options);
362 } else if ($context->contextlevel
== CONTEXT_SYSTEM
and $filearea === 'frontpagelogourl') {
363 $theme = theme_config
::load('formal_white');
364 return $theme->setting_file_serve('frontpagelogourl', $args, $forcedownload, $options);
366 send_file_not_found();