-
Notifications
You must be signed in to change notification settings - Fork 61
/
settings.php
2818 lines (2467 loc) · 166 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
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?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 Alexander Bias, lern.link GmbH <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use theme_boost_union\admin_setting_configdatetime;
use theme_boost_union\admin_setting_configstoredfilealwayscallback;
use theme_boost_union\admin_setting_configtext_url;
use core\di;
use core\hook\manager as hook_manager;
defined('MOODLE_INTERNAL') || die();
if ($hassiteconfig || has_capability('theme/boost_union:configure', context_system::instance())) {
global $PAGE;
// 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 core to be filled with the theme
// settings and which is automatically linked from the theme selector page.
// To avoid that there appears a broken "Boost Union" settings page, we redirect the user to a settings
// overview page if he opens this page.
$mainsettingspageurl = new core\url('/admin/settings.php', ['section' => 'themesettingboost_union']);
if ($ADMIN->fulltree && $PAGE->has_set_url() && $PAGE->url->compare($mainsettingspageurl)) {
redirect(new core\url('/theme/boost_union/settings_overview.php'));
}
// Create custom admin settings category.
$ADMIN->add('appearance', 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 Overview page
// (and allow users with the theme/boost_union:configure capability to access it).
$overviewpage = new admin_externalpage('theme_boost_union_overview',
get_string('settingsoverview', 'theme_boost_union', null, true),
new core\url('/theme/boost_union/settings_overview.php'),
'theme/boost_union:configure');
$ADMIN->add('theme_boost_union', $overviewpage);
// 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 Flavours settings page as external page
// (and allow users with the theme/boost_union:configure capability to access it).
$flavourspage = new admin_externalpage('theme_boost_union_flavours',
get_string('configtitleflavours', 'theme_boost_union', null, true),
new core\url('/theme/boost_union/flavours/overview.php'),
'theme/boost_union:configure');
$ADMIN->add('theme_boost_union', $flavourspage);
// Create Smart Menus settings page as external page.
// (and allow users with the theme/boost_union:configure capability to access it).
$smartmenuspage = new admin_externalpage('theme_boost_union_smartmenus',
get_string('smartmenus', 'theme_boost_union', null, true),
new core\url('/theme/boost_union/smartmenus/menus.php'),
'theme/boost_union:configure');
$ADMIN->add('theme_boost_union', $smartmenuspage);
}
// Create full settings page structure.
else if ($ADMIN->fulltree) { // phpcs:disable moodle.ControlStructures.ControlSignature.Found
// Require the necessary libraries.
require_once($CFG->dirroot . '/theme/boost_union/lib.php');
require_once($CFG->dirroot . '/theme/boost_union/locallib.php');
require_once($CFG->dirroot . '/course/lib.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 = [THEME_BOOST_UNION_SETTING_SELECT_YES => get_string('yes'),
THEME_BOOST_UNION_SETTING_SELECT_NO => get_string('no'), ];
// Prepare 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).
$widthregex = '/^((\d{1,2}|100)%)|((\d{1,2}|100)vw)|(\d{3,4}px)$/';
// 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';
$preseturl = new core\url('/admin/settings.php', ['section' => 'themesettingboost'], 'theme_boost_general');
$title = get_string('presetheading', 'theme_boost_union', null, true);
$description = get_string('presetheading_desc', 'theme_boost_union', null, true).'<br />'.
// We would love to use $OUTPUT->single_button($preseturl, ...) here, but this results in the fact
// that the settings page redirects to the Boost Core settings after saving for an unknown reason.
\core\output\html_writer::link($preseturl,
get_string('presetbutton', 'theme_boost_union', null, true),
['class' => 'btn btn-secondary my-3']);
$setting = new admin_setting_heading($name, $title, $description);
$tab->add($setting);
// Add tab to settings page.
$page->add($tab);
// Create SCSS tab.
$tab = new admin_settingpage('theme_boost_union_look_scss', get_string('scsstab', 'theme_boost_union', 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);
// Create external SCSS heading.
$name = 'theme_boost_union/extscssheading';
$title = get_string('extscssheading', 'theme_boost_union', null, true);
$taskurl = new core\url('/admin/tool/task/scheduledtasks.php',
['action' => 'edit', 'task' => 'theme_boost_union\task\purge_cache']);
$description = get_string('extscssheading_desc', 'theme_boost_union', null, true).'<br /><br />'.
get_string('extscssheading_instr', 'theme_boost_union', null, true).
'<ul><li>'.get_string('extscssheading_sources', 'theme_boost_union', null, true).'</li>'.
'<li>'.get_string('extscssheading_prepost', 'theme_boost_union', null, true).'</li>'.
'<li>'.get_string('extscssheading_structure', 'theme_boost_union', null, true).'</li>'.
'<li>'.get_string('extscssheading_drop', 'theme_boost_union', null, true).'</li>'.
'<li>'.get_string('extscssheading_task', 'theme_boost_union', $taskurl->out(), true).'</li></ul>';
$setting = new admin_setting_heading($name, $title, $description);
$tab->add($setting);
// Setting: External SCSS source.
$extscsssourceoptions = [
THEME_BOOST_UNION_SETTING_EXTSCSSSOURCE_NONE =>
get_string('extscsssourcenone', 'theme_boost_union'),
THEME_BOOST_UNION_SETTING_EXTSCSSSOURCE_DOWNLOAD =>
get_string('extscsssourcedownload', 'theme_boost_union'),
THEME_BOOST_UNION_SETTING_EXTSCSSSOURCE_GITHUB =>
get_string('extscsssourcegithub', 'theme_boost_union'),
];
$name = 'theme_boost_union/extscsssource';
$title = get_string('extscsssource', 'theme_boost_union', null, true);
$description = get_string('extscsssource_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configselect($name, $title, $description,
THEME_BOOST_UNION_SETTING_EXTSCSSSOURCE_NONE, $extscsssourceoptions);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: External Pre SCSS download URL.
$name = 'theme_boost_union/extscssurlpre';
$title = get_string('extscssurlpre', 'theme_boost_union', null, true);
$description = get_string('extscssurlpre_desc', 'theme_boost_union', null, true);
$default = '';
$setting = new admin_setting_configtext_url($name, $title, $description, $default, PARAM_URL);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
$page->hide_if('theme_boost_union/extscssurlpre', 'theme_boost_union/extscsssource', 'neq',
THEME_BOOST_UNION_SETTING_EXTSCSSSOURCE_DOWNLOAD);
// Setting: External Post SCSS download URL.
$name = 'theme_boost_union/extscssurlpost';
$title = get_string('extscssurlpost', 'theme_boost_union', null, true);
$description = get_string('extscssurlpost_desc', 'theme_boost_union', null, true);
$default = '';
$setting = new admin_setting_configtext_url($name, $title, $description, $default, PARAM_URL);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
$page->hide_if('theme_boost_union/extscssurlpost', 'theme_boost_union/extscsssource', 'neq',
THEME_BOOST_UNION_SETTING_EXTSCSSSOURCE_DOWNLOAD);
// Setting: External SCSS Github API token.
$name = 'theme_boost_union/extscssgithubtoken';
$title = get_string('extscssgithubtoken', 'theme_boost_union', null, true);
$description = get_string('extscssgithubtoken_desc', 'theme_boost_union', null, true).'<br />'.
get_string('extscssgithubtoken_docs', 'theme_boost_union', null, true);
$default = '';
$setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_ALPHANUMEXT);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
$page->hide_if('theme_boost_union/extscssgithubtoken', 'theme_boost_union/extscsssource', 'neq',
THEME_BOOST_UNION_SETTING_EXTSCSSSOURCE_GITHUB);
// Setting: External SCSS Github API user.
$name = 'theme_boost_union/extscssgithubuser';
$title = get_string('extscssgithubuser', 'theme_boost_union', null, true);
$description = get_string('extscssgithubuser_desc', 'theme_boost_union', null, true).'<br />'.
get_string('extscssgithubuser_example', 'theme_boost_union', null, true);
$default = '';
$setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_ALPHANUMEXT);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
$page->hide_if('theme_boost_union/extscssgithubuser', 'theme_boost_union/extscsssource', 'neq',
THEME_BOOST_UNION_SETTING_EXTSCSSSOURCE_GITHUB);
// Setting: External SCSS Github API repository.
$name = 'theme_boost_union/extscssgithubrepo';
$title = get_string('extscssgithubrepo', 'theme_boost_union', null, true);
$description = get_string('extscssgithubrepo_desc', 'theme_boost_union', null, true).'<br />'.
get_string('extscssgithubrepo_example', 'theme_boost_union', null, true);
$default = '';
$setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_ALPHANUMEXT);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
$page->hide_if('theme_boost_union/extscssgithubrepo', 'theme_boost_union/extscsssource', 'neq',
THEME_BOOST_UNION_SETTING_EXTSCSSSOURCE_GITHUB);
// Setting: External Pre SCSS Github file path.
$name = 'theme_boost_union/extscssgithubprefilepath';
$title = get_string('extscssgithubprefilepath', 'theme_boost_union', null, true);
$description = get_string('extscssgithubprefilepath_desc', 'theme_boost_union', null, true).'<br />'.
get_string('extscssgithubfilepath_example', 'theme_boost_union', null, true);
$default = '';
$setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_PATH);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
$page->hide_if('theme_boost_union/extscssgithubprefilepath', 'theme_boost_union/extscsssource', 'neq',
THEME_BOOST_UNION_SETTING_EXTSCSSSOURCE_GITHUB);
// Setting: External Post SCSS Github file path.
$name = 'theme_boost_union/extscssgithubpostfilepath';
$title = get_string('extscssgithubpostfilepath', 'theme_boost_union', null, true);
$description = get_string('extscssgithubpostfilepath_desc', 'theme_boost_union', null, true).'<br />'.
get_string('extscssgithubfilepath_example', 'theme_boost_union', null, true);
$default = '';
$setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_PATH);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
$page->hide_if('theme_boost_union/extscssgithubpostfilepath', 'theme_boost_union/extscsssource', 'neq',
THEME_BOOST_UNION_SETTING_EXTSCSSSOURCE_GITHUB);
// Setting: External SCSS validation.
$name = 'theme_boost_union/extscssvalidation';
$title = get_string('extscssvalidationsetting', 'theme_boost_union', null, true);
$description = get_string('extscssvalidationsetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_YES, $yesnooption);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
$page->hide_if('theme_boost_union/extscssvalidation', 'theme_boost_union/extscsssource', 'eq',
THEME_BOOST_UNION_SETTING_EXTSCSSSOURCE_NONE);
// 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 page width heading.
$name = 'theme_boost_union/pagewidthheading';
$title = get_string('pagewidthheading', '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';
$setting = new admin_setting_configtext($name, $title, $description, $default, $widthregex, 6);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: Medium content max width.
$name = 'theme_boost_union/mediumcontentmaxwidth';
$title = get_string('mediumcontentmaxwidthsetting', 'theme_boost_union', null, true);
$description = get_string('mediumcontentmaxwidthsetting_desc', 'theme_boost_union', null, true);
$default = '1120px';
$setting = new admin_setting_configtext($name, $title, $description, $default, $widthregex, 6);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Create drawer width heading.
$name = 'theme_boost_union/drawerwidthheading';
$title = get_string('drawerwidthheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Course index drawer width.
$name = 'theme_boost_union/courseindexdrawerwidth';
$title = get_string('courseindexdrawerwidthsetting', 'theme_boost_union', null, true);
$description = get_string('courseindexdrawerwidthsetting_desc', 'theme_boost_union', null, true);
$default = '285px';
$setting = new admin_setting_configtext($name, $title, $description, $default, $widthregex, 6);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: Block drawer width.
$name = 'theme_boost_union/blockdrawerwidth';
$title = get_string('blockdrawerwidthsetting', 'theme_boost_union', null, true);
$description = get_string('blockdrawerwidthsetting_desc', 'theme_boost_union', null, true);
$default = '315px';
$setting = new admin_setting_configtext($name, $title, $description, $default, $widthregex, 6);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Add tab to settings page.
$page->add($tab);
// Create site branding tab.
$tab = new admin_settingpage('theme_boost_union_look_sitebranding',
get_string('sitebrandingtab', 'theme_boost_union', null, true));
// Create logos heading.
$name = 'theme_boost_union/logosheading';
$title = get_string('logosheading', 'theme_boost_union', null, true);
$notificationurl = new core\url('/admin/settings.php', ['section' => 'logos']);
$notification = new \core\output\notification(get_string('logosheading_desc', 'theme_boost_union', $notificationurl->out()),
\core\output\notification::NOTIFY_INFO);
$notification->set_show_closebutton(false);
$description = $OUTPUT->render($notification);
$setting = new admin_setting_heading($name, $title, $description);
$tab->add($setting);
// Replicate the logo setting from core_admin.
$name = 'theme_boost_union/logo';
$title = get_string('logosetting', 'theme_boost_union', null, true);
$description = get_string('logosetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configstoredfile($name, $title, $description, 'logo', 0,
['maxfiles' => 1, 'accepted_types' => 'web_image']);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Replicate the compact logo setting from core_admin.
$name = 'theme_boost_union/logocompact';
$title = get_string('logocompactsetting', 'theme_boost_union', null, true);
$description = get_string('logocompactsetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configstoredfile($name, $title, $description, 'logocompact', 0,
['maxfiles' => 1, 'accepted_types' => 'web_image']);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Create favicon heading.
$name = 'theme_boost_union/faviconheading';
$title = get_string('faviconheading', 'theme_boost_union', null, true);
$notificationurl = new core\url('/admin/settings.php', ['section' => 'logos']);
$notification = new \core\output\notification(get_string('faviconheading_desc', 'theme_boost_union',
$notificationurl->out()), \core\output\notification::NOTIFY_INFO);
$notification->set_show_closebutton(false);
$description = $OUTPUT->render($notification);
$setting = new admin_setting_heading($name, $title, $description);
$tab->add($setting);
// Replicate the favicon setting from core_admin.
$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,
['maxfiles' => 1, 'accepted_types' => 'image']);
$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('backgroundimagesetting', 'theme_boost_union', null, true);
$description = get_string('backgroundimagesetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configstoredfile($name, $title, $description, 'backgroundimage', 0,
['maxfiles' => 1, 'accepted_types' => 'web_image']);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: Background image position.
$name = 'theme_boost_union/backgroundimageposition';
$title = get_string('backgroundimagepositionsetting', 'theme_boost_union', null, true);
$description = get_string('backgroundimagepositionsetting_desc', 'theme_boost_union', null, true);
$backgroundimagepositionoptions = [
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_CENTER =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_CENTER,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_TOP =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_TOP,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_BOTTOM =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_BOTTOM,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_TOP =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_TOP,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_CENTER =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_CENTER,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_BOTTOM =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_BOTTOM,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_RIGHT_TOP =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_RIGHT_TOP,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_RIGHT_CENTER =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_RIGHT_CENTER,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_RIGHT_BOTTOM =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_RIGHT_BOTTOM, ];
$setting = new admin_setting_configselect($name, $title, $description,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_TOP, $backgroundimagepositionoptions);
$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 brand 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 navbar heading.
$name = 'theme_boost_union/navbarheading';
$title = get_string('navbarheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Navbar color.
$name = 'theme_boost_union/navbarcolor';
$title = get_string('navbarcolorsetting', 'theme_boost_union', null, true);
$description = get_string('navbarcolorsetting_desc', 'theme_boost_union', null, true);
$navbarcoloroptions = [
THEME_BOOST_UNION_SETTING_NAVBARCOLOR_LIGHT =>
get_string('navbarcolorsetting_light', 'theme_boost_union'),
THEME_BOOST_UNION_SETTING_NAVBARCOLOR_DARK =>
get_string('navbarcolorsetting_dark', 'theme_boost_union'),
THEME_BOOST_UNION_SETTING_NAVBARCOLOR_PRIMARYLIGHT =>
get_string('navbarcolorsetting_primarylight', 'theme_boost_union'),
THEME_BOOST_UNION_SETTING_NAVBARCOLOR_PRIMARYDARK =>
get_string('navbarcolorsetting_primarydark', 'theme_boost_union'), ];
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_NAVBARCOLOR_LIGHT,
$navbarcoloroptions);
$tab->add($setting);
// Add tab to settings page.
$page->add($tab);
// Create activity branding tab.
$tab = new admin_settingpage('theme_boost_union_look_activitybranding',
get_string('activitybrandingtab', 'theme_boost_union', null, true));
// 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);
// Define all activity icon purposes (without the 'other' purpose as this is not branded).
$purposes = [MOD_PURPOSE_ADMINISTRATION,
MOD_PURPOSE_ASSESSMENT,
MOD_PURPOSE_COLLABORATION,
MOD_PURPOSE_COMMUNICATION,
MOD_PURPOSE_CONTENT,
MOD_PURPOSE_INTERACTIVECONTENT,
MOD_PURPOSE_INTERFACE];
// Iterate over all purposes.
foreach ($purposes as $purpose) {
// Setting: Activity icon color.
$name = 'theme_boost_union/activityiconcolor'.$purpose;
$title = get_string('activityiconcolor'.$purpose.'setting', 'theme_boost_union', null, true);
$description = get_string('activityiconcolor'.$purpose.'setting_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 fidelity.
$name = 'theme_boost_union/activityiconcolorfidelity';
$title = get_string('activityiconcolorfidelitysetting', 'theme_boost_union', null, true);
$description = get_string('activityiconcolorfidelitysetting_desc', 'theme_boost_union', null, true);
$activityiconcolorfidelityoptions = [
1 => get_string('activityiconcolorfidelity_oneshot', 'theme_boost_union'),
10 => get_string('activityiconcolorfidelity_sometries', 'theme_boost_union'),
100 => get_string('activityiconcolorfidelity_detailled', 'theme_boost_union'),
500 => get_string('activityiconcolorfidelity_insane', 'theme_boost_union'),
];
$setting = new admin_setting_configselect($name, $title, $description, 1, $activityiconcolorfidelityoptions);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Create activity icons purpose heading.
$name = 'theme_boost_union/activitypurposeheading';
$title = get_string('activitypurposeheading', 'theme_boost_union', null, true);
$description = get_string('activitypurposeheading_desc', 'theme_boost_union', null, true).'<br /><br />'.
get_string('activitypurposeheadingtechnote', 'theme_boost_union',
get_string('githubissueslink', 'theme_boost_union', null, true),
true);
$setting = new admin_setting_heading($name, $title, $description);
$tab->add($setting);
// Prepare activity purposes.
$purposesoptions = [
MOD_PURPOSE_ADMINISTRATION => get_string('activitypurposeadministration', 'theme_boost_union'),
MOD_PURPOSE_ASSESSMENT => get_string('activitypurposeassessment', 'theme_boost_union'),
MOD_PURPOSE_COLLABORATION => get_string('activitypurposecollaboration', 'theme_boost_union'),
MOD_PURPOSE_COMMUNICATION => get_string('activitypurposecommunication', 'theme_boost_union'),
MOD_PURPOSE_CONTENT => get_string('activitypurposecontent', 'theme_boost_union'),
MOD_PURPOSE_INTERACTIVECONTENT => get_string('activitypurposeinteractivecontent', 'theme_boost_union'),
MOD_PURPOSE_INTERFACE => get_string('activitypurposeinterface', 'theme_boost_union'),
MOD_PURPOSE_OTHER => get_string('activitypurposeother', 'theme_boost_union'),
];
// Get installed activity modules.
$installedactivities = get_module_types_names();
// Iterate over all existing activities.
foreach ($installedactivities as $modname => $modinfo) {
// Get default purpose of activity module.
$defaultpurpose = plugin_supports('mod', $modname, FEATURE_MOD_PURPOSE, MOD_PURPOSE_OTHER);
// If the plugin does not have any default purpose.
if (!$defaultpurpose) {
// Fallback to "other" purpose.
$defaultpurpose = MOD_PURPOSE_OTHER;
}
// Create the setting.
$name = 'theme_boost_union/activitypurpose'.$modname;
$title = get_string('modulename', $modname, null, true);
$description = '';
$setting = new admin_setting_configselect($name, $title, $description, $defaultpurpose, $purposesoptions);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
}
// Create activity icons heading.
$name = 'theme_boost_union/modicons';
$title = get_string('modiconsheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Enable custom icons for activities and resources.
$name = 'theme_boost_union/modiconsenable';
$title = get_string('modiconsenablesetting', 'theme_boost_union', null, true);
$description = get_string('modiconsenablesetting_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_boost_union_check_mod_icons_cleanup');
$tab->add($setting);
// Setting: Custom icon files.
$name = 'theme_boost_union/modiconsfiles';
$title = get_string('modiconsfiles', 'theme_boost_union', null, true);
$description = get_string('modiconsfiles_desc', 'theme_boost_union', null, true).'<br /><br />'.
get_string('modiconsfileshowto', 'theme_boost_union', null, true).'<br /><br />'.
get_string('modiconsfilestech', 'theme_boost_union', null, true);
// Use our enhanced implementation of admin_setting_configstoredfile to circumvent MDL-59082.
// This can be changed back to admin_setting_configstoredfile as soon as MDL-59082 is fixed.
$setting = new admin_setting_configstoredfilealwayscallback($name, $title, $description, 'modicons', 0,
['maxfiles' => -1, 'subdirs' => 1, 'accepted_types' => ['.png', '.svg']]);
$setting->set_updatedcallback('theme_boost_union_place_mod_icons');
$tab->add($setting);
$page->hide_if('theme_boost_union/modiconsfiles', 'theme_boost_union/modiconsenable', 'neq',
THEME_BOOST_UNION_SETTING_SELECT_YES);
// Information: Custom icons files list.
// If there is at least one file uploaded and if custom icons are enabled (unfortunately, hide_if does not
// work for admin_setting_description up to now, that's why we have to use this workaround).
$modiconsenableconfig = get_config('theme_boost_union', 'modiconsenable');
if ($modiconsenableconfig == THEME_BOOST_UNION_SETTING_SELECT_YES &&
!empty(get_config('theme_boost_union', 'modiconsfiles'))) {
// Prepare the widget.
$name = 'theme_boost_union/modiconlist';
$title = get_string('modiconlistsetting', 'theme_boost_union', null, true);
$description = get_string('modiconlistsetting_desc', 'theme_boost_union', null, true);
// Append the file list to the description.
$templatecontext = ['files' => theme_boost_union_get_modicon_templatecontext()];
$description .= $OUTPUT->render_from_template('theme_boost_union/settings-modicon-filelist', $templatecontext);
// Finish the widget.
$setting = new admin_setting_description($name, $title, $description);
$tab->add($setting);
}
// Add tab to settings page.
$page->add($tab);
// Create login page tab.
$tab = new admin_settingpage('theme_boost_union_look_loginpage',
get_string('loginpagetab', 'theme_boost_union', null, true));
// Create login page background images heading.
$name = 'theme_boost_union/loginbackgroundimagesheading';
$title = get_string('loginbackgroundimagesheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Login page background image.
$name = 'theme_boost_union/loginbackgroundimage';
$title = get_string('loginbackgroundimage', 'theme_boost_union', null, true);
$description = get_string('loginbackgroundimage_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configstoredfile($name, $title, $description, 'loginbackgroundimage', 0,
['maxfiles' => 25, 'accepted_types' => 'web_image']);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: Login page background image position.
$name = 'theme_boost_union/loginbackgroundimageposition';
$title = get_string('loginbackgroundimagepositionsetting', 'theme_boost_union', null, true);
$description = get_string('loginbackgroundimagepositionsetting_desc', 'theme_boost_union', null, true);
$loginbackgroundimagepositionoptions = [
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_CENTER =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_CENTER,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_TOP =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_TOP,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_BOTTOM =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_BOTTOM,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_TOP =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_TOP,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_CENTER =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_CENTER,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_BOTTOM =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_BOTTOM,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_RIGHT_TOP =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_RIGHT_TOP,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_RIGHT_CENTER =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_RIGHT_CENTER,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_RIGHT_BOTTOM =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_RIGHT_BOTTOM, ];
$setting = new admin_setting_configselect($name, $title, $description,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_TOP, $loginbackgroundimagepositionoptions);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: Login page background image text.
$name = 'theme_boost_union/loginbackgroundimagetext';
$title = get_string('loginbackgroundimagetextsetting', 'theme_boost_union', null, true);
$description = get_string('loginbackgroundimagetextsetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configtextarea($name, $title, $description, null, PARAM_TEXT);
$tab->add($setting);
// Create login form heading.
$name = 'theme_boost_union/loginformheading';
$title = get_string('loginformheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Login form position.
$name = 'theme_boost_union/loginformposition';
$title = get_string('loginformpositionsetting', 'theme_boost_union', null, true);
$description = get_string('loginformpositionsetting_desc', 'theme_boost_union', null, true);
$loginformoptions = [
THEME_BOOST_UNION_SETTING_LOGINFORMPOS_CENTER => get_string('loginformpositionsetting_center', 'theme_boost_union'),
THEME_BOOST_UNION_SETTING_LOGINFORMPOS_LEFT => get_string('loginformpositionsetting_left', 'theme_boost_union'),
THEME_BOOST_UNION_SETTING_LOGINFORMPOS_RIGHT =>
get_string('loginformpositionsetting_right', 'theme_boost_union'), ];
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_LOGINFORMPOS_CENTER,
$loginformoptions);
$tab->add($setting);
// Setting: Login form transparency.
$name = 'theme_boost_union/loginformtransparency';
$title = get_string('loginformtransparencysetting', 'theme_boost_union', null, true);
$description = get_string('loginformtransparencysetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO, $yesnooption);
$tab->add($setting);
// Create login providers heading.
$name = 'theme_boost_union/loginprovidersheading';
$title = get_string('loginprovidersheading', 'theme_boost_union', null, true);
$notificationurl = new core\url('/admin/settings.php', ['section' => 'manageauths']);
$notificationsettingname = get_string('showloginform', 'core_auth');
$notification = new \core\output\notification(
get_string('loginprovidersheading_desc', 'theme_boost_union',
['settingname' => $notificationsettingname, 'url' => $notificationurl->out()]),
\core\output\notification::NOTIFY_INFO
);
$notification->set_show_closebutton(false);
$description = $OUTPUT->render($notification);
$setting = new admin_setting_heading($name, $title, $description);
$tab->add($setting);
// Setting: Local login.
$name = 'theme_boost_union/loginlocalloginenable';
$title = get_string('loginlocalloginenablesetting', 'theme_boost_union', null, true);
$localloginurl = new core\url('/theme/boost_union/locallogin.php');
$description = get_string('loginlocalloginenablesetting_desc', 'theme_boost_union', null, true).'<br /><br />'.
get_string('loginlocalloginenablesetting_note', 'theme_boost_union', ['url' => $localloginurl], true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_YES, $yesnooption);
$tab->add($setting);
// Setting: Local login intro.
$name = 'theme_boost_union/loginlocalshowintro';
$title = get_string('loginlocalshowintrosetting', 'theme_boost_union', null, true);
$description = get_string('loginlocalshowintrosetting_desc', 'theme_boost_union',
get_string('loginlocalintro', 'theme_boost_union'), true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO, $yesnooption);
$tab->add($setting);
$page->hide_if('theme_boost_union/loginlocalshowintro', 'theme_boost_union/loginlocalloginenable', 'neq',
THEME_BOOST_UNION_SETTING_SELECT_YES);
// Setting: IDP login intro.
$name = 'theme_boost_union/loginidpshowintro';
$title = get_string('loginidpshowintrosetting', 'theme_boost_union', null, true);
$description = get_string('loginidpshowintrosetting_desc', 'theme_boost_union', get_string('potentialidps', 'auth'), true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_YES, $yesnooption);
$tab->add($setting);
// Create login order heading.
$name = 'theme_boost_union/loginorderheading';
$title = get_string('loginorderheading', 'theme_boost_union', null, true);
$description = get_string('loginorderheading_desc', 'theme_boost_union', null, true).'<br /><br />'.
get_string('loginorderheading_note', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, $description);
$tab->add($setting);
// Create the login order settings without code duplication.
$loginmethods = theme_boost_union_get_loginpage_methods();
$loginmethodsoptions = [];
foreach ($loginmethods as $key => $lm) {
$loginmethodsoptions[$key] = $key;
}
foreach ($loginmethods as $key => $lm) {
$name = 'theme_boost_union/loginorder'.$lm;
$title = get_string('loginorder'.$lm.'setting', 'theme_boost_union', null, true);
$setting = new admin_setting_configselect($name, $title, null, $key, $loginmethodsoptions);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
}
// Add tab to settings page.
$page->add($tab);
// Create Dashboard / My courses tab.
$tab = new admin_settingpage('theme_boost_union_look_dashboard',
get_string('dashboardtab', 'theme_boost_union', null, true));
// Create Course overview block heading.
$name = 'theme_boost_union/courseoverviewheading';
$title = get_string('courseoverviewheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Prepare show course images options.
$showcourseimagesoptions = [
THEME_BOOST_UNION_SETTING_COURSEOVERVIEW_SHOWCOURSEIMAGES_CARD => get_string('card', 'block_myoverview'),
THEME_BOOST_UNION_SETTING_COURSEOVERVIEW_SHOWCOURSEIMAGES_LIST => get_string('list', 'block_myoverview'),
THEME_BOOST_UNION_SETTING_COURSEOVERVIEW_SHOWCOURSEIMAGES_SUMMARY => get_string('summary', 'block_myoverview'),
];
// Setting: Show course images.
$name = 'theme_boost_union/courseoverviewshowcourseimages';
$title = get_string('courseoverviewshowcourseimagessetting', 'theme_boost_union', null, true);
$description = get_string('courseoverviewshowcourseimagessetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configmulticheckbox($name, $title, $description, $showcourseimagesoptions,
$showcourseimagesoptions);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: Show course progress.
$name = 'theme_boost_union/courseoverviewshowcourseprogress';
$title = get_string('courseoverviewshowprogresssetting', 'theme_boost_union', null, true);
$description = get_string('courseoverviewshowprogresssetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_YES, $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_look_blocks',
get_string('blockstab', 'theme_boost_union', null, true));
// Create Timeline block heading.
$name = 'theme_boost_union/timelineheading';
$title = get_string('timelineheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Tint activity icons in the timeline block.
$name = 'theme_boost_union/timelinetintenabled';
$title = get_string('timelinetintenabled', 'theme_boost_union', null, true);
$description = get_string('timelinetintenabled_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);
// Create Upcoming events block heading.
$name = 'theme_boost_union/upcomingeventsheading';
$title = get_string('upcomingeventsheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Tint activity icons in the upcoming events block.
$name = 'theme_boost_union/upcomingeventstintenabled';
$title = get_string('upcomingeventstintenabled', 'theme_boost_union', null, true);
$description = get_string('upcomingeventstintenabled_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);
// Create Recently accessed items block heading.
$name = 'theme_boost_union/recentlyaccesseditemsheading';
$title = get_string('recentlyaccesseditemsheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Tint activity icons in the recently accessed items block.
$name = 'theme_boost_union/recentlyaccesseditemstintenabled';
$title = get_string('recentlyaccesseditemstintenabled', 'theme_boost_union', null, true);
$description = get_string('recentlyaccesseditemstintenabled_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);
// Create Activities block heading.
$name = 'theme_boost_union/activitiesheading';
$title = get_string('activitiesheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Tint activity icons in the activities block.
$name = 'theme_boost_union/activitiestintenabled';
$title = get_string('activitiestintenabled', 'theme_boost_union', null, true);
$description = get_string('activitiestintenabled_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 course tab.
$tab = new admin_settingpage('theme_boost_union_look_course',
get_string('coursetab', 'theme_boost_union', null, true));
// Create course header heading.
$name = 'theme_boost_union/courseheaderheading';
$title = get_string('courseheaderheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Setting: Display the course image in the course header.
$name = 'theme_boost_union/courseheaderimageenabled';
$title = get_string('courseheaderimageenabled', 'theme_boost_union', null, true);
$description = get_string('courseheaderimageenabled_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: Fallback course header image.
$name = 'theme_boost_union/courseheaderimagefallback';
$title = get_string('courseheaderimagefallback', 'theme_boost_union', null, true);
$description = get_string('courseheaderimagefallback_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configstoredfile($name, $title, $description, 'courseheaderimagefallback', 0,
['maxfiles' => 1, 'accepted_types' => 'web_image']);
$tab->add($setting);
$page->hide_if('theme_boost_union/courseheaderimagefallback', 'theme_boost_union/courseheaderimageenabled', 'neq',
THEME_BOOST_UNION_SETTING_SELECT_YES);
// Setting: Course header image layout.
$name = 'theme_boost_union/courseheaderimagelayout';
$title = get_string('courseheaderimagelayout', 'theme_boost_union', null, true);
$description = get_string('courseheaderimagelayout_desc', 'theme_boost_union', null, true);
$courseheaderimagelayoutoptions = [
THEME_BOOST_UNION_SETTING_COURSEIMAGELAYOUT_STACKEDDARK =>
get_string('courseheaderimagelayoutstackeddark', 'theme_boost_union'),
THEME_BOOST_UNION_SETTING_COURSEIMAGELAYOUT_STACKEDLIGHT =>
get_string('courseheaderimagelayoutstackedlight', 'theme_boost_union'),
THEME_BOOST_UNION_SETTING_COURSEIMAGELAYOUT_HEADINGABOVE =>
get_string('courseheaderimagelayoutheadingabove', 'theme_boost_union'), ];
$setting = new admin_setting_configselect($name, $title, $description,
THEME_BOOST_UNION_SETTING_COURSEIMAGELAYOUT_HEADINGABOVE, $courseheaderimagelayoutoptions);
$tab->add($setting);
$page->hide_if('theme_boost_union/courseheaderimagelayout', 'theme_boost_union/courseheaderimageenabled', 'neq',
THEME_BOOST_UNION_SETTING_SELECT_YES);
// Setting: Course header image height.
$name = 'theme_boost_union/courseheaderimageheight';
$title = get_string('courseheaderimageheight', 'theme_boost_union', null, true);
$description = get_string('courseheaderimageheight_desc', 'theme_boost_union', null, true);
$courseheaderimageheightoptions = [
THEME_BOOST_UNION_SETTING_HEIGHT_100PX => THEME_BOOST_UNION_SETTING_HEIGHT_100PX,
THEME_BOOST_UNION_SETTING_HEIGHT_150PX => THEME_BOOST_UNION_SETTING_HEIGHT_150PX,
THEME_BOOST_UNION_SETTING_HEIGHT_200PX => THEME_BOOST_UNION_SETTING_HEIGHT_200PX,
THEME_BOOST_UNION_SETTING_HEIGHT_250PX => THEME_BOOST_UNION_SETTING_HEIGHT_250PX, ];
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_HEIGHT_150PX,
$courseheaderimageheightoptions);
$tab->add($setting);
$page->hide_if('theme_boost_union/courseheaderimageheight', 'theme_boost_union/courseheaderimageenabled', 'neq',
THEME_BOOST_UNION_SETTING_SELECT_YES);
// Setting: Course header image position.
$name = 'theme_boost_union/courseheaderimageposition';
$title = get_string('courseheaderimageposition', 'theme_boost_union', null, true);
$description = get_string('courseheaderimageposition_desc', 'theme_boost_union', null, true);
$courseheaderimagepositionoptions = [
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_CENTER =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_CENTER,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_TOP =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_TOP,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_BOTTOM =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_CENTER_BOTTOM,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_TOP =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_TOP,
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_CENTER =>
THEME_BOOST_UNION_SETTING_IMAGEPOSITION_LEFT_CENTER,