Merge branch 'MDL-59303' of https://github.com/paulholden/moodle
[moodle.git] / theme / classic / settings.php
blob97619800db9736b0c43b27c010c67f1aaeab6d22
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Classic theme settings file.
20 * @package theme_classic
21 * @copyright 2018 Bas Brands
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 defined('MOODLE_INTERNAL') || die;
26 if ($ADMIN->fulltree) {
28 $settings = new theme_boost_admin_settingspage_tabs('themesettingclassic', get_string('configtitle', 'theme_classic'));
29 $page = new admin_settingpage('theme_classic_general', get_string('generalsettings', 'theme_boost'));
31 $name = 'theme_classic/navbardark';
32 $title = get_string('navbardark', 'theme_classic');
33 $description = get_string('navbardarkdesc', 'theme_classic');
34 $setting = new admin_setting_configcheckbox($name, $title, $description, 0);
35 $setting->set_updatedcallback('theme_reset_all_caches');
36 $page->add($setting);
38 // Preset.
39 $name = 'theme_classic/preset';
40 $title = get_string('preset', 'theme_classic');
41 $description = get_string('preset_desc', 'theme_classic');
42 $default = 'default.scss';
44 $context = context_system::instance();
45 $fs = get_file_storage();
46 $files = $fs->get_area_files($context->id, 'theme_classic', 'preset', 0, 'itemid, filepath, filename', false);
48 $choices = [];
49 foreach ($files as $file) {
50 $choices[$file->get_filename()] = $file->get_filename();
53 // These are the built in presets.
54 $choices['default.scss'] = 'default.scss';
55 $choices['plain.scss'] = 'plain.scss';
57 $setting = new admin_setting_configthemepreset($name, $title, $description, $default, $choices, 'classic');
58 $setting->set_updatedcallback('theme_reset_all_caches');
59 $page->add($setting);
61 // Preset files setting.
62 $name = 'theme_classic/presetfiles';
63 $title = get_string('presetfiles', 'theme_classic');
64 $description = get_string('presetfiles_desc', 'theme_classic');
66 $setting = new admin_setting_configstoredfile($name, $title, $description, 'preset', 0,
67 array('maxfiles' => 20, 'accepted_types' => array('.scss')));
68 $page->add($setting);
70 // Background image setting.
71 $name = 'theme_classic/backgroundimage';
72 $title = get_string('backgroundimage', 'theme_boost');
73 $description = get_string('backgroundimage_desc', 'theme_boost');
74 $setting = new admin_setting_configstoredfile($name, $title, $description, 'backgroundimage');
75 $setting->set_updatedcallback('theme_reset_all_caches');
76 $page->add($setting);
78 // Variable $body-color.
79 // We use an empty default value because the default colour should come from the preset.
80 $name = 'theme_classic/brandcolor';
81 $title = get_string('brandcolor', 'theme_boost');
82 $description = get_string('brandcolor_desc', 'theme_boost');
83 $setting = new admin_setting_configcolourpicker($name, $title, $description, '');
84 $setting->set_updatedcallback('theme_reset_all_caches');
85 $page->add($setting);
87 // Must add the page after definiting all the settings!
88 $settings->add($page);
90 // Advanced settings.
91 $page = new admin_settingpage('theme_classic_advanced', get_string('advancedsettings', 'theme_boost'));
93 // Raw SCSS to include before the content.
94 $setting = new admin_setting_scsscode('theme_classic/scsspre',
95 get_string('rawscsspre', 'theme_boost'), get_string('rawscsspre_desc', 'theme_boost'), '', PARAM_RAW);
96 $setting->set_updatedcallback('theme_reset_all_caches');
97 $page->add($setting);
99 // Raw SCSS to include after the content.
100 $setting = new admin_setting_scsscode('theme_classic/scss', get_string('rawscss', 'theme_boost'),
101 get_string('rawscss_desc', 'theme_boost'), '', PARAM_RAW);
102 $setting->set_updatedcallback('theme_reset_all_caches');
103 $page->add($setting);
105 $settings->add($page);