forked from open-lms-open-source/moodle-theme_snap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.php
440 lines (376 loc) · 19.1 KB
/
settings.php
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
<?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/>.
/**
* Snap settings.
*
* @package theme_snap
* @copyright Copyright (c) 2015 Moodlerooms Inc. (http://www.moodlerooms.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
use theme_snap\admin_setting_configurl;
use theme_snap\admin_setting_configcourseid;
use theme_snap\admin_setting_configradiobuttons;
$ADMIN->add('themes', new admin_category('theme_snap', 'Snap'));
$settings = null; // Unsets the default $settings object initialised by Moodle.
// Basic settings.
$snapsettings = new admin_settingpage('themesettingsnap', 'Snap');
// Feature spots settings.
$fssettings = new admin_settingpage('themesnapfeaturespots', get_string('featurespots', 'theme_snap'));
// Featured courses settings.
$fcsettings = new admin_settingpage('themesnapfeaturedcourses', get_string('featuredcourses', 'theme_snap'));
// Feature spots settings.
$resourcesettings = new admin_settingpage('themesnapresourcedisplay', get_string('resourcedisplay', 'theme_snap'));
if ($ADMIN->fulltree) {
$checked = '1';
$unchecked = '0';
// Output flex page front page warning if necessary.
$fpwarning = \theme_snap\output\shared::flexpage_frontpage_warning();
if (!empty($fpwarning)) {
$setting = new admin_setting_heading('flexpage_warning', '', $fpwarning);
$snapsettings->add($setting);
}
$name = 'theme_snap/brandingheading';
$title = new lang_string('brandingheading', 'theme_snap');
$description = new lang_string('brandingheadingdesc', 'theme_snap');
$setting = new admin_setting_heading($name, $title, $description);
$snapsettings->add($setting);
if (!during_initial_install() && !empty(get_site()->fullname)) {
// Site name setting.
$name = 'fullname';
$title = new lang_string('fullname', 'theme_snap');
$description = new lang_string('fullnamedesc', 'theme_snap');
$setting = new admin_setting_sitesettext($name, $title, $description, null);
$snapsettings->add($setting);
}
// Site description setting.
$name = 'theme_snap/subtitle';
$title = new lang_string('subtitle', 'theme_snap');
$description = new lang_string('subtitle_desc', 'theme_snap');
$setting = new admin_setting_configtextarea($name, $title, $description, '');
$snapsettings->add($setting);
// Main theme colour setting.
$name = 'theme_snap/themecolor';
$title = new lang_string('themecolor', 'theme_snap');
$description = new lang_string('themecolordesc', 'theme_snap');
$default = '#3bcedb';
$previewconfig = null;
$setting = new admin_setting_configcolourpicker($name, $title, $description, $default, $previewconfig);
$setting->set_updatedcallback('theme_reset_all_caches');
$snapsettings->add($setting);
// Logo file setting.
$name = 'theme_snap/logo';
$title = new lang_string('logo', 'theme_snap');
$description = new lang_string('logodesc', 'theme_snap');
$opts = array('accepted_types' => array('.png', '.jpg', '.gif', '.webp', '.tiff', '.svg'));
$setting = new admin_setting_configstoredfile($name, $title, $description, 'logo', 0, $opts);
$setting->set_updatedcallback('theme_reset_all_caches');
$snapsettings->add($setting);
// Favicon file setting.
$name = 'theme_snap/favicon';
$title = new lang_string('favicon', 'theme_snap');
$description = new lang_string('favicondesc', 'theme_snap');
$opts = array('accepted_types' => array('.ico'));
$setting = new admin_setting_configstoredfile($name, $title, $description, 'favicon', 0, $opts);
$setting->set_updatedcallback('theme_reset_all_caches');
$snapsettings->add($setting);
// Cover image file setting.
$name = 'theme_snap/poster';
$title = new lang_string('poster', 'theme_snap');
$description = new lang_string('posterdesc', 'theme_snap');
$opts = array('accepted_types' => array('.png', '.jpg', '.gif', '.webp', '.tiff', '.svg'));
$setting = new admin_setting_configstoredfile($name, $title, $description, 'poster', 0, $opts);
$setting->set_updatedcallback('theme_snap_process_site_coverimage');
$snapsettings->add($setting);
// Personal menu settings.
$name = 'theme_snap/personalmenu';
$title = new lang_string('personalmenu', 'theme_snap');
$description = new lang_string('footerheadingdesc', 'theme_snap');
$setting = new admin_setting_heading($name, $title, $description);
$snapsettings->add($setting);
// Personal menu display on login on/off.
$name = 'theme_snap/personalmenulogintoggle';
$title = new lang_string('personalmenulogintoggle', 'theme_snap');
$description = new lang_string('personalmenulogintoggledesc', 'theme_snap');
$default = $checked;
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, $checked, $unchecked);
$snapsettings->add($setting);
// Personal menu deadlines on/off.
$name = 'theme_snap/deadlinestoggle';
$title = new lang_string('deadlinestoggle', 'theme_snap');
$description = new lang_string('deadlinestoggledesc', 'theme_snap');
$default = $checked;
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, $checked, $unchecked);
$setting->set_updatedcallback('theme_reset_all_caches');
$snapsettings->add($setting);
// Personal menu recent feedback & grading on/off.
$name = 'theme_snap/feedbacktoggle';
$title = new lang_string('feedbacktoggle', 'theme_snap');
$description = new lang_string('feedbacktoggledesc', 'theme_snap');
$default = $checked;
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, $checked, $unchecked);
$setting->set_updatedcallback('theme_reset_all_caches');
$snapsettings->add($setting);
// Personal menu messages on/off.
$name = 'theme_snap/messagestoggle';
$title = new lang_string('messagestoggle', 'theme_snap');
$description = new lang_string('messagestoggledesc', 'theme_snap');
$default = $checked;
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, $checked, $unchecked);
$setting->set_updatedcallback('theme_reset_all_caches');
$snapsettings->add($setting);
// Personal menu forum posts on/off.
$name = 'theme_snap/forumpoststoggle';
$title = new lang_string('forumpoststoggle', 'theme_snap');
$description = new lang_string('forumpoststoggledesc', 'theme_snap');
$default = $checked;
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, $checked, $unchecked);
$setting->set_updatedcallback('theme_reset_all_caches');
$snapsettings->add($setting);
// Personal menu show course grade in cards.
$name = 'theme_snap/showcoursegradepersonalmenu';
$title = new lang_string('showcoursegradepersonalmenu', 'theme_snap');
$description = new lang_string('showcoursegradepersonalmenudesc', 'theme_snap');
$default = $checked; // For new installations (legacy is unchecked via upgrade.php).
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, $checked, $unchecked);
$snapsettings->add($setting);
$name = 'theme_snap/footerheading';
$title = new lang_string('footerheading', 'theme_snap');
$description = new lang_string('footerheadingdesc', 'theme_snap');
$setting = new admin_setting_heading($name, $title, $description);
$snapsettings->add($setting);
// Hide navigation block.
$name = 'theme_snap/hidenavblock';
$title = new lang_string('hidenavblock', 'theme_snap');
$description = new lang_string('hidenavblockdesc', 'theme_snap');
$default = $checked;
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, $checked, $unchecked);
$snapsettings->add($setting);
// Course footer on/off.
$name = 'theme_snap/coursefootertoggle';
$title = new lang_string('coursefootertoggle', 'theme_snap');
$description = new lang_string('coursefootertoggledesc', 'theme_snap');
$default = $checked;
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, $checked, $unchecked);
$setting->set_updatedcallback('theme_reset_all_caches');
$snapsettings->add($setting);
// Custom footer setting.
$name = 'theme_snap/footnote';
$title = new lang_string('footnote', 'theme_snap');
$description = new lang_string('footnotedesc', 'theme_snap');
$default = '';
$setting = new admin_setting_confightmleditor($name, $title, $description, $default);
$setting->set_updatedcallback('theme_reset_all_caches');
$snapsettings->add($setting);
// Social media.
$name = 'theme_snap/facebook';
$title = new lang_string('facebook', 'theme_snap');
$description = new lang_string('facebookdesc', 'theme_snap');
$default = '';
$setting = new admin_setting_configurl($name, $title, $description, $default);
$snapsettings->add($setting);
$name = 'theme_snap/twitter';
$title = new lang_string('twitter', 'theme_snap');
$description = new lang_string('twitterdesc', 'theme_snap');
$default = '';
$setting = new admin_setting_configurl($name, $title, $description, $default);
$snapsettings->add($setting);
$name = 'theme_snap/youtube';
$title = new lang_string('youtube', 'theme_snap');
$description = new lang_string('youtubedesc', 'theme_snap');
$default = '';
$setting = new admin_setting_configurl($name, $title, $description, $default);
$snapsettings->add($setting);
$name = 'theme_snap/instagram';
$title = new lang_string('instagram', 'theme_snap');
$description = new lang_string('instagramdesc', 'theme_snap');
$default = '';
$setting = new admin_setting_configurl($name, $title, $description, $default);
$snapsettings->add($setting);
// Advanced branding heading.
$name = 'theme_snap/advancedbrandingheading';
$title = new lang_string('advancedbrandingheading', 'theme_snap');
$description = new lang_string('advancedbrandingheadingdesc', 'theme_snap');
$setting = new admin_setting_heading($name, $title, $description);
$snapsettings->add($setting);
// Heading font setting.
$name = 'theme_snap/headingfont';
$title = new lang_string('headingfont', 'theme_snap');
$description = new lang_string('headingfont_desc', 'theme_snap');
$default = '"Roboto"';
$setting = new admin_setting_configtext($name, $title, $description, $default);
$setting->set_updatedcallback('theme_reset_all_caches');
$snapsettings->add($setting);
// Serif font setting.
$name = 'theme_snap/seriffont';
$title = new lang_string('seriffont', 'theme_snap');
$description = new lang_string('seriffont_desc', 'theme_snap');
$default = '"Georgia"';
$setting = new admin_setting_configtext($name, $title, $description, $default);
$setting->set_updatedcallback('theme_reset_all_caches');
$snapsettings->add($setting);
// Left toc option.
$name = 'theme_snap/leftnav';
$title = new lang_string('leftnav', 'theme_snap');
$description = new lang_string('leftnavdesc', 'theme_snap');
$default = $unchecked;
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, $checked, $unchecked);
$snapsettings->add($setting);
// Custom CSS file.
$name = 'theme_snap/customcss';
$title = new lang_string('customcss', 'theme_snap');
$description = new lang_string('customcssdesc', 'theme_snap');
$default = '';
$setting = new admin_setting_configtextarea($name, $title, $description, $default);
$setting->set_updatedcallback('theme_reset_all_caches');
$snapsettings->add($setting);
// Feature spots settings.
// Feature spot instructions.
$name = 'theme_snap/fs_instructions';
$heading = '';
$description = get_string('featurespotshelp', 'theme_snap');
$setting = new admin_setting_heading($name, $heading, $description);
$fssettings->add($setting);
// Feature spots heading.
$name = 'theme_snap/fs_heading';
$title = new lang_string('featurespotsheading', 'theme_snap');
$description = '';
$default = '';
$setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_RAW, 50);
$fssettings->add($setting);
// Feature spot images.
$name = 'theme_snap/fs_one_image';
$title = new lang_string('featureoneimage', 'theme_snap');
$opts = array('accepted_types' => array('.png', '.jpg', '.gif', '.webp', '.svg'));
$setting = new admin_setting_configstoredfile($name, $title, $description, 'fs_one_image', 0, $opts);
$fssettings->add($setting);
$name = 'theme_snap/fs_two_image';
$title = new lang_string('featuretwoimage', 'theme_snap');
$opts = array('accepted_types' => array('.png', '.jpg', '.gif', '.webp', '.svg'));
$setting = new admin_setting_configstoredfile($name, $title, $description, 'fs_two_image', 0, $opts);
$fssettings->add($setting);
$name = 'theme_snap/fs_three_image';
$title = new lang_string('featurethreeimage', 'theme_snap');
$opts = array('accepted_types' => array('.png', '.jpg', '.gif', '.webp', '.svg'));
$setting = new admin_setting_configstoredfile($name, $title, $description, 'fs_three_image', 0, $opts);
$fssettings->add($setting);
// Feature spot titles.
$name = 'theme_snap/fs_one_title';
$title = new lang_string('featureonetitle', 'theme_snap');
$description = '';
$default = '';
$setting = new admin_setting_configtext($name, $title, $description, $default);
$fssettings->add($setting);
$name = 'theme_snap/fs_two_title';
$title = new lang_string('featuretwotitle', 'theme_snap');
$setting = new admin_setting_configtext($name, $title, $description, $default);
$fssettings->add($setting);
$name = 'theme_snap/fs_three_title';
$title = new lang_string('featurethreetitle', 'theme_snap');
$setting = new admin_setting_configtext($name, $title, $description, $default);
$fssettings->add($setting);
// Feature spot text.
$name = 'theme_snap/fs_one_text';
$title = new lang_string('featureonetext', 'theme_snap');
$setting = new admin_setting_configtextarea($name, $title, $description, $default);
$fssettings->add($setting);
$name = 'theme_snap/fs_two_text';
$title = new lang_string('featuretwotext', 'theme_snap');
$setting = new admin_setting_configtextarea($name, $title, $description, $default);
$fssettings->add($setting);
$name = 'theme_snap/fs_three_text';
$title = new lang_string('featurethreetext', 'theme_snap');
$setting = new admin_setting_configtextarea($name, $title, $description, $default);
$fssettings->add($setting);
// Featured courses instructions.
$name = 'theme_snap/fc_instructions';
$heading = '';
$description = get_string('featuredcourseshelp', 'theme_snap');
$setting = new admin_setting_heading($name, $heading, $description);
$fcsettings->add($setting);
// Featured courses heading.
$name = 'theme_snap/fc_heading';
$title = new lang_string('featuredcoursesheading', 'theme_snap');
$description = '';
$default = new lang_string('featuredcourses', 'theme_snap');
$setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_RAW_TRIMMED, 50);
$fcsettings->add($setting);
// Featured courses.
$name = 'theme_snap/fc_one';
$title = new lang_string('featuredcourseone', 'theme_snap');
$description = '';
$default = '0';
$setting = new admin_setting_configcourseid($name, $title, $description, $default, PARAM_RAW_TRIMMED);
$fcsettings->add($setting);
$name = 'theme_snap/fc_two';
$title = new lang_string('featuredcoursetwo', 'theme_snap');
$setting = new admin_setting_configcourseid($name, $title, $description, $default, PARAM_RAW_TRIMMED);
$fcsettings->add($setting);
$name = 'theme_snap/fc_three';
$title = new lang_string('featuredcoursethree', 'theme_snap');
$setting = new admin_setting_configcourseid($name, $title, $description, $default, PARAM_RAW_TRIMMED);
$fcsettings->add($setting);
$name = 'theme_snap/fc_four';
$title = new lang_string('featuredcoursefour', 'theme_snap');
$setting = new admin_setting_configcourseid($name, $title, $description, $default, PARAM_RAW_TRIMMED);
$fcsettings->add($setting);
$name = 'theme_snap/fc_five';
$title = new lang_string('featuredcoursefive', 'theme_snap');
$setting = new admin_setting_configcourseid($name, $title, $description, $default, PARAM_RAW_TRIMMED);
$fcsettings->add($setting);
$name = 'theme_snap/fc_six';
$title = new lang_string('featuredcoursesix', 'theme_snap');
$setting = new admin_setting_configcourseid($name, $title, $description, $default, PARAM_RAW_TRIMMED);
$fcsettings->add($setting);
$name = 'theme_snap/fc_seven';
$title = new lang_string('featuredcourseseven', 'theme_snap');
$setting = new admin_setting_configcourseid($name, $title, $description, $default, PARAM_RAW_TRIMMED);
$fcsettings->add($setting);
$name = 'theme_snap/fc_eight';
$title = new lang_string('featuredcourseeight', 'theme_snap');
$setting = new admin_setting_configcourseid($name, $title, $description, $default, PARAM_RAW_TRIMMED);
$fcsettings->add($setting);
// Browse all courses link.
$name = 'theme_snap/fc_browse_all';
$title = new lang_string('featuredcoursesbrowseall', 'theme_snap');
$description = new lang_string('featuredcoursesbrowsealldesc', 'theme_snap');
$checked = '1';
$unchecked = '0';
$default = $unchecked;
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, $checked, $unchecked);
$fcsettings->add($setting);
// Resource display help text.
$name = 'theme_snap/resourcedisplayhelp';
$heading = '';
$description = get_string('resourcedisplayhelp', 'theme_snap');
$setting = new admin_setting_heading($name, $heading, $description);
$resourcesettings->add($setting);
// Resource display options.
$name = 'theme_snap/resourcedisplay';
$title = new lang_string('resourcedisplay', 'theme_snap');
$card = new lang_string('card', 'theme_snap');
$list = new lang_string('list', 'theme_snap');
$radios = array('list' => $list, 'card' => $card);
$default = 'card';
$description = '';
$setting = new admin_setting_configradiobuttons($name, $title, $description, $default, $radios);
$resourcesettings->add($setting);
}
// Add theme pages.
$ADMIN->add('theme_snap', $snapsettings);
$ADMIN->add('theme_snap', $fssettings);
$ADMIN->add('theme_snap', $fcsettings);
$ADMIN->add('theme_snap', $resourcesettings);