Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 126
Línea 27... Línea 27...
27
 *
27
 *
28
 * @param string $setting
28
 * @param string $setting
29
 * @param bool $format
29
 * @param bool $format
30
 * @return string
30
 * @return string
31
 */
31
 */
32
function theme_universe_get_setting($setting, $format = false) {
32
function theme_universe_get_setting($setting, $format = false)
-
 
33
{
33
    $theme = theme_config::load('universe');
34
    $theme = theme_config::load('universe');
Línea 34... Línea 35...
34
 
35
 
35
    if (empty($theme->settings->$setting)) {
36
    if (empty($theme->settings->$setting)) {
36
        return false;
37
        return false;
Línea 55... Línea 56...
55
 * Post process the CSS tree.
56
 * Post process the CSS tree.
56
 *
57
 *
57
 * @param string $tree The CSS tree.
58
 * @param string $tree The CSS tree.
58
 * @param theme_config $theme The theme config object.
59
 * @param theme_config $theme The theme config object.
59
 */
60
 */
60
function theme_universe_css_tree_post_processor($tree, $theme) {
61
function theme_universe_css_tree_post_processor($tree, $theme)
-
 
62
{
61
    debugging('theme_universe_css_tree_post_processor() is deprecated. Required' .
63
    debugging('theme_universe_css_tree_post_processor() is deprecated. Required' .
62
        'prefixes for Bootstrap are now in theme/universe/scss/moodle/prefixes.scss');
64
        'prefixes for Bootstrap are now in theme/universe/scss/moodle/prefixes.scss');
63
    $prefixer = new theme_universe\autoprefixer($tree);
65
    $prefixer = new theme_universe\autoprefixer($tree);
64
    $prefixer->prefix();
66
    $prefixer->prefix();
65
}
67
}
Línea 67... Línea 69...
67
/**
69
/**
68
 * Get the current user preferences that are available
70
 * Get the current user preferences that are available
69
 *
71
 *
70
 * @return array[]
72
 * @return array[]
71
 */
73
 */
72
function theme_universe_user_preferences(): array {
74
function theme_universe_user_preferences(): array
-
 
75
{
73
    return [
76
    return [
74
        'drawer-open-block' => [
77
        'drawer-open-block' => [
75
            'type' => PARAM_BOOL,
78
            'type' => PARAM_BOOL,
76
            'null' => NULL_NOT_ALLOWED,
79
            'null' => NULL_NOT_ALLOWED,
77
            'default' => false,
80
            'default' => false,
Línea 102... Línea 105...
102
 * Inject additional SCSS.
105
 * Inject additional SCSS.
103
 *
106
 *
104
 * @param theme_config $theme The theme config object.
107
 * @param theme_config $theme The theme config object.
105
 * @return string
108
 * @return string
106
 */
109
 */
107
function theme_universe_get_extra_scss($theme) {
110
function theme_universe_get_extra_scss($theme)
-
 
111
{
108
    $content = '';
112
    $content = '';
Línea 109... Línea 113...
109
 
113
 
110
    // Sets the login background image.
114
    // Sets the login background image.
111
    // Check login layout, only layout #1 has background image.
115
    // Check login layout, only layout #1 has background image.
Línea 151... Línea 155...
151
 * @param array $args
155
 * @param array $args
152
 * @param bool $forcedownload
156
 * @param bool $forcedownload
153
 * @param array $options
157
 * @param array $options
154
 * @return bool
158
 * @return bool
155
 */
159
 */
156
function theme_universe_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
160
function theme_universe_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array())
-
 
161
{
157
    if ($context->contextlevel == CONTEXT_SYSTEM) {
162
    if ($context->contextlevel == CONTEXT_SYSTEM) {
158
        $theme = theme_config::load('universe');
163
        $theme = theme_config::load('universe');
159
        // By default, theme files must be cache-able by both browsers and proxies.
164
        // By default, theme files must be cache-able by both browsers and proxies.
160
        if (!array_key_exists('cacheability', $options)) {
165
        if (!array_key_exists('cacheability', $options)) {
161
            $options['cacheability'] = 'public';
166
            $options['cacheability'] = 'public';
Línea 210... Línea 215...
210
 * @param $filearea
215
 * @param $filearea
211
 * @param $theme
216
 * @param $theme
212
 * @return array|false|string|string[]|null
217
 * @return array|false|string|string[]|null
213
 * @throws dml_exception
218
 * @throws dml_exception
214
 */
219
 */
215
function theme_universe_setting_file_url($setting, $filearea, $theme) {
220
function theme_universe_setting_file_url($setting, $filearea, $theme)
-
 
221
{
216
    global $CFG;
222
    global $CFG;
Línea 217... Línea 223...
217
 
223
 
218
    $component = 'theme_universe';
224
    $component = 'theme_universe';
219
    $itemid = 0;
225
    $itemid = 0;
Línea 238... Línea 244...
238
 * Returns the main SCSS content.
244
 * Returns the main SCSS content.
239
 *
245
 *
240
 * @param theme_config $theme The theme config object.
246
 * @param theme_config $theme The theme config object.
241
 * @return string
247
 * @return string
242
 */
248
 */
243
function theme_universe_get_main_scss_content($theme) {
249
function theme_universe_get_main_scss_content($theme)
-
 
250
{
244
    global $CFG;
251
    global $CFG;
Línea 245... Línea 252...
245
 
252
 
246
    $scss = '';
253
    $scss = '';
247
    $filename = !empty($theme->settings->preset) ? $theme->settings->preset : null;
254
    $filename = !empty($theme->settings->preset) ? $theme->settings->preset : null;
Línea 265... Línea 272...
265
/**
272
/**
266
 * Get compiled css.
273
 * Get compiled css.
267
 *
274
 *
268
 * @return string compiled css
275
 * @return string compiled css
269
 */
276
 */
270
function theme_universe_get_precompiled_css() {
277
function theme_universe_get_precompiled_css()
-
 
278
{
271
    global $CFG;
279
    global $CFG;
272
    return file_get_contents($CFG->dirroot . '/theme/universe/style/moodle.css');
280
    return file_get_contents($CFG->dirroot . '/theme/universe/style/moodle.css');
273
}
281
}
Línea 274... Línea 282...
274
 
282
 
275
/**
283
/**
276
 * Get SCSS to prepend.
284
 * Get SCSS to prepend.
277
 *
285
 *
278
 * @param theme_config $theme The theme config object.
286
 * @param theme_config $theme The theme config object.
279
 * @return array
287
 * @return array
280
 */
288
 */
-
 
289
function theme_universe_get_pre_scss($theme)
281
function theme_universe_get_pre_scss($theme) {
290
{
Línea 282... Línea 291...
282
    global $CFG;
291
    global $CFG;
283
 
292
 
284
    $scss = '';
293
    $scss = '';
Línea 402... Línea 411...
402
 * Build the guest access hint HTML code.
411
 * Build the guest access hint HTML code.
403
 *
412
 *
404
 * @param int $courseid The course ID.
413
 * @param int $courseid The course ID.
405
 * @return string.
414
 * @return string.
406
 */
415
 */
407
function theme_universe_get_course_guest_access_hint($courseid) {
416
function theme_universe_get_course_guest_access_hint($courseid)
-
 
417
{
408
    global $CFG;
418
    global $CFG;
409
    require_once($CFG->dirroot . '/enrol/self/lib.php');
419
    require_once($CFG->dirroot . '/enrol/self/lib.php');
Línea 410... Línea 420...
410
 
420
 
411
    $html = '';
421
    $html = '';
Línea 433... Línea 443...
433
 * Build the course page information banners HTML code.
443
 * Build the course page information banners HTML code.
434
 * This function evaluates and composes all information banners which may appear on a course page below the full header.
444
 * This function evaluates and composes all information banners which may appear on a course page below the full header.
435
 *
445
 *
436
 * @return string.
446
 * @return string.
437
 */
447
 */
438
function theme_universe_get_course_information_banners() {
448
function theme_universe_get_course_information_banners()
-
 
449
{
439
    global $CFG, $COURSE, $PAGE, $USER, $OUTPUT;
450
    global $CFG, $COURSE, $PAGE, $USER, $OUTPUT;
Línea 440... Línea 451...
440
 
451
 
441
    // Require user library.
452
    // Require user library.
Línea 642... Línea 653...
642
            foreach ($selfenrolinstances as $selfenrolinstanceid => $selfenrolinstanceobject) {
653
            foreach ($selfenrolinstances as $selfenrolinstanceid => $selfenrolinstanceobject) {
643
                // If the user has the capability to config self enrolments, enrich the instance name with the settings link.
654
                // If the user has the capability to config self enrolments, enrich the instance name with the settings link.
644
                if (has_capability('enrol/self:config', \context_course::instance($COURSE->id))) {
655
                if (has_capability('enrol/self:config', \context_course::instance($COURSE->id))) {
645
                    $url = new moodle_url('/enrol/editinstance.php', array(
656
                    $url = new moodle_url('/enrol/editinstance.php', array(
646
                        'courseid' => $COURSE->id,
657
                        'courseid' => $COURSE->id,
647
                        'id' => $selfenrolinstanceid, 'type' => 'self'
658
                        'id' => $selfenrolinstanceid,
-
 
659
                        'type' => 'self'
648
                    ));
660
                    ));
649
                    $selfenrolinstanceobject->name = html_writer::link($url, $selfenrolinstanceobject->name);
661
                    $selfenrolinstanceobject->name = html_writer::link($url, $selfenrolinstanceobject->name);
650
                }
662
                }
Línea 651... Línea 663...
651
 
663
 
Línea 760... Línea 772...
760
 * @param string $filename The filename.
772
 * @param string $filename The filename.
761
 * @param theme_config $theme The theme config object.
773
 * @param theme_config $theme The theme config object.
762
 *
774
 *
763
 * @throws dml_exception
775
 * @throws dml_exception
764
 */
776
 */
765
function theme_universe_serve_hvp_css($filename, $theme) {
777
function theme_universe_serve_hvp_css($filename, $theme)
-
 
778
{
766
    global $CFG, $PAGE;
779
    global $CFG, $PAGE;
Línea 767... Línea 780...
767
 
780
 
Línea 768... Línea 781...
768
    require_once($CFG->dirroot . '/lib/configonlylib.php'); // For min_enable_zlib_compression.
781
    require_once($CFG->dirroot . '/lib/configonlylib.php'); // For min_enable_zlib_compression.
Línea 817... Línea 830...
817
 *
830
 *
818
 * @return array|null
831
 * @return array|null
819
 * @throws coding_exception
832
 * @throws coding_exception
820
 * @throws dml_exception
833
 * @throws dml_exception
821
 */
834
 */
822
function theme_universe_get_additionalresources_templatecontext() {
835
function theme_universe_get_additionalresources_templatecontext()
-
 
836
{
823
    global $OUTPUT;
837
    global $OUTPUT;
Línea 824... Línea 838...
824
 
838
 
825
    // Static variable to remember the files for subsequent calls of this function.
839
    // Static variable to remember the files for subsequent calls of this function.
Línea 836... Línea 850...
836
        $files = $fs->get_area_files($systemcontext->id, 'theme_universe', 'additionalresources', false, 'itemid', false);
850
        $files = $fs->get_area_files($systemcontext->id, 'theme_universe', 'additionalresources', false, 'itemid', false);
Línea 837... Línea 851...
837
 
851
 
838
        // Iterate over the files and fill the templatecontext of the file list.
852
        // Iterate over the files and fill the templatecontext of the file list.
839
        $filesforcontext = [];
853
        $filesforcontext = [];
840
        foreach ($files as $af) {
854
        foreach ($files as $af) {
841
            $urlpersistent = new moodle_url('/pluginfile.php/1/theme_universe/additionalresources/0/'.$af->get_filename());
855
            $urlpersistent = new moodle_url('/pluginfile.php/1/theme_universe/additionalresources/0/' . $af->get_filename());
842
            $urlrevisioned = new moodle_url('/pluginfile.php/1/theme_universe/additionalresources/'.theme_get_revision().
856
            $urlrevisioned = new moodle_url('/pluginfile.php/1/theme_universe/additionalresources/' . theme_get_revision() .
-
 
857
                '/' . $af->get_filename());
843
                    '/'.$af->get_filename());
858
            $filesforcontext[] = [
844
            $filesforcontext[] = ['filename' => $af->get_filename(),
859
                'filename' => $af->get_filename(),
845
                                        'filetype' => $af->get_mimetype(),
860
                'filetype' => $af->get_mimetype(),
846
                                        'filesize' => display_size($af->get_filesize()),
861
                'filesize' => display_size($af->get_filesize()),
847
                                        'fileicon' => $OUTPUT->image_icon(file_file_icon($af), get_mimetype_description($af)),
862
                'fileicon' => $OUTPUT->image_icon(file_file_icon($af), get_mimetype_description($af)),
848
                                        'fileurlpersistent' => $urlpersistent->out(),
863
                'fileurlpersistent' => $urlpersistent->out(),
-
 
864
                'fileurlrevisioned' => $urlrevisioned->out(),
849
                                        'fileurlrevisioned' => $urlrevisioned->out(), ];
865
            ];
850
        }
866
        }
Línea 851... Línea 867...
851
    }
867
    }
852
 
868
 
Línea 862... Línea 878...
862
 * @return array|null
878
 * @return array|null
863
 * @throws coding_exception
879
 * @throws coding_exception
864
 * @throws dml_exception
880
 * @throws dml_exception
865
 * Credits: Boost_Union
881
 * Credits: Boost_Union
866
 */
882
 */
867
function theme_universe_get_customfonts_templatecontext() {
883
function theme_universe_get_customfonts_templatecontext()
-
 
884
{
868
    global $OUTPUT;
885
    global $OUTPUT;
Línea 869... Línea 886...
869
 
886
 
870
    // Static variable to remember the files for subsequent calls of this function.
887
    // Static variable to remember the files for subsequent calls of this function.
Línea 891... Línea 908...
891
 
908
 
892
            // Check if the file is really a font file (as we can't really rely on the upload restriction in settings.php)
909
            // Check if the file is really a font file (as we can't really rely on the upload restriction in settings.php)
893
            // according to its file suffix (as the filetype might not have a known mimetype).
910
            // according to its file suffix (as the filetype might not have a known mimetype).
894
            // If it isn't a font file, skip it.
911
            // If it isn't a font file, skip it.
895
            $filenamesuffix = pathinfo($filename, PATHINFO_EXTENSION);
912
            $filenamesuffix = pathinfo($filename, PATHINFO_EXTENSION);
896
            if (!in_array('.'.$filenamesuffix, $webfonts)) {
913
            if (!in_array('.' . $filenamesuffix, $webfonts)) {
897
                continue;
914
                continue;
Línea 898... Línea 915...
898
            }
915
            }
899
 
916
 
-
 
917
            // Otherwise, fill the templatecontext of the file list.
900
            // Otherwise, fill the templatecontext of the file list.
918
            $urlpersistent = new moodle_url('/pluginfile.php/1/theme_universe/fontfiles/0/' . $filename);
901
            $urlpersistent = new moodle_url('/pluginfile.php/1/theme_universe/fontfiles/0/'.$filename);
919
            $filesforcontext[] = [
-
 
920
                'filename' => $filename,
902
            $filesforcontext[] = ['filename' => $filename,
921
                'fileurlpersistent' => $urlpersistent->out(),
903
                    'fileurlpersistent' => $urlpersistent->out(), ];
922
            ];
Línea 904... Línea 923...
904
        }
923
        }
905
    }
924
    }
Línea 911... Línea 930...
911
 * Helper function which returns an array of accepted webfonts extensions (including the dots).
930
 * Helper function which returns an array of accepted webfonts extensions (including the dots).
912
 *
931
 *
913
 * @return array
932
 * @return array
914
 * Credits: Boost_Union
933
 * Credits: Boost_Union
915
 */
934
 */
916
function theme_universe_get_webfonts_extensions() {
935
function theme_universe_get_webfonts_extensions()
-
 
936
{
917
    return ['.eot', '.otf', '.svg', '.ttf', '.woff', '.woff2'];
937
    return ['.eot', '.otf', '.svg', '.ttf', '.woff', '.woff2'];
918
}
938
}
Línea 919... Línea 939...
919
 
939
 
920
/**
940
/**
Línea 928... Línea 948...
928
 *
948
 *
929
 * @return boolean true if the filetypes were registered, false if not.
949
 * @return boolean true if the filetypes were registered, false if not.
930
 * @throws coding_exception
950
 * @throws coding_exception
931
 * Credits: Boost_Union
951
 * Credits: Boost_Union
932
 */
952
 */
933
function theme_universe_register_webfonts_filetypes() {
953
function theme_universe_register_webfonts_filetypes()
-
 
954
{
934
    global $CFG;
955
    global $CFG;
Línea 935... Línea 956...
935
 
956
 
936
    // If customfiletypes are set in config.php or PHP tests are running, we can't do anything.
957
    // If customfiletypes are set in config.php or PHP tests are running, we can't do anything.
937
    if (array_key_exists('customfiletypes', $CFG->config_php_settings) || PHPUNIT_TEST) {
958
    if (array_key_exists('customfiletypes', $CFG->config_php_settings) || PHPUNIT_TEST) {
Línea 940... Línea 961...
940
 
961
 
941
    // Our array of webfont file types to register.
962
    // Our array of webfont file types to register.
942
    // As we want to keep things simple, we do not set a particular icon for these file types.
963
    // As we want to keep things simple, we do not set a particular icon for these file types.
943
    // Likewise, we do not set any type groups or use descriptions from the language pack.
964
    // Likewise, we do not set any type groups or use descriptions from the language pack.
944
    $webfonts = [
965
    $webfonts = [
945
            'eot' => [
966
        'eot' => [
946
                    'extension' => 'eot',
967
            'extension' => 'eot',
947
                    'mimetype' => 'application/vnd.ms-fontobject',
968
            'mimetype' => 'application/vnd.ms-fontobject',
948
                    'coreicon' => 'unknown',
969
            'coreicon' => 'unknown',
949
            ],
970
        ],
950
            'otf' => [
971
        'otf' => [
951
                    'extension' => 'otf',
972
            'extension' => 'otf',
952
                    'mimetype' => 'font/otf',
973
            'mimetype' => 'font/otf',
953
                    'coreicon' => 'unknown',
974
            'coreicon' => 'unknown',
954
            ],
975
        ],
955
            'svg' => [
976
        'svg' => [
956
                    'extension' => 'svg',
977
            'extension' => 'svg',
957
                    'mimetype' => 'image/svg+xml',
978
            'mimetype' => 'image/svg+xml',
958
                    'coreicon' => 'unknown',
979
            'coreicon' => 'unknown',
959
            ],
980
        ],
960
            'ttf' => [
981
        'ttf' => [
961
                    'extension' => 'ttf',
982
            'extension' => 'ttf',
962
                    'mimetype' => 'font/ttf',
983
            'mimetype' => 'font/ttf',
963
                    'coreicon' => 'unknown',
984
            'coreicon' => 'unknown',
964
            ],
985
        ],
965
            'woff' => [
986
        'woff' => [
966
                    'extension' => 'woff',
987
            'extension' => 'woff',
967
                    'mimetype' => 'font/woff',
988
            'mimetype' => 'font/woff',
968
                    'coreicon' => 'unknown',
989
            'coreicon' => 'unknown',
969
            ],
990
        ],
970
            'woff2' => [
991
        'woff2' => [
971
                    'extension' => 'woff2',
992
            'extension' => 'woff2',
972
                    'mimetype' => 'font/woff2',
993
            'mimetype' => 'font/woff2',
973
                    'coreicon' => 'unknown',
994
            'coreicon' => 'unknown',
974
            ],
995
        ],
Línea 975... Línea 996...
975
    ];
996
    ];
976
 
997
 
Línea 988... Línea 1009...
988
        core_filetypes::add_type($f['extension'], $f['mimetype'], $f['coreicon']);
1009
        core_filetypes::add_type($f['extension'], $f['mimetype'], $f['coreicon']);
989
    }
1010
    }
Línea 990... Línea 1011...
990
 
1011
 
991
    return true;
1012
    return true;
-
 
1013
}
-
 
1014
 
-
 
1015
function theme_universe_get_default_blocks()
-
 
1016
{
-
 
1017
    return array(
-
 
1018
        'incourse' => array(
-
 
1019
            'side-pre' => array('block_messageteacher', 'messageteacher')
-
 
1020
        ),
-
 
1021
        'course-view' => array(
-
 
1022
            'side-pre' => array('block_messageteacher', 'messageteacher')
-
 
1023
        ),
-
 
1024
    );