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 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
32 * Parses CSS before it is cached.
34 * This function can make alterations and replace patterns within the CSS.
36 * @param string $css The CSS
37 * @param theme_config $theme The theme config object.
38 * @return string The parsed CSS The parsed CSS.
40 function theme_clean_process_css($css, $theme) {
43 // Set the background image for the logo.
44 $logo = $OUTPUT->get_logo_url(null, 75);
45 $css = theme_clean_set_logo($css, $logo);
48 if (!empty($theme->settings
->customcss
)) {
49 $customcss = $theme->settings
->customcss
;
53 $css = theme_clean_set_customcss($css, $customcss);
59 * Adds the logo to CSS.
61 * @param string $css The CSS.
62 * @param string $logo The URL of the logo.
63 * @return string The parsed CSS
65 function theme_clean_set_logo($css, $logo) {
66 $tag = '[[setting:logo]]';
68 if (is_null($replacement)) {
72 $css = str_replace($tag, $replacement, $css);
78 * Serves any files associated with the theme settings.
80 * @param stdClass $course
82 * @param context $context
83 * @param string $filearea
85 * @param bool $forcedownload
86 * @param array $options
89 function theme_clean_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
90 if ($context->contextlevel
== CONTEXT_SYSTEM
and ($filearea === 'logo' ||
$filearea === 'smalllogo')) {
91 $theme = theme_config
::load('clean');
92 // By default, theme files must be cache-able by both browsers and proxies.
93 if (!array_key_exists('cacheability', $options)) {
94 $options['cacheability'] = 'public';
96 return $theme->setting_file_serve($filearea, $args, $forcedownload, $options);
98 send_file_not_found();
103 * Adds any custom CSS to the CSS before it is cached.
105 * @param string $css The original CSS.
106 * @param string $customcss The custom CSS to add.
107 * @return string The CSS which now contains our custom CSS.
109 function theme_clean_set_customcss($css, $customcss) {
110 $tag = '[[setting:customcss]]';
111 $replacement = $customcss;
112 if (is_null($replacement)) {
116 $css = str_replace($tag, $replacement, $css);
122 * Returns an object containing HTML for the areas affected by settings.
124 * Do not add Clean specific logic in here, child themes should be able to
125 * rely on that function just by declaring settings with similar names.
127 * @param renderer_base $output Pass in $OUTPUT.
128 * @param moodle_page $page Pass in $PAGE.
129 * @return stdClass An object with the following properties:
130 * - navbarclass A CSS class to use on the navbar. By default ''.
131 * - heading HTML to use for the heading. A logo if one is selected or the default heading.
132 * - footnote HTML to use as a footnote. By default ''.
134 function theme_clean_get_html_for_settings(renderer_base
$output, moodle_page
$page) {
136 $return = new stdClass
;
138 $return->navbarclass
= '';
139 if (!empty($page->theme
->settings
->invert
)) {
140 $return->navbarclass
.= ' navbar-inverse';
143 // Only display the logo on the front page and login page, if one is defined.
144 if (!empty($page->theme
->settings
->logo
) &&
145 ($page->pagelayout
== 'frontpage' ||
$page->pagelayout
== 'login')) {
146 $return->heading
= html_writer
::tag('div', '', array('class' => 'logo'));
148 $return->heading
= $output->page_heading();
151 $return->footnote
= '';
152 if (!empty($page->theme
->settings
->footnote
)) {
153 $return->footnote
= '<div class="footnote text-center">'.format_text($page->theme
->settings
->footnote
).'</div>';
160 * All theme functions should start with theme_clean_
161 * @deprecated since 2.5.1
163 function clean_process_css() {
164 throw new coding_exception('Please call theme_'.__FUNCTION__
.' instead of '.__FUNCTION__
);
168 * All theme functions should start with theme_clean_
169 * @deprecated since 2.5.1
171 function clean_set_logo() {
172 throw new coding_exception('Please call theme_'.__FUNCTION__
.' instead of '.__FUNCTION__
);
176 * All theme functions should start with theme_clean_
177 * @deprecated since 2.5.1
179 function clean_set_customcss() {
180 throw new coding_exception('Please call theme_'.__FUNCTION__
.' instead of '.__FUNCTION__
);