-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlib.php
More file actions
225 lines (207 loc) · 7.86 KB
/
Copy pathlib.php
File metadata and controls
225 lines (207 loc) · 7.86 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Moodle's crisp theme, an example of how to make a Bootstrap theme
*
* DO NOT MODIFY THIS THEME!
* COPY IT FIRST, THEN RENAME THE COPY AND MODIFY IT INSTEAD.
*
* For full information about creating Moodle themes, see:
* http://docs.moodle.org/dev/Themes_2.0
*
* @package theme_crisp
* @copyright 2014 dualcube {@link http://dualcube.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Returns an object containing HTML for the areas affected by settings.
*
* @param renderer_base $output Pass in $OUTPUT.
* @param moodle_page $page Pass in $PAGE.
* @return stdClass An object with the following properties:
* - navbarclass A CSS class to use on the navbar. By default ''.
* - heading HTML to use for the heading. A logo if one is selected or the default heading.
* - footnote HTML to use as a footnote. By default ''.
*/
function theme_crisp_get_html_for_settings(renderer_base $output, moodle_page $page) {
global $CFG;
$return = new stdClass;
$return->navbarclass = '';
if (!empty($page->theme->settings->invert)) {
$return->navbarclass .= ' navbar-inverse';
}
if (!empty($page->theme->settings->logo)) {
$return->heading = html_writer::link($CFG->wwwroot, '', array('title' => get_string('home'), 'class' => 'logo'));
} else {
$return->heading = $output->page_heading();
}
$return->footnote = '';
if (!empty($page->theme->settings->footnote)) {
$return->footnote = '<div class="footnote text-center">'.$page->theme->settings->footnote.'</div>';
}
return $return;
}
function theme_crisp_get_setting($setting, $format = false) {
global $CFG;
require_once($CFG->dirroot . '/lib/weblib.php');
static $theme;
if (empty($theme)) {
$theme = theme_config::load('crisp');
}
if (empty($theme->settings->$setting)) {
return false;
} else if (!$format) {
return $theme->settings->$setting;
} else if ($format === 'format_text') {
return format_text($theme->settings->$setting, FORMAT_PLAIN);
} else if ($format === 'format_html') {
return format_text($theme->settings->$setting, FORMAT_HTML, array('trusted' => true, 'noclean' => true));
} else {
return format_string($theme->settings->$setting);
}
}
/**
* Parses CSS before it is cached.
*
* This function can make alterations and replace patterns within the CSS.
*
* @param string $css The CSS
* @param theme_config $theme The theme config object.
* @return string The parsed CSS The parsed CSS.
*/
function theme_crisp_process_css($css, $theme) {
// Set the background image for the logo.
$logo = $theme->setting_file_url('logo', 'logo');
$css = theme_crisp_set_logo($css, $logo);
// Set custom CSS.
if (!empty($theme->settings->customcss)) {
$customcss = $theme->settings->customcss;
} else {
$customcss = null;
}
$css = theme_crisp_set_customcss($css, $customcss);
$thememaincolor = theme_crisp_get_setting('maincolor');
$css = theme_crisp_set_maincolor($css, $thememaincolor);
return $css;
}
/**
* Adds any custom color to the CSS before it is cached.
*
* @param string $css The original CSS.
* @param string $themecolor The custom CSS to add.
* @return string The CSS which now contains our custom CSS.
*/
function theme_crisp_set_maincolor($css, $themecolor) {
$tag = '[[setting:maincolor]]';
$replacement = $themecolor;
if (is_null($replacement)) {
$replacement = '#088a4a';
}
$css = str_replace($tag, $replacement, $css);
return $css;
}
/**
* Adds the logo to CSS.
*
* @param string $css The CSS.
* @param string $logo The URL of the logo.
* @return string The parsed CSS
*/
function theme_crisp_set_logo($css, $logo) {
$tag = '[[setting:logo]]';
$replacement = $logo;
if (is_null($replacement)) {
$replacement = '';
}
$css = str_replace($tag, $replacement, $css);
return $css;
}
function theme_crisp_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
static $theme;
if (empty($theme)) {
$theme = theme_config::load('crisp');
}
if ($context->contextlevel == CONTEXT_SYSTEM) {
if ($filearea === 'logo') {
return $theme->setting_file_serve('logo', $args, $forcedownload, $options);
} else if ($filearea === 'slidepic1') {
return $theme->setting_file_serve('slidepic1', $args, $forcedownload, $options);
} else if ($filearea === 'slidepic2') {
return $theme->setting_file_serve('slidepic2', $args, $forcedownload, $options);
} else if ($filearea === 'slidepic3') {
return $theme->setting_file_serve('slidepic3', $args, $forcedownload, $options);
} else if ($filearea === 'slidepic4') {
return $theme->setting_file_serve('slidepic4', $args, $forcedownload, $options);
} else if ($filearea === 'slidepic5') {
return $theme->setting_file_serve('slidepic5', $args, $forcedownload, $options);
} else if ($filearea === 'slidepic6') {
return $theme->setting_file_serve('slidepic6', $args, $forcedownload, $options);
} else if ($filearea === 'picture1') {
return $theme->setting_file_serve('picture1', $args, $forcedownload, $options);
} else if ($filearea === 'favicon') {
return $theme->setting_file_serve('favicon', $args, $forcedownload, $options);
} else if ($filearea === 'pic1') {
return $theme->setting_file_serve('pic1', $args, $forcedownload, $options);
} else if ($filearea === 'pic2') {
return $theme->setting_file_serve('pic2', $args, $forcedownload, $options);
} else if ($filearea === 'pic3') {
return $theme->setting_file_serve('pic3', $args, $forcedownload, $options);
} else if ($filearea === 'img1') {
return $theme->setting_file_serve('img1', $args, $forcedownload, $options);
} else {
send_file_not_found();
}
} else {
send_file_not_found();
}
}
/**
* Adds any custom CSS to the CSS before it is cached.
*
* @param string $css The original CSS.
* @param string $customcss The custom CSS to add.
* @return string The CSS which now contains our custom CSS.
*/
function theme_crisp_set_customcss($css, $customcss) {
$tag = '[[setting:customcss]]';
$replacement = $customcss;
if (is_null($replacement)) {
$replacement = '';
}
$css = str_replace($tag, $replacement, $css);
return $css;
}
/**
* All theme functions should start with theme_crisp_
* @deprecated since 2.5.1
*/
function crisp_process_css() {
throw new coding_exception('Please call theme_'.__FUNCTION__.' instead of '.__FUNCTION__);
}
/**
* All theme functions should start with theme_crisp_
* @deprecated since 2.5.1
*/
function crisp_set_logo() {
throw new coding_exception('Please call theme_'.__FUNCTION__.' instead of '.__FUNCTION__);
}
/**
* All theme functions should start with theme_crisp_
* @deprecated since 2.5.1
*/
function crisp_set_customcss() {
throw new coding_exception('Please call theme_'.__FUNCTION__.' instead of '.__FUNCTION__);
}