Proyectos de Subversion Moodle

Rev

Rev 1 | Rev 1336 | 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.
1335 ariadna 13
    $settings = new theme_universe_admin_settingspage_tabs('themesettinguniverse', get_string('configtitle', 'theme_universe'));
14
 
1 efrain 15
    // Each page is a tab - the first is the "General" tab.
1335 ariadna 16
    $page = new admin_settingpage('theme_universe_child_general', get_string('generalsettings', 'theme_universe_child'));
17
 
1 efrain 18
    // Replicate the preset setting from boost.
1335 ariadna 19
    $name = 'theme_universe_child/preset';
20
    $title = get_string('preset', 'theme_universe_child');
21
    $description = get_string('preset_desc', 'theme_universe_child');
22
    $default = 'default.scss';
23
 
1 efrain 24
    // We list files in our own file area to add to the drop down. We will provide our own function to
25
    // load all the presets from the correct paths.
1335 ariadna 26
    $context = context_system::instance();
27
    $fs = get_file_storage();
28
    $files = $fs->get_area_files($context->id, 'theme_universe_child', 'preset', 0, 'itemid, filepath, filename', false);
29
 
30
    $choices = [];
31
    foreach ($files as $file) {
32
        $choices[$file->get_filename()] = $file->get_filename();
33
    }
1 efrain 34
    // These are the built in presets from Boost.
1335 ariadna 35
    $choices['default.scss'] = 'default.scss';
36
    $choices['plain.scss'] = 'plain.scss';
37
 
38
    $setting = new admin_setting_configselect($name, $title, $description, $default, $choices);
39
    $setting->set_updatedcallback('theme_reset_all_caches');
40
    $page->add($setting);
41
 
1 efrain 42
    // Preset files setting.
1335 ariadna 43
    $name = 'theme_universe_child/presetfiles';
44
    $title = get_string('presetfiles', 'theme_universe_child');
45
    $description = get_string('presetfiles_desc', 'theme_universe_child');
1 efrain 46
 
1335 ariadna 47
    $setting = new admin_setting_configstoredfile(
48
        $name,
49
        $title,
50
        $description,
51
        'preset',
52
        0,
53
        array('maxfiles' => 20, 'accepted_types' => array('.scss'))
54
    );
55
    $page->add($setting);
56
 
1 efrain 57
    // Variable $brand-color.
58
    // We use an empty default value because the default colour should come from the preset.
1335 ariadna 59
    $name = 'theme_universe_child/brandcolor';
60
    $title = get_string('brandcolor', 'theme_universe_child');
61
    $description = get_string('brandcolor_desc', 'theme_universe_child');
62
    $setting = new admin_setting_configcolourpicker($name, $title, $description, '');
63
    $setting->set_updatedcallback('theme_reset_all_caches');
64
    $page->add($setting);
65
 
1 efrain 66
    // Must add the page after definiting all the settings!
1335 ariadna 67
    $settings->add($page);
68
 
1 efrain 69
    // Advanced settings.
1335 ariadna 70
    $page = new admin_settingpage('theme_universe_child_advanced', get_string('advancedsettings', 'theme_universe_child'));
71
 
1 efrain 72
    // Raw SCSS to include before the content.
1335 ariadna 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
 
1 efrain 83
    // Raw SCSS to include after the content.
1335 ariadna 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
 
94
    $settings->add($page);
95
}