Proyectos de Subversion Moodle

Rev

Rev 1378 | Rev 1381 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

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