-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsettings.php
131 lines (108 loc) · 5.64 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
<?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/>.
/**
* @package theme_bengal
* @copyright 2022 Max MacCluer
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
if ($ADMIN->fulltree) {
require_once($CFG->dirroot . '/theme/bengal/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 = array(THEME_BENGAL_SETTING_SELECT_YES => get_string('yes'),
THEME_BENGAL_SETTING_SELECT_NO => get_string('no'));
$settings = new theme_boost_admin_settingspage_tabs('themesettingbengal', get_string('configtitle', 'theme_bengal'));
$page = new admin_settingpage('theme_bengal_general', get_string('generalsettings', 'theme_bengal'));
// Unaddable blocks.
// Blocks to be excluded when this theme is enabled in the "Add a block" list: Administration, Navigation, Courses and
// Section links.
$default = 'navigation,settings,course_list,section_links';
$setting = new admin_setting_configtext('theme_bengal/unaddableblocks',
get_string('unaddableblocks', 'theme_bengal'), get_string('unaddableblocks_desc', 'theme_bengal'), $default, PARAM_TEXT);
$page->add($setting);
// Setting: scroll-spy.
$name = 'theme_bengal/scrollspy';
$title = get_string('scrollspysetting', 'theme_bengal', null, true);
$description = get_string('scrollspysetting_desc', 'theme_bengal', null, true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BENGAL_SETTING_SELECT_NO, $yesnooption);
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Preset.
$name = 'theme_bengal/preset';
$title = get_string('preset', 'theme_bengal');
$description = get_string('preset_desc', 'theme_bengal');
$default = 'default.scss';
$context = context_system::instance();
$fs = get_file_storage();
$files = $fs->get_area_files($context->id, 'theme_bengal', 'preset', 0, 'itemid, filepath, filename', false);
$choices = [];
foreach ($files as $file) {
$choices[$file->get_filename()] = $file->get_filename();
}
// These are the built in presets.
$choices['default.scss'] = 'default.scss';
$choices['plain.scss'] = 'plain.scss';
$setting = new admin_setting_configthemepreset($name, $title, $description, $default, $choices, 'bengal');
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Preset files setting.
$name = 'theme_bengal/presetfiles';
$title = get_string('presetfiles','theme_bengal');
$description = get_string('presetfiles_desc', 'theme_bengal');
$setting = new admin_setting_configstoredfile($name, $title, $description, 'preset', 0,
array('maxfiles' => 20, 'accepted_types' => array('.scss')));
$page->add($setting);
/*
// Background image setting.
$name = 'theme_bengal/backgroundimage';
$title = get_string('backgroundimage', 'theme_bengal');
$description = get_string('backgroundimage_desc', 'theme_bengal');
$setting = new admin_setting_configstoredfile($name, $title, $description, 'backgroundimage');
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Login Background image setting.
$name = 'theme_bengal/loginbackgroundimage';f
$title = get_string('loginbackgroundimage', 'theme_bengal');
$description = get_string('loginbackgroundimage_desc', 'theme_bengal');
$setting = new admin_setting_configstoredfile($name, $title, $description, 'loginbackgroundimage');
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Variable $body-color.
// We use an empty default value because the default colour should come from the preset.
$name = 'theme_bengal/brandcolor';
$title = get_string('brandcolor', 'theme_bengal');
$description = get_string('brandcolor_desc', 'theme_bengal');
$setting = new admin_setting_configcolourpicker($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
*/
// Must add the page after definiting all the settings!
$settings->add($page);
// Advanced settings.
$page = new admin_settingpage('theme_bengal_advanced', get_string('advancedsettings', 'theme_bengal'));
// Raw SCSS to include before the content.
$setting = new admin_setting_scsscode('theme_bengal/scsspre',
get_string('rawscsspre', 'theme_bengal'), get_string('rawscsspre_desc', 'theme_bengal'), '', PARAM_RAW);
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Raw SCSS to include after the content.
$setting = new admin_setting_scsscode('theme_bengal/scss', get_string('rawscss', 'theme_bengal'),
get_string('rawscss_desc', 'theme_bengal'), '', PARAM_RAW);
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
$settings->add($page);
}