Proyectos de Subversion Moodle

Rev

Rev 1335 | Ir a la última revisión | | 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.
6
defined('MOODLE_INTERNAL') || die();
7
 
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.
10
if ($ADMIN->fulltree) {
11
 
12
    // Boost provides a nice setting page which splits settings onto separate tabs. We want to use it here.
13
    $settings = new theme_universe_admin_settingspage_tabs('themesettinguniverse_child', get_string('configtitle', 'theme_universe_child'));
14
 
15
    // Each page is a tab - the first is the "General" tab.
16
    $page = new admin_settingpage('theme_universe_child_general', get_string('generalsettings', 'theme_universe_child'));
17
 
18
    // Replicate the preset setting from boost.
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
 
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.
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
    }
34
    // These are the built in presets from Boost.
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
 
42
    // Preset files setting.
43
    $name = 'theme_universe_child/presetfiles';
44
    $title = get_string('presetfiles','theme_universe_child');
45
    $description = get_string('presetfiles_desc', 'theme_universe_child');
46
 
47
    $setting = new admin_setting_configstoredfile($name, $title, $description, 'preset', 0,
48
        array('maxfiles' => 20, 'accepted_types' => array('.scss')));
49
    $page->add($setting);
50
 
51
    // Variable $brand-color.
52
    // We use an empty default value because the default colour should come from the preset.
53
    $name = 'theme_universe_child/brandcolor';
54
    $title = get_string('brandcolor', 'theme_universe_child');
55
    $description = get_string('brandcolor_desc', 'theme_universe_child');
56
    $setting = new admin_setting_configcolourpicker($name, $title, $description, '');
57
    $setting->set_updatedcallback('theme_reset_all_caches');
58
    $page->add($setting);
59
 
60
    // Must add the page after definiting all the settings!
61
    $settings->add($page);
62
 
63
    // Advanced settings.
64
    $page = new admin_settingpage('theme_universe_child_advanced', get_string('advancedsettings', 'theme_universe_child'));
65
 
66
    // Raw SCSS to include before the content.
67
    $setting = new admin_setting_configtextarea('theme_universe_child/scsspre',
68
        get_string('rawscsspre', 'theme_universe_child'), get_string('rawscsspre_desc', 'theme_universe_child'), '', PARAM_RAW);
69
    $setting->set_updatedcallback('theme_reset_all_caches');
70
    $page->add($setting);
71
 
72
    // Raw SCSS to include after the content.
73
    $setting = new admin_setting_configtextarea('theme_universe_child/scss', get_string('rawscss', 'theme_universe_child'),
74
        get_string('rawscss_desc', 'theme_universe_child'), '', PARAM_RAW);
75
    $setting->set_updatedcallback('theme_reset_all_caches');
76
    $page->add($setting);
77
 
78
    $settings->add($page);
79
}