Proyectos de Subversion Moodle

Rev

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

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