Proyectos de Subversion Moodle

Rev

Rev 1355 | Rev 1357 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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.
1335 ariadna 6
defined('MOODLE_INTERNAL') || die();
7
 
1 efrain 8
// This is used for performance, we don't need to know about these settings on every page in Moodle, only when
9
// we are looking at the admin settings pages.
1335 ariadna 10
if ($ADMIN->fulltree) {
11
 
1 efrain 12
    // Boost provides a nice setting page which splits settings onto separate tabs. We want to use it here.
1356 ariadna 13
    $settings = new theme_universe_admin_settingspage_tabs('themesettinguniverse_child', get_string('configtitle', 'theme_universe_child'));
1344 ariadna 14
 
1356 ariadna 15
 
1344 ariadna 16
    // Each page is a tab - the first is the "General" tab.
17
    $page = new admin_settingpage('theme_universe_child_general', get_string('generalsettings', 'theme_universe_child'));
18
 
19
    // Replicate the preset setting from boost.
20
    $name = 'theme_universe_child/preset';
21
    $title = get_string('preset', 'theme_universe_child');
22
    $description = get_string('preset_desc', 'theme_universe_child');
23
    $default = 'default.scss';
24
 
25
    // We list files in our own file area to add to the drop down. We will provide our own function to
26
    // load all the presets from the correct paths.
27
    $context = context_system::instance();
28
    $fs = get_file_storage();
29
    $files = $fs->get_area_files($context->id, 'theme_universe_child', 'preset', 0, 'itemid, filepath, filename', false);
30
 
31
    $choices = [];
32
    foreach ($files as $file) {
33
        $choices[$file->get_filename()] = $file->get_filename();
34
    }
35
    // These are the built in presets from Boost.
36
    $choices['default.scss'] = 'default.scss';
37
    $choices['plain.scss'] = 'plain.scss';
38
 
39
    $setting = new admin_setting_configselect($name, $title, $description, $default, $choices);
40
    $setting->set_updatedcallback('theme_reset_all_caches');
41
    $page->add($setting);
42
 
43
    // Preset files setting.
44
    $name = 'theme_universe_child/presetfiles';
45
    $title = get_string('presetfiles', 'theme_universe_child');
46
    $description = get_string('presetfiles_desc', 'theme_universe_child');
47
 
48
    $setting = new admin_setting_configstoredfile(
49
        $name,
50
        $title,
51
        $description,
52
        'preset',
53
        0,
54
        array('maxfiles' => 20, 'accepted_types' => array('.scss'))
55
    );
56
    $page->add($setting);
57
 
58
    // Variable $brand-color.
59
    // We use an empty default value because the default colour should come from the preset.
60
    $name = 'theme_universe_child/brandcolor';
61
    $title = get_string('brandcolor', 'theme_universe_child');
62
    $description = get_string('brandcolor_desc', 'theme_universe_child');
63
    $setting = new admin_setting_configcolourpicker($name, $title, $description, '');
64
    $setting->set_updatedcallback('theme_reset_all_caches');
65
    $page->add($setting);
66
 
67
    // Must add the page after definiting all the settings!
68
    $settings->add($page);
69
 
70
    // Advanced settings.
71
    $page = new admin_settingpage('theme_universe_child_advanced', get_string('advancedsettings', 'theme_universe_child'));
72
 
73
    // Raw SCSS to include before the content.
74
    $setting = new admin_setting_configtextarea(
75
        'theme_universe_child/scsspre',
76
        get_string('rawscsspre', 'theme_universe_child'),
77
        get_string('rawscsspre_desc', 'theme_universe_child'),
78
        '',
79
        PARAM_RAW
80
    );
81
    $setting->set_updatedcallback('theme_reset_all_caches');
82
    $page->add($setting);
83
 
84
    // Raw SCSS to include after the content.
85
    $setting = new admin_setting_configtextarea(
86
        'theme_universe_child/scss',
87
        get_string('rawscss', 'theme_universe_child'),
88
        get_string('rawscss_desc', 'theme_universe_child'),
89
        '',
90
        PARAM_RAW
91
    );
92
    $setting->set_updatedcallback('theme_reset_all_caches');
93
    $page->add($setting);
94
 
95
    $settings->add($page);
1335 ariadna 96
}