| 1441 |
ariadna |
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.
|
|
|
13 |
//
|
|
|
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/>.
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
*
|
|
|
19 |
* @package theme_universe
|
|
|
20 |
* @copyright Copyright © 2021 onwards Marcin Czaja (https://rosea.io)
|
|
|
21 |
* @license Commercial https://themeforest.net/licenses
|
|
|
22 |
*
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
defined('MOODLE_INTERNAL') || die();
|
|
|
27 |
$page = new admin_settingpage('theme_universe_fontcustomization', get_string('settingsfontcustomization', 'theme_universe'));
|
|
|
28 |
|
|
|
29 |
$name = 'theme_universe/fontbody';
|
|
|
30 |
$title = get_string('fontbody', 'theme_universe');
|
|
|
31 |
$description = get_string('fontbody_desc', 'theme_universe');
|
|
|
32 |
$default = "'Inter', sans-serif";
|
|
|
33 |
$setting = new admin_setting_configtext($name, $title, $description, $default);
|
|
|
34 |
$setting->set_updatedcallback('theme_reset_all_caches');
|
|
|
35 |
$page->add($setting);
|
|
|
36 |
|
|
|
37 |
$name = 'theme_universe/fontweightregular';
|
|
|
38 |
$title = get_string('fontweightregular', 'theme_universe');
|
|
|
39 |
$description = get_string('fontweightregular_desc', 'theme_universe');
|
|
|
40 |
$default = '400';
|
|
|
41 |
$setting = new admin_setting_configtext($name, $title, $description, $default);
|
|
|
42 |
$setting->set_updatedcallback('theme_reset_all_caches');
|
|
|
43 |
$page->add($setting);
|
|
|
44 |
|
|
|
45 |
$name = 'theme_universe/fontweightmedium';
|
|
|
46 |
$title = get_string('fontweightmedium', 'theme_universe');
|
|
|
47 |
$description = get_string('fontweightmedium_desc', 'theme_universe');
|
|
|
48 |
$default = '500';
|
|
|
49 |
$setting = new admin_setting_configtext($name, $title, $description, $default);
|
|
|
50 |
$setting->set_updatedcallback('theme_reset_all_caches');
|
|
|
51 |
$page->add($setting);
|
|
|
52 |
|
|
|
53 |
$name = 'theme_universe/fontweightbold';
|
|
|
54 |
$title = get_string('fontweightbold', 'theme_universe');
|
|
|
55 |
$description = get_string('fontweightbold_desc', 'theme_universe');
|
|
|
56 |
$default = '700';
|
|
|
57 |
$setting = new admin_setting_configtext($name, $title, $description, $default);
|
|
|
58 |
$setting->set_updatedcallback('theme_reset_all_caches');
|
|
|
59 |
$page->add($setting);
|
|
|
60 |
|
|
|
61 |
$name = 'theme_universe/fontweightheadings';
|
|
|
62 |
$title = get_string('fontweightheadings', 'theme_universe');
|
|
|
63 |
$description = get_string('fontweightheadings_desc', 'theme_universe');
|
|
|
64 |
$default = '700';
|
|
|
65 |
$setting = new admin_setting_configtext($name, $title, $description, $default);
|
|
|
66 |
$setting->set_updatedcallback('theme_reset_all_caches');
|
|
|
67 |
$page->add($setting);
|
|
|
68 |
|
|
|
69 |
// Google Font.
|
|
|
70 |
$name = 'theme_universe/hgooglefont';
|
|
|
71 |
$heading = get_string('hgooglefont', 'theme_universe');
|
|
|
72 |
$setting = new admin_setting_heading($name, $heading, format_text(get_string('hgooglefont_desc', 'theme_universe'), FORMAT_MARKDOWN));
|
|
|
73 |
$page->add($setting);
|
|
|
74 |
|
|
|
75 |
// Google Font.
|
|
|
76 |
$name = 'theme_universe/googlefonturl';
|
|
|
77 |
$title = get_string('googlefonturl', 'theme_universe');
|
|
|
78 |
$description = get_string('googlefonturl_desc', 'theme_universe');
|
|
|
79 |
$default = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap';
|
|
|
80 |
$setting = new admin_setting_configtextarea($name, $title, $description, $default);
|
|
|
81 |
$page->add($setting);
|
|
|
82 |
|
|
|
83 |
// Font files upload.
|
|
|
84 |
// Register the webfonts file types for filtering the uploads in the subsequent admin settings.
|
|
|
85 |
// This function call may return false. In this case, the filetypes were not registered and we
|
|
|
86 |
// can't restrict the filetypes in the subsequent admin settings unfortunately.
|
|
|
87 |
$name = 'theme_universe/hcustomfont';
|
|
|
88 |
$heading = get_string('hcustomfont', 'theme_universe');
|
|
|
89 |
$setting = new admin_setting_heading($name, $heading, format_text(get_string('hcustomfont_desc', 'theme_universe'), FORMAT_MARKDOWN));
|
|
|
90 |
$page->add($setting);
|
|
|
91 |
|
|
|
92 |
$registerfontsresult = theme_universe_register_webfonts_filetypes();
|
|
|
93 |
|
|
|
94 |
// Setting: Custom fonts.
|
|
|
95 |
$name = 'theme_universe/fontfiles';
|
|
|
96 |
$title = get_string('fontfilessetting', 'theme_universe', null, true);
|
|
|
97 |
$description = get_string('fontfilessetting_desc', 'theme_universe', null, true);
|
|
|
98 |
if ($registerfontsresult == true) {
|
|
|
99 |
$setting = new admin_setting_configstoredfile($name, $title, $description, 'fontfiles', 0,
|
|
|
100 |
['maxfiles' => -1, 'accepted_types' => theme_universe_get_webfonts_extensions()]);
|
|
|
101 |
} else {
|
|
|
102 |
$setting = new admin_setting_configstoredfile($name, $title, $description, 'fontfiles', 0,
|
|
|
103 |
['maxfiles' => -1]);
|
|
|
104 |
}
|
|
|
105 |
$page->add($setting);
|
|
|
106 |
|
|
|
107 |
// Information: Custom fonts list.
|
|
|
108 |
// If there is at least one file uploaded.
|
|
|
109 |
if (!empty(get_config('theme_universe', 'fontfiles'))) {
|
|
|
110 |
// Prepare the widget.
|
|
|
111 |
$name = 'theme_universe/customfontslist';
|
|
|
112 |
$title = get_string('customfontslistsetting', 'theme_universe', null, true);
|
|
|
113 |
$description = get_string('customfontslistsetting_desc', 'theme_universe', null, true);
|
|
|
114 |
|
|
|
115 |
// Append the file list to the description.
|
|
|
116 |
$templatecontext = ['files' => theme_universe_get_customfonts_templatecontext()];
|
|
|
117 |
$description .= $OUTPUT->render_from_template('theme_universe/settings-customfonts-filelist', $templatecontext);
|
|
|
118 |
|
|
|
119 |
// Finish the widget.
|
|
|
120 |
$setting = new admin_setting_description($name, $title, $description);
|
|
|
121 |
$page->add($setting);
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
$settings->add($page);
|