Proyectos de Subversion Moodle

Rev

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