Proyectos de Subversion Moodle

Rev

Rev 1383 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1380 ariadna 1
<?php
2
 
3
// Every file should have GPL and copyright in the header - we skip it in tutorials but you should not skip it for real.
4
 
5
// This line protects the file from being accessed by a URL directly.
6
defined('MOODLE_INTERNAL') || die();
1383 ariadna 7
require_once(__DIR__ . '/../universe/libs/admin_confightmleditor.php');
8
require_once($CFG->dirroot . '/theme/universe/lib.php');
9
 
1380 ariadna 10
$siteurl = $CFG->wwwroot;
11
$a = new stdClass;
12
$a->siteurl = $siteurl;
13
 
14
// This is used for performance, we don't need to know about these settings on every page in Moodle, only when
15
// we are looking at the admin settings pages.
16
if ($ADMIN->fulltree) {
17
 
18
    // Boost provides a nice setting page which splits settings onto separate tabs. We want to use it here.
19
    $settings = new theme_universe_admin_settingspage_tabs('themesettinguniverse_child', get_string('configtitle', 'theme_universe_child'));
20
 
1383 ariadna 21
    // Child theme specific settings
22
    $page = new admin_settingpage('theme_universe_child_specific', get_string('childthemesettings', 'theme_universe_child'));
23
 
1380 ariadna 24
    // Replicate the preset setting from boost.
25
    $name = 'theme_universe_child/preset';
26
    $title = get_string('preset', 'theme_universe_child');
27
    $description = get_string('preset_desc', 'theme_universe_child');
28
    $default = 'default.scss';
29
 
30
    // We list files in our own file area to add to the drop down. We will provide our own function to
31
    // load all the presets from the correct paths.
32
    $context = context_system::instance();
33
    $fs = get_file_storage();
34
    $files = $fs->get_area_files($context->id, 'theme_universe_child', 'preset', 0, 'itemid, filepath, filename', false);
35
 
36
    $choices = [];
37
    foreach ($files as $file) {
38
        $choices[$file->get_filename()] = $file->get_filename();
39
    }
40
    // These are the built in presets from Boost.
41
    $choices['default.scss'] = 'default.scss';
42
    $choices['plain.scss'] = 'plain.scss';
43
 
44
    $setting = new admin_setting_configselect($name, $title, $description, $default, $choices);
45
    $setting->set_updatedcallback('theme_reset_all_caches');
46
    $page->add($setting);
47
 
48
    // Preset files setting.
49
    $name = 'theme_universe_child/presetfiles';
50
    $title = get_string('presetfiles', 'theme_universe_child');
51
    $description = get_string('presetfiles_desc', 'theme_universe_child');
52
 
53
    $setting = new admin_setting_configstoredfile(
54
        $name,
55
        $title,
56
        $description,
57
        'preset',
58
        0,
59
        array('maxfiles' => 20, 'accepted_types' => array('.scss'))
60
    );
61
    $page->add($setting);
62
 
63
    // Variable $brand-color.
64
    // We use an empty default value because the default colour should come from the preset.
65
    $name = 'theme_universe_child/brandcolor';
66
    $title = get_string('brandcolor', 'theme_universe_child');
67
    $description = get_string('brandcolor_desc', 'theme_universe_child');
68
    $setting = new admin_setting_configcolourpicker($name, $title, $description, '');
69
    $setting->set_updatedcallback('theme_reset_all_caches');
70
    $page->add($setting);
71
 
1383 ariadna 72
    // Raw SCSS to include before the content.
73
    $setting = new admin_setting_configtextarea(
74
        'theme_universe_child/scsspre',
75
        get_string('rawscsspre', 'theme_universe_child'),
76
        get_string('rawscsspre_desc', 'theme_universe_child'),
77
        '',
78
        PARAM_RAW
79
    );
80
    $setting->set_updatedcallback('theme_reset_all_caches');
81
    $page->add($setting);
82
 
83
    // Raw SCSS to include after the content.
84
    $setting = new admin_setting_configtextarea(
85
        'theme_universe_child/scss',
86
        get_string('rawscss', 'theme_universe_child'),
87
        get_string('rawscss_desc', 'theme_universe_child'),
88
        '',
89
        PARAM_RAW
90
    );
91
    $setting->set_updatedcallback('theme_reset_all_caches');
92
    $page->add($setting);
93
 
1380 ariadna 94
    $settings->add($page);
95
 
96
    // Advanced settings.
97
    $page = new admin_settingpage('theme_universe_child_advanced', get_string('advancedsettings', 'theme_universe_child'));
98
 
99
    // Raw SCSS to include before the content.
100
    $setting = new admin_setting_configtextarea(
101
        'theme_universe_child/scsspre',
102
        get_string('rawscsspre', 'theme_universe_child'),
103
        get_string('rawscsspre_desc', 'theme_universe_child'),
104
        '',
105
        PARAM_RAW
106
    );
107
    $setting->set_updatedcallback('theme_reset_all_caches');
108
    $page->add($setting);
109
 
110
    // Raw SCSS to include after the content.
111
    $setting = new admin_setting_configtextarea(
112
        'theme_universe_child/scss',
113
        get_string('rawscss', 'theme_universe_child'),
114
        get_string('rawscss_desc', 'theme_universe_child'),
115
        '',
116
        PARAM_RAW
117
    );
118
    $setting->set_updatedcallback('theme_reset_all_caches');
119
    $page->add($setting);
120
 
121
    $settings->add($page);
122
}