Proyectos de Subversion Moodle

Rev

Rev 1382 | Ir a la última revisión | | 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
    // Include inherited settings
22
    require_once(__DIR__ . '/settings/inherit_settings.php');
1380 ariadna 23
 
1383 ariadna 24
    // Child theme specific settings
25
    $page = new admin_settingpage('theme_universe_child_specific', get_string('childthemesettings', 'theme_universe_child'));
26
 
1380 ariadna 27
    // Replicate the preset setting from boost.
28
    $name = 'theme_universe_child/preset';
29
    $title = get_string('preset', 'theme_universe_child');
30
    $description = get_string('preset_desc', 'theme_universe_child');
31
    $default = 'default.scss';
32
 
33
    // We list files in our own file area to add to the drop down. We will provide our own function to
34
    // load all the presets from the correct paths.
35
    $context = context_system::instance();
36
    $fs = get_file_storage();
37
    $files = $fs->get_area_files($context->id, 'theme_universe_child', 'preset', 0, 'itemid, filepath, filename', false);
38
 
39
    $choices = [];
40
    foreach ($files as $file) {
41
        $choices[$file->get_filename()] = $file->get_filename();
42
    }
43
    // These are the built in presets from Boost.
44
    $choices['default.scss'] = 'default.scss';
45
    $choices['plain.scss'] = 'plain.scss';
46
 
47
    $setting = new admin_setting_configselect($name, $title, $description, $default, $choices);
48
    $setting->set_updatedcallback('theme_reset_all_caches');
49
    $page->add($setting);
50
 
51
    // Preset files setting.
52
    $name = 'theme_universe_child/presetfiles';
53
    $title = get_string('presetfiles', 'theme_universe_child');
54
    $description = get_string('presetfiles_desc', 'theme_universe_child');
55
 
56
    $setting = new admin_setting_configstoredfile(
57
        $name,
58
        $title,
59
        $description,
60
        'preset',
61
        0,
62
        array('maxfiles' => 20, 'accepted_types' => array('.scss'))
63
    );
64
    $page->add($setting);
65
 
66
    // Variable $brand-color.
67
    // We use an empty default value because the default colour should come from the preset.
68
    $name = 'theme_universe_child/brandcolor';
69
    $title = get_string('brandcolor', 'theme_universe_child');
70
    $description = get_string('brandcolor_desc', 'theme_universe_child');
71
    $setting = new admin_setting_configcolourpicker($name, $title, $description, '');
72
    $setting->set_updatedcallback('theme_reset_all_caches');
73
    $page->add($setting);
74
 
1383 ariadna 75
    // Raw SCSS to include before the content.
76
    $setting = new admin_setting_configtextarea(
77
        'theme_universe_child/scsspre',
78
        get_string('rawscsspre', 'theme_universe_child'),
79
        get_string('rawscsspre_desc', 'theme_universe_child'),
80
        '',
81
        PARAM_RAW
82
    );
83
    $setting->set_updatedcallback('theme_reset_all_caches');
84
    $page->add($setting);
85
 
86
    // Raw SCSS to include after the content.
87
    $setting = new admin_setting_configtextarea(
88
        'theme_universe_child/scss',
89
        get_string('rawscss', 'theme_universe_child'),
90
        get_string('rawscss_desc', 'theme_universe_child'),
91
        '',
92
        PARAM_RAW
93
    );
94
    $setting->set_updatedcallback('theme_reset_all_caches');
95
    $page->add($setting);
96
 
1380 ariadna 97
    $settings->add($page);
98
 
99
    // Advanced settings.
100
    $page = new admin_settingpage('theme_universe_child_advanced', get_string('advancedsettings', 'theme_universe_child'));
101
 
102
    // Raw SCSS to include before the content.
103
    $setting = new admin_setting_configtextarea(
104
        'theme_universe_child/scsspre',
105
        get_string('rawscsspre', 'theme_universe_child'),
106
        get_string('rawscsspre_desc', 'theme_universe_child'),
107
        '',
108
        PARAM_RAW
109
    );
110
    $setting->set_updatedcallback('theme_reset_all_caches');
111
    $page->add($setting);
112
 
113
    // Raw SCSS to include after the content.
114
    $setting = new admin_setting_configtextarea(
115
        'theme_universe_child/scss',
116
        get_string('rawscss', 'theme_universe_child'),
117
        get_string('rawscss_desc', 'theme_universe_child'),
118
        '',
119
        PARAM_RAW
120
    );
121
    $setting->set_updatedcallback('theme_reset_all_caches');
122
    $page->add($setting);
123
 
124
    $settings->add($page);
125
}