forked from moodle-an-hochschulen/moodle-theme_boost_union
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.php
741 lines (619 loc) · 40.3 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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
<?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/>.
/**
* Theme Boost Union - Settings file
*
* @package theme_boost_union
* @copyright 2022 Moodle an Hochschulen e.V. <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use \theme_boost_union\admin_setting_configdatetime;
defined('MOODLE_INTERNAL') || die();
if ($hassiteconfig || has_capability('theme/boost_union:configure', context_system::instance())) {
// How this file works:
// This theme's settings are divided into multiple settings pages.
// This is quite unusual as Boost themes would have a nice tabbed settings interface.
// However, as we are using many hide_if constraints for our settings, we would run into the
// stupid "Too much data passed as arguments to js_call_amd..." debugging message if we would
// pack all settings onto just one settings page.
// To achieve this goal, we create a custom admin settings category and fill it with several settings pages.
// However, there is still the $settings variable which is expected by Moodle coreto be filled with the theme
// settings and which is automatically added to the admin settings tree in one settings page.
// To avoid that there appears an empty "Boost Union" settings page near our own custom settings category,
// we set $settings to null.
// Avoid that the theme settings page is auto-created.
$settings = null;
// Create custom admin settings category.
$ADMIN->add('themes', new admin_category('theme_boost_union',
get_string('pluginname', 'theme_boost_union', null, true)));
// Create empty settings page structure to make the site administration work on non-admin pages.
if (!$ADMIN->fulltree) {
// Create Look settings page
// (and allow users with the theme/boost_union:configure capability to access it).
$tab = new admin_settingpage('theme_boost_union_look',
get_string('configtitlelook', 'theme_boost_union', null, true),
'theme/boost_union:configure');
$ADMIN->add('theme_boost_union', $tab);
// Create Feel settings page
// (and allow users with the theme/boost_union:configure capability to access it).
$tab = new admin_settingpage('theme_boost_union_feel',
get_string('configtitlefeel', 'theme_boost_union', null, true),
'theme/boost_union:configure');
$ADMIN->add('theme_boost_union', $tab);
// Create Content settings page
// (and allow users with the theme/boost_union:configure capability to access it).
$tab = new admin_settingpage('theme_boost_union_content',
get_string('configtitlecontent', 'theme_boost_union', null, true),
'theme/boost_union:configure');
$ADMIN->add('theme_boost_union', $tab);
// Create Functionality settings page
// (and allow users with the theme/boost_union:configure capability to access it).
$tab = new admin_settingpage('theme_boost_union_functionality',
get_string('configtitlefunctionality', 'theme_boost_union', null, true),
'theme/boost_union:configure');
$ADMIN->add('theme_boost_union', $tab);
}
// Create full settings page structure.
// @codingStandardsIgnoreLine
else if ($ADMIN->fulltree) {
// Require the necessary libraries.
require_once($CFG->dirroot . '/theme/boost_union/lib.php');
require_once($CFG->dirroot . '/theme/boost_union/locallib.php');
// Prepare options array for select settings.
// Due to MDL-58376, we will use binary select settings instead of checkbox settings throughout this theme.
$yesnooption = array(THEME_BOOST_UNION_SETTING_SELECT_YES => get_string('yes'),
THEME_BOOST_UNION_SETTING_SELECT_NO => get_string('no'));
// Create Look settings page with tabs
// (and allow users with the theme/boost_union:configure capability to access it).
$page = new theme_boost_admin_settingspage_tabs('theme_boost_union_look',
get_string('configtitlelook', 'theme_boost_union', null, true),
'theme/boost_union:configure');
// Create general settings tab.
$tab = new admin_settingpage('theme_boost_union_look_general', get_string('generalsettings', 'theme_boost', null, true));
// Create theme presets heading.
$name = 'theme_boost_union/presetheading';
$title = get_string('presetheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Replicate the preset setting from theme_boost, but use our own file area.
$name = 'theme_boost_union/preset';
$title = get_string('preset', 'theme_boost', null, true);
$description = get_string('preset_desc', 'theme_boost', null, true);
$default = 'default.scss';
$context = context_system::instance();
$fs = get_file_storage();
$files = $fs->get_area_files($context->id, 'theme_boost_union', 'preset', 0, 'itemid, filepath, filename', false);
$choices = [];
foreach ($files as $file) {
$choices[$file->get_filename()] = $file->get_filename();
}
$choices['default.scss'] = 'default.scss';
$choices['plain.scss'] = 'plain.scss';
$setting = new admin_setting_configthemepreset($name, $title, $description, $default, $choices, 'boost_union');
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Replicate the preset files setting from theme_boost.
$name = 'theme_boost_union/presetfiles';
$title = get_string('presetfiles', 'theme_boost', null, true);
$description = get_string('presetfiles_desc', 'theme_boost', null, true);
$setting = new admin_setting_configstoredfile($name, $title, $description, 'preset', 0,
array('maxfiles' => 20, 'accepted_types' => array('.scss')));
$tab->add($setting);
// Add tab to settings page.
$page->add($tab);
// Create advanced settings tab.
$tab = new admin_settingpage('theme_boost_union_look_advanced', get_string('advancedsettings', 'theme_boost', null, true));
// Create Raw SCSS heading.
$name = 'theme_boost_union/scssheading';
$title = get_string('scssheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Replicate the Raw initial SCSS setting from theme_boost.
$name = 'theme_boost_union/scsspre';
$title = get_string('rawscsspre', 'theme_boost', null, true);
$description = get_string('rawscsspre_desc', 'theme_boost', null, true);
$default = '';
$setting = new admin_setting_scsscode($name, $title, $description, $default, PARAM_RAW);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Replicate the Raw SCSS setting from theme_boost.
$name = 'theme_boost_union/scss';
$title = get_string('rawscss', 'theme_boost', null, true);
$description = get_string('rawscss_desc', 'theme_boost', null, true);
$default = '';
$setting = new admin_setting_scsscode($name, $title, $description, $default, PARAM_RAW);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Add tab to settings page.
$page->add($tab);
// Create page tab.
$tab = new admin_settingpage('theme_boost_union_look_page', get_string('pagetab', 'theme_boost_union', null, true));
// Create layout heading.
$name = 'theme_boost_union/layoutheading';
$title = get_string('layoutheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Course content max width.
$name = 'theme_boost_union/coursecontentmaxwidth';
$title = get_string('coursecontentmaxwidthsetting', 'theme_boost_union', null, true);
$description = get_string('coursecontentmaxwidthsetting_desc', 'theme_boost_union', null, true);
$default = '830px';
// Regular expression for checking if the value is a percent number (from 0% to 100%) or a pixel number (with 3 or 4 digits)
// or a viewport width number (from 0 to 100).
$regex = '/^((\d{1,2}|100)%)|((\d{1,2}|100)vw)|(\d{3,4}px)$/';
$setting = new admin_setting_configtext($name, $title, $description, $default, $regex, 6);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Add tab to settings page.
$page->add($tab);
// Create branding tab.
$tab = new admin_settingpage('theme_boost_union_look_branding', get_string('brandingtab', 'theme_boost_union', null, true));
// Create favicon heading.
$name = 'theme_boost_union/faviconheading';
$title = get_string('faviconheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Favicon.
$name = 'theme_boost_union/favicon';
$title = get_string('faviconsetting', 'theme_boost_union', null, true);
$description = get_string('faviconsetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configstoredfile($name, $title, $description, 'favicon', 0,
array('maxfiles' => 1, 'accepted_types' => array('.ico', '.png')));
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Create background images heading.
$name = 'theme_boost_union/backgroundimagesheading';
$title = get_string('backgroundimagesheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Replicate the Background image setting from theme_boost.
$name = 'theme_boost_union/backgroundimage';
$title = get_string('backgroundimage', 'theme_boost', null, true);
$description = get_string('backgroundimage_desc', 'theme_boost', null, true);
$setting = new admin_setting_configstoredfile($name, $title, $description, 'backgroundimage');
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Replicate the Login Background image setting from theme_boost.
$name = 'theme_boost_union/loginbackgroundimage';
$title = get_string('loginbackgroundimage', 'theme_boost', null, true);
$description = get_string('loginbackgroundimage_desc', 'theme_boost', null, true);
$setting = new admin_setting_configstoredfile($name, $title, $description, 'loginbackgroundimage');
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Create brand colors heading.
$name = 'theme_boost_union/brandcolorsheading';
$title = get_string('brandcolorsheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Replicate the Variable $body-color setting from theme_boost.
$name = 'theme_boost_union/brandcolor';
$title = get_string('brandcolor', 'theme_boost', null, true);
$description = get_string('brandcolor_desc', 'theme_boost', null, true);
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Create Bootstrap colors heading.
$name = 'theme_boost_union/bootstrapcolorsheading';
$title = get_string('bootstrapcolorsheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Bootstrap color for 'success'.
$name = 'theme_boost_union/bootstrapcolorsuccess';
$title = get_string('bootstrapcolorsuccesssetting', 'theme_boost_union', null, true);
$description = get_string('bootstrapcolorsuccesssetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: Bootstrap color for 'info'.
$name = 'theme_boost_union/bootstrapcolorinfo';
$title = get_string('bootstrapcolorinfosetting', 'theme_boost_union', null, true);
$description = get_string('bootstrapcolorinfosetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: Bootstrap color for 'warning'.
$name = 'theme_boost_union/bootstrapcolorwarning';
$title = get_string('bootstrapcolorwarningsetting', 'theme_boost_union', null, true);
$description = get_string('bootstrapcolorwarningsetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: Bootstrap color for 'danger'.
$name = 'theme_boost_union/bootstrapcolordanger';
$title = get_string('bootstrapcolordangersetting', 'theme_boost_union', null, true);
$description = get_string('bootstrapcolordangersetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Create activity icon colors heading.
$name = 'theme_boost_union/activityiconcolorsheading';
$title = get_string('activityiconcolorsheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Activity icon color for 'administration'.
$name = 'theme_boost_union/activityiconcoloradministration';
$title = get_string('activityiconcoloradministrationsetting', 'theme_boost_union', null, true);
$description = get_string('activityiconcoloradministrationsetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: Activity icon color for 'assessment'.
$name = 'theme_boost_union/activityiconcolorassessment';
$title = get_string('activityiconcolorassessmentsetting', 'theme_boost_union', null, true);
$description = get_string('activityiconcolorassessmentsetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: Activity icon color for 'collaboration'.
$name = 'theme_boost_union/activityiconcolorcollaboration';
$title = get_string('activityiconcolorcollaborationsetting', 'theme_boost_union', null, true);
$description = get_string('activityiconcolorcollaborationsetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: Activity icon color for 'communication'.
$name = 'theme_boost_union/activityiconcolorcommunication';
$title = get_string('activityiconcolorcommunicationsetting', 'theme_boost_union', null, true);
$description = get_string('activityiconcolorcommunicationsetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: Activity icon color for 'content'.
$name = 'theme_boost_union/activityiconcolorcontent';
$title = get_string('activityiconcolorcontentsetting', 'theme_boost_union', null, true);
$description = get_string('activityiconcolorcontentsetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: Activity icon color for 'interface'.
$name = 'theme_boost_union/activityiconcolorinterface';
$title = get_string('activityiconcolorinterfacesetting', 'theme_boost_union', null, true);
$description = get_string('activityiconcolorinterfacesetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Add tab to settings page.
$page->add($tab);
// Add settings page to the admin settings category.
$ADMIN->add('theme_boost_union', $page);
// Create Feel settings page with tabs
// (and allow users with the theme/boost_union:configure capability to access it).
$page = new theme_boost_admin_settingspage_tabs('theme_boost_union_feel',
get_string('configtitlefeel', 'theme_boost_union', null, true),
'theme/boost_union:configure');
// Create navigation tab.
$tab = new admin_settingpage('theme_boost_union_feel_navigation',
get_string('navigationtab', 'theme_boost_union', null, true));
// Create navigation heading.
$name = 'theme_boost_union/navigationheading';
$title = get_string('navigationheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: back to top button.
$name = 'theme_boost_union/backtotopbutton';
$title = get_string('backtotopbuttonsetting', 'theme_boost_union', null, true);
$description = get_string('backtotopbuttonsetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO, $yesnooption);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: scroll-spy.
$name = 'theme_boost_union/scrollspy';
$title = get_string('scrollspysetting', 'theme_boost_union', null, true);
$description = get_string('scrollspysetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO, $yesnooption);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Add tab to settings page.
$page->add($tab);
// Create blocks tab.
$tab = new admin_settingpage('theme_boost_union_feel_blocks', get_string('blockstab', 'theme_boost_union', null, true));
// Create blocks general heading.
$name = 'theme_boost_union/blocksgeneralheading';
$title = get_string('blocksgeneralheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Replicate the Unaddable blocks setting from theme_boost.
$name = 'theme_boost_union/unaddableblocks';
$title = get_string('unaddableblocks', 'theme_boost', null, true);
$description = get_string('unaddableblocks_desc', 'theme_boost', null, true);
$default = 'navigation,settings,course_list,section_links';
$setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_TEXT);
$tab->add($setting);
// Add tab to settings page.
$page->add($tab);
// Create misc tab.
$tab = new admin_settingpage('theme_boost_union_feel_misc', get_string('misctab', 'theme_boost_union', null, true));
// Create JavaScript heading.
$name = 'theme_boost_union/javascriptheading';
$title = get_string('javascriptheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: JavaScript disabled hint.
$name = 'theme_boost_union/javascriptdisabledhint';
$title = get_string('javascriptdisabledhint', 'theme_boost_union', null, true);
$description = get_string('javascriptdisabledhint_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO, $yesnooption);
$tab->add($setting);
// Add tab to settings page.
$page->add($tab);
// Add settings page to the admin settings category.
$ADMIN->add('theme_boost_union', $page);
// Create Content settings page with tabs
// (and allow users with the theme/boost_union:configure capability to access it).
$page = new theme_boost_admin_settingspage_tabs('theme_boost_union_content',
get_string('configtitlecontent', 'theme_boost_union', null, true),
'theme/boost_union:configure');
// Create footer tab.
$tab = new admin_settingpage('theme_boost_union_content_footer', get_string('footertab', 'theme_boost_union', null, true));
// Create footnote heading.
$name = 'theme_boost_union/footnoteheading';
$title = get_string('footnoteheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Footnote.
$name = 'theme_boost_union/footnote';
$title = get_string('footnotesetting', 'theme_boost_union', null, true);
$description = get_string('footnotesetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_confightmleditor($name, $title, $description, '');
$tab->add($setting);
// Add tab to settings page.
$page->add($tab);
// Create static pages tab.
$tab = new admin_settingpage('theme_boost_union_content_staticpages',
get_string('staticpagestab', 'theme_boost_union', null, true));
// Create imprint heading.
$name = 'theme_boost_union/imprintheading';
$title = get_string('imprintheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Enable imprint.
$name = 'theme_boost_union/enableimprint';
$title = get_string('enableimprintsetting', 'theme_boost_union', null, true);
$description = '';
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO, $yesnooption);
$tab->add($setting);
// Setting: Imprint content.
$name = 'theme_boost_union/imprintcontent';
$title = get_string('imprintcontentsetting', 'theme_boost_union', null, true);
$description = get_string('imprintcontentsetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_confightmleditor($name, $title, $description, '');
$tab->add($setting);
$page->hide_if('theme_boost_union/imprintcontent', 'theme_boost_union/enableimprint', 'neq',
THEME_BOOST_UNION_SETTING_SELECT_YES);
// Setting: Imprint page title.
$name = 'theme_boost_union/imprintpagetitle';
$title = get_string('imprintpagetitlesetting', 'theme_boost_union', null, true);
$description = get_string('imprintpagetitlesetting_desc', 'theme_boost_union', null, true);
$default = get_string('imprintpagetitledefault', 'theme_boost_union', null, true);
$setting = new admin_setting_configtext($name, $title, $description, $default);
$tab->add($setting);
$page->hide_if('theme_boost_union/imprintpagetitle', 'theme_boost_union/enableimprint', 'neq',
THEME_BOOST_UNION_SETTING_SELECT_YES);
// Setting: Imprint link position.
$name = 'theme_boost_union/imprintlinkposition';
$title = get_string('imprintlinkpositionsetting', 'theme_boost_union', null, true);
$imprinturl = theme_boost_union_get_imprint_link();
$description = get_string('imprintlinkpositionsetting_desc', 'theme_boost_union', array('url' => $imprinturl), true);
$imprintlinkpositionoption =
// Don't use string lazy loading (= false) because the string will be directly used and would produce a
// PHP warning otherwise.
array(THEME_BOOST_UNION_SETTING_IMPRINTLINKPOSITION_NONE =>
get_string('imprintlinkpositionnone', 'theme_boost_union', null, false),
THEME_BOOST_UNION_SETTING_IMPRINTLINKPOSITION_FOOTNOTE =>
get_string('imprintlinkpositionfootnote', 'theme_boost_union', null, false),
THEME_BOOST_UNION_SETTING_IMPRINTLINKPOSITION_FOOTER =>
get_string('imprintlinkpositionfooter', 'theme_boost_union', null, false),
THEME_BOOST_UNION_SETTING_IMPRINTLINKPOSITION_BOTH =>
get_string('imprintlinkpositionboth', 'theme_boost_union', null, false));
$default = 'none';
$setting = new admin_setting_configselect($name, $title, $description, $default, $imprintlinkpositionoption);
$tab->add($setting);
$page->hide_if('theme_boost_union/imprintlinkposition', 'theme_boost_union/enableimprint', 'neq',
THEME_BOOST_UNION_SETTING_SELECT_YES);
// Add tab to settings page.
$page->add($tab);
// Create info banner tab.
$tab = new admin_settingpage('theme_boost_union_infobanners_infobanner',
get_string('infobannertab', 'theme_boost_union', null, true));
// Prepare options for the pages settings.
$infobannerpages = array(
// Don't use string lazy loading (= false) because the string will be directly used and would produce a
// PHP warning otherwise.
THEME_BOOST_UNION_SETTING_INFOBANNERPAGES_MY => get_string('myhome', 'core', null, false),
THEME_BOOST_UNION_SETTING_INFOBANNERPAGES_MYCOURSES => get_string('mycourses', 'core', null, false),
THEME_BOOST_UNION_SETTING_INFOBANNERPAGES_SITEHOME => get_string('sitehome', 'core', null, false),
THEME_BOOST_UNION_SETTING_INFOBANNERPAGES_COURSE => get_string('course', 'core', null, false),
THEME_BOOST_UNION_SETTING_INFOBANNERPAGES_LOGIN =>
get_string('infobannerpageloginpage', 'theme_boost_union', null, false)
);
// Prepare options for the bootstrap class settings.
$infobannerbsclasses = array(
// Don't use string lazy loading (= false) because the string will be directly used and would produce a
// PHP warning otherwise.
'primary' => get_string('bootstrapprimarycolor', 'theme_boost_union', null, false),
'secondary' => get_string('bootstrapsecondarycolor', 'theme_boost_union', null, false),
'success' => get_string('bootstrapsuccesscolor', 'theme_boost_union', null, false),
'danger' => get_string('bootstrapdangercolor', 'theme_boost_union', null, false),
'warning' => get_string('bootstrapwarningcolor', 'theme_boost_union', null, false),
'info' => get_string('bootstrapinfocolor', 'theme_boost_union', null, false),
'light' => get_string('bootstraplightcolor', 'theme_boost_union', null, false),
'dark' => get_string('bootstrapdarkcolor', 'theme_boost_union', null, false),
'none' => get_string('bootstrapnone', 'theme_boost_union', null, false)
);
// Prepare options for the order settings.
$infobannerorders = array();
for ($i = 1; $i <= THEME_BOOST_UNION_SETTING_INFOBANNER_COUNT; $i++) {
$infobannerorders[$i] = $i;
}
// Prepare options for the mode settings.
$infobannermodes = array(
// Don't use string lazy loading (= false) because the string will be directly used and would produce a
// PHP warning otherwise.
THEME_BOOST_UNION_SETTING_INFOBANNERMODE_PERPETUAL =>
get_string('infobannermodeperpetual', 'theme_boost_union', null, false),
THEME_BOOST_UNION_SETTING_INFOBANNERMODE_TIMEBASED =>
get_string('infobannermodetimebased', 'theme_boost_union', null, false)
);
// Create the hardcoded amount of information banners without code duplication.
for ($i = 1; $i <= THEME_BOOST_UNION_SETTING_INFOBANNER_COUNT; $i++) {
// Create Infobanner heading.
$name = 'theme_boost_union/infobanner'.$i.'heading';
$title = get_string('infobannerheading', 'theme_boost_union', array('no' => $i), true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Infobanner enabled.
$name = 'theme_boost_union/infobanner'.$i.'enabled';
$title = get_string('infobannerenabledsetting', 'theme_boost_union', array('no' => $i), true);
$description = get_string('infobannerenabledsetting_desc', 'theme_boost_union', array('no' => $i), true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO,
$yesnooption);
$tab->add($setting);
// Setting: Infobanner content.
$name = 'theme_boost_union/infobanner'.$i.'content';
$title = get_string('infobannercontentsetting', 'theme_boost_union', array('no' => $i), true);
$description = get_string('infobannercontentsetting_desc', 'theme_boost_union', array('no' => $i), true);
$setting = new admin_setting_confightmleditor($name, $title, $description, '');
$tab->add($setting);
$page->hide_if('theme_boost_union/infobanner'.$i.'content', 'theme_boost_union/infobanner'.$i.'enabled', 'neq',
THEME_BOOST_UNION_SETTING_SELECT_YES);
// Setting: Infobanner pages.
$name = 'theme_boost_union/infobanner'.$i.'pages';
$title = get_string('infobannerpagessetting', 'theme_boost_union', array('no' => $i), true);
$description = get_string('infobannerpagessetting_desc', 'theme_boost_union', array('no' => $i), true);
$setting = new admin_setting_configmultiselect($name, $title, $description,
array($infobannerpages[THEME_BOOST_UNION_SETTING_INFOBANNERPAGES_MY]), $infobannerpages);
$tab->add($setting);
$page->hide_if('theme_boost_union/infobanner'.$i.'pages', 'theme_boost_union/infobanner'.$i.'enabled', 'neq',
THEME_BOOST_UNION_SETTING_SELECT_YES);
// Setting: Infobanner bootstrap class.
$name = 'theme_boost_union/infobanner'.$i.'bsclass';
$title = get_string('infobannerbsclasssetting', 'theme_boost_union', array('no' => $i), true);
$description = get_string('infobannerbsclasssetting_desc',
'theme_boost_union',
array('no' => $i, 'bootstrapnone' => get_string('bootstrapnone', 'theme_boost_union')),
true);
$setting = new admin_setting_configselect($name, $title, $description,
'primary', $infobannerbsclasses);
$tab->add($setting);
$page->hide_if('theme_boost_union/infobanner'.$i.'bsclass', 'theme_boost_union/infobanner'.$i.'enabled', 'neq',
THEME_BOOST_UNION_SETTING_SELECT_YES);
// Setting: Infobanner order.
$name = 'theme_boost_union/infobanner'.$i.'order';
$title = get_string('infobannerordersetting', 'theme_boost_union', array('no' => $i), true);
$description = get_string('infobannerordersetting_desc', 'theme_boost_union', array('no' => $i), true);
$setting = new admin_setting_configselect($name, $title, $description,
$i, $infobannerorders);
$tab->add($setting);
$page->hide_if('theme_boost_union/infobanner'.$i.'order', 'theme_boost_union/infobanner'.$i.'enabled', 'neq',
THEME_BOOST_UNION_SETTING_SELECT_YES);
// Setting: Infobanner mode.
$name = 'theme_boost_union/infobanner'.$i.'mode';
$title = get_string('infobannermodesetting', 'theme_boost_union', array('no' => $i), true);
$description = get_string('infobannermodesetting_desc', 'theme_boost_union', array('no' => $i), true);
$setting = new admin_setting_configselect($name, $title, $description,
THEME_BOOST_UNION_SETTING_INFOBANNERMODE_PERPETUAL, $infobannermodes);
$tab->add($setting);
$page->hide_if('theme_boost_union/infobanner'.$i.'mode', 'theme_boost_union/infobanner'.$i.'enabled', 'neq',
THEME_BOOST_UNION_SETTING_SELECT_YES);
// Setting: Infobanner start time.
$name = 'theme_boost_union/infobanner'.$i.'start';
$title = get_string('infobannerstartsetting', 'theme_boost_union', array('no' => $i), true);
$description = get_string('infobannerstartsetting_desc', 'theme_boost_union', array('no' => $i), true);
$setting = new admin_setting_configdatetime($name, $title, $description, '');
$tab->add($setting);
$page->hide_if('theme_boost_union/infobanner'.$i.'start', 'theme_boost_union/infobanner'.$i.'enabled', 'neq',
THEME_BOOST_UNION_SETTING_SELECT_YES);
$page->hide_if('theme_boost_union/infobanner'.$i.'start', 'theme_boost_union/infobanner'.$i.'mode', 'neq',
THEME_BOOST_UNION_SETTING_INFOBANNERMODE_TIMEBASED);
// Setting: Infobanner end time.
$name = 'theme_boost_union/infobanner'.$i.'end';
$title = get_string('infobannerendsetting', 'theme_boost_union', array('no' => $i), true);
$description = get_string('infobannerendsetting_desc', 'theme_boost_union', array('no' => $i), true);
$setting = new admin_setting_configdatetime($name, $title, $description, '');
$tab->add($setting);
$page->hide_if('theme_boost_union/infobanner'.$i.'end', 'theme_boost_union/infobanner'.$i.'enabled', 'neq',
THEME_BOOST_UNION_SETTING_SELECT_YES);
$page->hide_if('theme_boost_union/infobanner'.$i.'end', 'theme_boost_union/infobanner'.$i.'mode', 'neq',
THEME_BOOST_UNION_SETTING_INFOBANNERMODE_TIMEBASED);
// Setting: Infobanner dismissible.
$name = 'theme_boost_union/infobanner'.$i.'dismissible';
$title = get_string('infobannerdismissiblesetting', 'theme_boost_union', array('no' => $i), true);
$description = get_string('infobannerdismissiblesetting_desc', 'theme_boost_union', array('no' => $i), true);
// Add Reset button if the info banner is already configured to be dismissible.
if (get_config('theme_boost_union', 'infobanner'.$i.'dismissible') == true) {
$reseturl = new moodle_url('/theme/boost_union/settings_infobanner_resetdismissed.php',
array('sesskey' => sesskey(), 'no' => $i));
$description .= html_writer::empty_tag('br');
$description .= html_writer::link($reseturl,
get_string('infobannerdismissresetbutton', 'theme_boost_union', array('no' => $i), true),
array('class' => 'btn btn-secondary mt-3', 'role' => 'button'));
}
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO,
$yesnooption);
$tab->add($setting);
$page->hide_if('theme_boost_union/infobanner'.$i.'dismissible', 'theme_boost_union/infobanner'.$i.'enabled', 'neq',
THEME_BOOST_UNION_SETTING_SELECT_YES);
$page->hide_if('theme_boost_union/infobanner'.$i.'dismissible', 'theme_boost_union/infobanner'.$i.'mode', 'neq',
THEME_BOOST_UNION_SETTING_INFOBANNERMODE_PERPETUAL);
}
// Add tab to settings page.
$page->add($tab);
// Add settings page to the admin settings category.
$ADMIN->add('theme_boost_union', $page);
// Create Functionality settings page with tabs
// (and allow users with the theme/boost_union:configure capability to access it).
$page = new theme_boost_admin_settingspage_tabs('theme_boost_union_functionality',
get_string('configtitlefunctionality', 'theme_boost_union', null, true),
'theme/boost_union:configure');
// Create courses tab.
$tab = new admin_settingpage('theme_boost_union_functionality_courses',
get_string('coursestab', 'theme_boost_union', null, true));
// Create course related hints heading.
$name = 'theme_boost_union/courserelatedhintsheading';
$title = get_string('courserelatedhintsheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Show hint for switched role.
$name = 'theme_boost_union/showswitchedroleincourse';
$title = get_string('showswitchedroleincoursesetting', 'theme_boost_union', null, true);
$description = get_string('showswitchedroleincoursesetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO, $yesnooption);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: Show hint in hidden courses.
$name = 'theme_boost_union/showhintcoursehidden';
$title = get_string('showhintcoursehiddensetting', 'theme_boost_union', null, true);
$description = get_string('showhintcoursehiddensetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO, $yesnooption);
$tab->add($setting);
// Setting: Show hint guest for access.
$name = 'theme_boost_union/showhintcourseguestaccess';
$title = get_string('showhintcoursguestaccesssetting', 'theme_boost_union', null, true);
$description = get_string('showhintcourseguestaccesssetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO, $yesnooption);
$tab->add($setting);
// Setting: Show hint for self enrolment without enrolment key.
$name = 'theme_boost_union/showhintcourseselfenrol';
$title = get_string('showhintcourseselfenrolsetting', 'theme_boost_union', null, true);
$description = get_string('showhintcourseselfenrolsetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO, $yesnooption);
$tab->add($setting);
// Add tab to settings page.
$page->add($tab);
// Add settings page to the admin settings category.
$ADMIN->add('theme_boost_union', $page);
}
}