Proyectos de Subversion Moodle

Rev

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