Proyectos de Subversion Moodle

Rev

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