Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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_monocolor
20
 * @copyright 2022 - 2023 Marcin Czaja (https://rosea.io)
21
 * @license   Commercial https://themeforest.net/licenses
22
 *
23
 */
24
 
25
 
26
defined('MOODLE_INTERNAL') || die();
27
 
28
// Advanced settings.
29
$page = new admin_settingpage(
30
    'theme_monocolor_advanced',
31
    get_string('advancedsettings', 'theme_monocolor')
32
);
33
 
34
// H5P custom CSS.
35
$setting = new admin_setting_configtextarea(
36
    'theme_monocolor/hvpcss',
37
    get_string('hvpcss', 'theme_monocolor'),
38
    get_string('hvpcss_desc', 'theme_monocolor'), '');
39
$page->add($setting);
40
 
41
// Raw SCSS to include before the content.
42
$setting = new admin_setting_scsscode(
43
    'theme_monocolor/scsspre',
44
    get_string('rawscsspre', 'theme_monocolor'),
45
    get_string('rawscsspre_desc', 'theme_monocolor'),
46
    '',
47
    PARAM_RAW
48
);
49
$setting->set_updatedcallback('theme_reset_all_caches');
50
$page->add($setting);
51
 
52
// Raw SCSS to include after the content.
53
$setting = new admin_setting_scsscode(
54
    'theme_monocolor/scss',
55
    get_string('rawscss', 'theme_monocolor'),
56
    get_string('rawscss_desc', 'theme_monocolor'),
57
    '',
58
    PARAM_RAW
59
);
60
$setting->set_updatedcallback('theme_reset_all_caches');
61
$page->add($setting);
62
 
63
// Register the webfonts file types for filtering the uploads in the subsequent admin settings.
64
// This function call may return false. In this case, the filetypes were not registered and we
65
// can't restrict the filetypes in the subsequent admin settings unfortunately.
66
$registerfontsresult = theme_monocolor_register_webfonts_filetypes();
67
 
68
// Font files upload.
69
// Setting: Custom fonts.
70
$name = 'theme_monocolor/fontfiles';
71
$title = get_string('customfontssetting', 'theme_monocolor', null, true);
72
$description = get_string('customfontssetting_desc', 'theme_monocolor', null, true);
73
if ($registerfontsresult == true) {
74
    $setting = new admin_setting_configstoredfile($name, $title, $description, 'fontfiles', 0,
75
            ['maxfiles' => -1, 'accepted_types' => theme_monocolor_get_webfonts_extensions()]);
76
} else {
77
    $setting = new admin_setting_configstoredfile($name, $title, $description, 'fontfiles', 0,
78
            ['maxfiles' => -1]);
79
}
80
$page->add($setting);
81
 
82
// Information: Custom fonts list.
83
// Credits: Boost_Union
84
// If there is at least one file uploaded.
85
if (!empty(get_config('theme_monocolor', 'fontfiles'))) {
86
    // Prepare the widget.
87
    $name = 'theme_monocolor/customfontslist';
88
    $title = get_string('customfontslistsetting', 'theme_monocolor', null, true);
89
    $description = get_string('customfontslistsetting_desc', 'theme_monocolor', null, true);
90
 
91
    // Append the file list to the description.
92
    $templatecontext = ['files' => theme_monocolor_get_customfonts_templatecontext()];
93
    $description .= $OUTPUT->render_from_template('theme_monocolor/settings-customfonts-filelist', $templatecontext);
94
 
95
    // Finish the widget.
96
    $setting = new admin_setting_description($name, $title, $description);
97
    $page->add($setting);
98
}
99
 
100
$settings->add($page);