-
Notifications
You must be signed in to change notification settings - Fork 5
/
settings.php
126 lines (106 loc) · 6.43 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
<?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 Child - Settings file
*
* @package theme_boost_union_child
* @copyright 2023 Daniel Poggenpohl <[email protected]> and Alexander Bias <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
if ($hassiteconfig || has_capability('theme/boost_union:configure', context_system::instance())) {
// How this file works:
// Boost Union's settings are divided into multiple settings pages which resides in its own settings category.
// You will understand it as soon as you look at /theme/boost_union/settings.php.
// This settings file here is built in a way that it adds another settings page to this existing settings
// category. You can add all child-theme-specific settings to this settings page here.
// 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 Child" 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_child']);
if ($ADMIN->fulltree && $PAGE->has_set_url() && $PAGE->url->compare($mainsettingspageurl)) {
redirect(new \core\url('/admin/settings.php', ['section' => 'theme_boost_union_child']));
}
// Create empty settings page structure to make the site administration work on non-admin pages.
if (!$ADMIN->fulltree) {
// Create Boost Union Child settings page
// (and allow users with the theme/boost_union:configure capability to access it).
$tab = new admin_settingpage('theme_boost_union_child',
get_string('configtitle', 'theme_boost_union_child', null, true),
'theme/boost_union:configure');
$ADMIN->add('theme_boost_union', $tab);
}
// Create full settings page structure.
// phpcs:disable moodle.ControlStructures.ControlSignature.Found
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');
require_once($CFG->dirroot . '/theme/boost_union_child/lib.php');
require_once($CFG->dirroot . '/theme/boost_union_child/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 = [THEME_BOOST_UNION_SETTING_SELECT_YES => get_string('yes'),
THEME_BOOST_UNION_SETTING_SELECT_NO => get_string('no'), ];
// Create Boost Union Child 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_child',
get_string('configtitle', 'theme_boost_union_child', null, true),
'theme/boost_union:configure');
// Create general settings tab.
$tab = new admin_settingpage('theme_boost_union_child_general',
get_string('generalsettings', 'theme_boost', null, true));
// Create inheritance heading.
$name = 'theme_boost_union_child/inheritanceheading';
$title = get_string('inheritanceheading', 'theme_boost_union_child', null, true);
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);
// Prepare inheritance options.
$inheritanceoptions = [
THEME_BOOST_UNION_CHILD_SETTING_INHERITANCE_INHERIT =>
get_string('inheritanceinherit', 'theme_boost_union_child'),
THEME_BOOST_UNION_CHILD_SETTING_INHERITANCE_DUPLICATE =>
get_string('inheritanceduplicate', 'theme_boost_union_child'),
];
// Setting: Pre SCSS inheritance setting.
$name = 'theme_boost_union_child/prescssinheritance';
$title = get_string('prescssinheritancesetting', 'theme_boost_union_child', null, true);
$description = get_string('prescssinheritancesetting_desc', 'theme_boost_union_child', null, true).'<br />'.
get_string('inheritanceoptionsexplanation', 'theme_boost_union_child', null, true);
$setting = new admin_setting_configselect($name, $title, $description,
THEME_BOOST_UNION_CHILD_SETTING_INHERITANCE_INHERIT, $inheritanceoptions);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Setting: Extra SCSS inheritance setting.
$name = 'theme_boost_union_child/extrascssinheritance';
$title = get_string('extrascssinheritancesetting', 'theme_boost_union_child', null, true);
$description = get_string('extrascssinheritancesetting_desc', 'theme_boost_union_child', null, true).'<br />'.
get_string('inheritanceoptionsexplanation', 'theme_boost_union_child', null, true);
$setting = new admin_setting_configselect($name, $title, $description,
THEME_BOOST_UNION_CHILD_SETTING_INHERITANCE_INHERIT, $inheritanceoptions);
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
// Add tab to settings page.
$page->add($tab);
/**********************************************************
* EXTENSION POINT:
* Add your Boost Union Child settings here.
*********************************************************/
// Add settings page to the admin settings category.
$ADMIN->add('theme_boost_union', $page);
}
}