Proyectos de Subversion Moodle

Rev

Rev 1374 | Rev 1376 | 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
 
1374 ariadna 18
    // Include all parent theme settings
1375 ariadna 19
    require('../../universe_child/settings/topbar.php');
1356 ariadna 20
 
1374 ariadna 21
 
1344 ariadna 22
    // Each page is a tab - the first is the "General" tab.
23
    $page = new admin_settingpage('theme_universe_child_general', get_string('generalsettings', 'theme_universe_child'));
24
 
25
    // Replicate the preset setting from boost.
26
    $name = 'theme_universe_child/preset';
27
    $title = get_string('preset', 'theme_universe_child');
28
    $description = get_string('preset_desc', 'theme_universe_child');
29
    $default = 'default.scss';
30
 
31
    // We list files in our own file area to add to the drop down. We will provide our own function to
32
    // load all the presets from the correct paths.
33
    $context = context_system::instance();
34
    $fs = get_file_storage();
35
    $files = $fs->get_area_files($context->id, 'theme_universe_child', 'preset', 0, 'itemid, filepath, filename', false);
36
 
37
    $choices = [];
38
    foreach ($files as $file) {
39
        $choices[$file->get_filename()] = $file->get_filename();
40
    }
41
    // These are the built in presets from Boost.
42
    $choices['default.scss'] = 'default.scss';
43
    $choices['plain.scss'] = 'plain.scss';
44
 
45
    $setting = new admin_setting_configselect($name, $title, $description, $default, $choices);
46
    $setting->set_updatedcallback('theme_reset_all_caches');
47
    $page->add($setting);
48
 
49
    // Preset files setting.
50
    $name = 'theme_universe_child/presetfiles';
51
    $title = get_string('presetfiles', 'theme_universe_child');
52
    $description = get_string('presetfiles_desc', 'theme_universe_child');
53
 
54
    $setting = new admin_setting_configstoredfile(
55
        $name,
56
        $title,
57
        $description,
58
        'preset',
59
        0,
60
        array('maxfiles' => 20, 'accepted_types' => array('.scss'))
61
    );
62
    $page->add($setting);
63
 
64
    // Variable $brand-color.
65
    // We use an empty default value because the default colour should come from the preset.
66
    $name = 'theme_universe_child/brandcolor';
67
    $title = get_string('brandcolor', 'theme_universe_child');
68
    $description = get_string('brandcolor_desc', 'theme_universe_child');
69
    $setting = new admin_setting_configcolourpicker($name, $title, $description, '');
70
    $setting->set_updatedcallback('theme_reset_all_caches');
71
    $page->add($setting);
72
 
73
    // Must add the page after definiting all the settings!
74
    $settings->add($page);
75
 
76
    // Advanced settings.
77
    $page = new admin_settingpage('theme_universe_child_advanced', get_string('advancedsettings', 'theme_universe_child'));
78
 
79
    // Raw SCSS to include before the content.
80
    $setting = new admin_setting_configtextarea(
81
        'theme_universe_child/scsspre',
82
        get_string('rawscsspre', 'theme_universe_child'),
83
        get_string('rawscsspre_desc', 'theme_universe_child'),
84
        '',
85
        PARAM_RAW
86
    );
87
    $setting->set_updatedcallback('theme_reset_all_caches');
88
    $page->add($setting);
89
 
90
    // Raw SCSS to include after the content.
91
    $setting = new admin_setting_configtextarea(
92
        'theme_universe_child/scss',
93
        get_string('rawscss', 'theme_universe_child'),
94
        get_string('rawscss_desc', 'theme_universe_child'),
95
        '',
96
        PARAM_RAW
97
    );
98
    $setting->set_updatedcallback('theme_reset_all_caches');
99
    $page->add($setting);
100
 
101
    $settings->add($page);
1335 ariadna 102
}