MDL-39552 Make behat code re-entrant safe
[moodle.git] / theme / clean / lib.php
blob3325ca93bf2ceb46c165c9aa2e5bc22707a5f359
1 <?php
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.
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/>.
17 /**
18 * Moodle's Clean theme, an example of how to make a Bootstrap 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_clean
27 * @copyright 2013 Moodle, moodle.org
28 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31 function clean_process_css($css, $theme) {
33 // Set the background image for the logo.
34 $logo = $theme->setting_file_url('logo', 'logo');
35 $css = clean_set_logo($css, $logo);
37 // Set custom CSS.
38 if (!empty($theme->settings->customcss)) {
39 $customcss = $theme->settings->customcss;
40 } else {
41 $customcss = null;
43 $css = clean_set_customcss($css, $customcss);
45 return $css;
48 function clean_set_logo($css, $logo) {
49 global $OUTPUT;
50 $tag = '[[setting:logo]]';
51 $replacement = $logo;
52 if (is_null($replacement)) {
53 $replacement = '';
56 $css = str_replace($tag, $replacement, $css);
58 return $css;
61 function theme_clean_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
62 if ($context->contextlevel == CONTEXT_SYSTEM and $filearea === 'logo') {
63 $theme = theme_config::load('clean');
64 return $theme->setting_file_serve('logo', $args, $forcedownload, $options);
65 } else {
66 send_file_not_found();
70 function clean_set_customcss($css, $customcss) {
71 $tag = '[[setting:customcss]]';
72 $replacement = $customcss;
73 if (is_null($replacement)) {
74 $replacement = '';
77 $css = str_replace($tag, $replacement, $css);
79 return $css;