Proyectos de Subversion Moodle

Rev

Rev 1287 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1287 Rev 1441
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
{
-
 
34
    $theme = theme_config::load('universe');
33
    $theme = theme_config::load('universe');
Línea 35... Línea 34...
35
 
34
 
36
    if (empty($theme->settings->$setting)) {
35
    if (empty($theme->settings->$setting)) {
37
        return false;
36
        return false;
Línea 50... Línea 49...
50
    }
49
    }
Línea 51... Línea 50...
51
 
50
 
52
    return format_string($theme->settings->$setting);
51
    return format_string($theme->settings->$setting);
Línea 53... Línea -...
53
}
-
 
54
 
-
 
55
function theme_universe_themedir()
-
 
56
{
-
 
57
    global $CFG;
-
 
58
 
-
 
59
    $teme_dir = '/theme';
-
 
60
 
-
 
61
    if (isset($CFG->themedir)) {
-
 
62
        $teme_dir = $CFG->themedir;
-
 
63
        $teme_dir = str_replace($CFG->dirroot, '', $CFG->themedir);
-
 
64
    }
-
 
65
 
-
 
66
    return $teme_dir;
-
 
67
}
52
}
68
 
53
 
69
/**
54
/**
70
 * Post process the CSS tree.
55
 * Post process the CSS tree.
71
 *
56
 *
72
 * @param string $tree The CSS tree.
57
 * @param string $tree The CSS tree.
73
 * @param theme_config $theme The theme config object.
58
 * @param theme_config $theme The theme config object.
74
 */
-
 
75
function theme_universe_css_tree_post_processor($tree, $theme)
59
 */
76
{
60
function theme_universe_css_tree_post_processor($tree, $theme) {
77
    debugging('theme_universe_css_tree_post_processor() is deprecated. Required' .
61
    debugging('theme_universe_css_tree_post_processor() is deprecated. Required' .
78
        'prefixes for Bootstrap are now in theme/universe/scss/moodle/prefixes.scss');
62
        'prefixes for Bootstrap are now in theme/universe/scss/moodle/prefixes.scss');
79
    $prefixer = new theme_universe\autoprefixer($tree);
63
    $prefixer = new theme_universe\autoprefixer($tree);
Línea 83... Línea 67...
83
/**
67
/**
84
 * Get the current user preferences that are available
68
 * Get the current user preferences that are available
85
 *
69
 *
86
 * @return array[]
70
 * @return array[]
87
 */
71
 */
88
function theme_universe_user_preferences(): array
72
function theme_universe_user_preferences(): array {
89
{
-
 
90
    return [
73
    return [
91
        'drawer-open-block' => [
74
        'drawer-open-block' => [
92
            'type' => PARAM_BOOL,
75
            'type' => PARAM_BOOL,
93
            'null' => NULL_NOT_ALLOWED,
76
            'null' => NULL_NOT_ALLOWED,
94
            'default' => false,
77
            'default' => false,
Línea 104... Línea 87...
104
            'type' => PARAM_BOOL,
87
            'type' => PARAM_BOOL,
105
            'null' => NULL_NOT_ALLOWED,
88
            'null' => NULL_NOT_ALLOWED,
106
            'default' => false,
89
            'default' => false,
107
            'permissioncallback' => [core_user::class, 'is_current_user'],
90
            'permissioncallback' => [core_user::class, 'is_current_user'],
108
        ],
91
        ],
-
 
92
        'coursefilter-on' => [
-
 
93
            'type' => PARAM_BOOL,
-
 
94
            'null' => NULL_NOT_ALLOWED,
-
 
95
            'default' => false,
-
 
96
            'permissioncallback' => [core_user::class, 'is_current_user'],
-
 
97
        ],
109
        'sidepre-open' => [
98
        'sidepre-open' => [
110
            'type' => PARAM_BOOL,
99
            'type' => PARAM_BOOL,
111
            'null' => NULL_NOT_ALLOWED,
100
            'null' => NULL_NOT_ALLOWED,
112
            'default' => true,
101
            'default' => true,
113
            'permissioncallback' => [core_user::class, 'is_current_user'],
102
            'permissioncallback' => [core_user::class, 'is_current_user'],
Línea 119... Línea 108...
119
 * Inject additional SCSS.
108
 * Inject additional SCSS.
120
 *
109
 *
121
 * @param theme_config $theme The theme config object.
110
 * @param theme_config $theme The theme config object.
122
 * @return string
111
 * @return string
123
 */
112
 */
124
function theme_universe_get_extra_scss($theme)
113
function theme_universe_get_extra_scss($theme) {
125
{
-
 
126
    $content = '';
114
    $content = '';
Línea 127... Línea 115...
127
 
115
 
128
    // Sets the login background image.
116
    // Sets the login background image.
129
    // Check login layout, only layout #1 has background image.
117
    // Check login layout, only layout #1 has background image.
Línea 150... Línea 138...
150
 
138
 
151
    $forcefwvideo = theme_universe_get_setting('forcefwvideo');
139
    $forcefwvideo = theme_universe_get_setting('forcefwvideo');
152
    if ($forcefwvideo == 1) {
140
    if ($forcefwvideo == 1) {
153
        $content .= '.mediaplugin.mediaplugin_videojs div[style*="max-width"] {margin-left:auto;margin-right:auto;
141
        $content .= '.mediaplugin.mediaplugin_videojs div[style*="max-width"] {margin-left:auto;margin-right:auto;
154
            width: 100%; max-width: 100% !important;}';
-
 
155
        $content .= '.mediaplugin div {max-width:100%!important;}';
142
            width: 100%; max-width: 100% !important;}';
Línea 156... Línea 143...
156
    }
143
    }
157
 
144
 
158
    // Always return the background image with the scss when we have it.
145
    // Always return the background image with the scss when we have it.
Línea 169... Línea 156...
169
 * @param array $args
156
 * @param array $args
170
 * @param bool $forcedownload
157
 * @param bool $forcedownload
171
 * @param array $options
158
 * @param array $options
172
 * @return bool
159
 * @return bool
173
 */
160
 */
174
function theme_universe_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array())
161
function theme_universe_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
175
{
-
 
176
    if ($context->contextlevel == CONTEXT_SYSTEM) {
162
    if ($context->contextlevel == CONTEXT_SYSTEM) {
177
        $theme = theme_config::load('universe');
163
        $theme = theme_config::load('universe');
178
        // 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.
179
        if (!array_key_exists('cacheability', $options)) {
165
        if (!array_key_exists('cacheability', $options)) {
180
            $options['cacheability'] = 'public';
166
            $options['cacheability'] = 'public';
Línea 214... Línea 200...
214
            return $theme->setting_file_serve('block2videomp4', $args, $forcedownload, $options);
200
            return $theme->setting_file_serve('block2videomp4', $args, $forcedownload, $options);
215
        } else if ($filearea === 'block2videowebm') {
201
        } else if ($filearea === 'block2videowebm') {
216
            return $theme->setting_file_serve('block2videowebm', $args, $forcedownload, $options);
202
            return $theme->setting_file_serve('block2videowebm', $args, $forcedownload, $options);
217
        } else if ($filearea === 'footerbgimg') {
203
        } else if ($filearea === 'footerbgimg') {
218
            return $theme->setting_file_serve('footerbgimg', $args, $forcedownload, $options);
204
            return $theme->setting_file_serve('footerbgimg', $args, $forcedownload, $options);
-
 
205
        } else if ($filearea === 'additionalresources') {
-
 
206
            return $theme->setting_file_serve('additionalresources', $args, $forcedownload, $options);
219
        } else {
207
        } else {
220
            send_file_not_found();
208
            send_file_not_found();
221
        }
209
        }
222
    }
210
    }
223
}
211
}
Línea 229... Línea 217...
229
 * @param $filearea
217
 * @param $filearea
230
 * @param $theme
218
 * @param $theme
231
 * @return array|false|string|string[]|null
219
 * @return array|false|string|string[]|null
232
 * @throws dml_exception
220
 * @throws dml_exception
233
 */
221
 */
234
function theme_universe_setting_file_url($setting, $filearea, $theme)
222
function theme_universe_setting_file_url($setting, $filearea, $theme) {
235
{
-
 
236
    global $CFG;
223
    global $CFG;
Línea 237... Línea 224...
237
 
224
 
238
    $component = 'theme_universe';
225
    $component = 'theme_universe';
239
    $itemid = 0;
226
    $itemid = 0;
Línea 258... Línea 245...
258
 * Returns the main SCSS content.
245
 * Returns the main SCSS content.
259
 *
246
 *
260
 * @param theme_config $theme The theme config object.
247
 * @param theme_config $theme The theme config object.
261
 * @return string
248
 * @return string
262
 */
249
 */
263
function theme_universe_get_main_scss_content($theme)
250
function theme_universe_get_main_scss_content($theme) {
264
{
-
 
265
    global $CFG;
251
    global $CFG;
Línea 266... Línea 252...
266
 
252
 
267
    $scss = '';
253
    $scss = '';
268
    $filename = !empty($theme->settings->preset) ? $theme->settings->preset : null;
254
    $filename = !empty($theme->settings->preset) ? $theme->settings->preset : null;
Línea 286... Línea 272...
286
/**
272
/**
287
 * Get compiled css.
273
 * Get compiled css.
288
 *
274
 *
289
 * @return string compiled css
275
 * @return string compiled css
290
 */
276
 */
291
function theme_universe_get_precompiled_css()
277
function theme_universe_get_precompiled_css() {
292
{
-
 
293
    global $CFG;
278
    global $CFG;
294
    return file_get_contents($CFG->dirroot . '/theme/universe/style/moodle.css');
279
    return file_get_contents($CFG->dirroot . '/theme/universe/style/moodle.css');
295
}
280
}
Línea 296... Línea 281...
296
 
281
 
297
/**
282
/**
298
 * Get SCSS to prepend.
283
 * Get SCSS to prepend.
299
 *
284
 *
300
 * @param theme_config $theme The theme config object.
285
 * @param theme_config $theme The theme config object.
301
 * @return array
286
 * @return array
302
 */
287
 */
303
function theme_universe_get_pre_scss($theme)
-
 
304
{
288
function theme_universe_get_pre_scss($theme) {
Línea 305... Línea 289...
305
    global $CFG;
289
    global $CFG;
306
 
290
 
307
    $scss = '';
291
    $scss = '';
Línea 317... Línea 301...
317
        'fontweightheadings' => ['headings-font-weight'],
301
        'fontweightheadings' => ['headings-font-weight'],
318
        'fontbody' => ['font-family-base'],
302
        'fontbody' => ['font-family-base'],
319
        'fontweightregular' => ['font-weight-normal'],
303
        'fontweightregular' => ['font-weight-normal'],
320
        'fontweightmedium' => ['font-weight-medium'],
304
        'fontweightmedium' => ['font-weight-medium'],
321
        'fontweightbold' => ['font-weight-bold'],
305
        'fontweightbold' => ['font-weight-bold'],
322
        'fontheadings' => ['fontheadings'],
-
 
323
        // 'coursedescwidth' => ['coursedescwidth'],
-
 
324
        // 'incoursedescwidth' => ['incoursedescwidth'],
-
 
325
        // Text.
306
        // Text.
326
        'colorbody' => ['body-color'],
307
        'colorbody' => ['body-color'],
327
        'colorbodysecondary' => ['body-color-secondary'],
308
        'colorbodysecondary' => ['body-color-secondary'],
328
        'colorbodylight' => ['body-color-light'],
309
        'colorbodylight' => ['body-color-light'],
329
        'colorlink' => ['link-color'],
310
        'colorlink' => ['link-color'],
Línea 351... Línea 332...
351
        'colorprimary800' => ['primary-color-800'],
332
        'colorprimary800' => ['primary-color-800'],
352
        'colorprimary900' => ['primary-color-900'],
333
        'colorprimary900' => ['primary-color-900'],
353
        // Others.
334
        // Others.
354
        'colorbodybg' => ['body-bg'],
335
        'colorbodybg' => ['body-bg'],
355
        'colorborder' => ['border-color'],
336
        'colorborder' => ['border-color'],
356
        //'colorcoursecardmask' => ['course-card-shadow-color'],
-
 
357
        // Topbar.
337
        // Topbar.
358
        'topbarheight' => ['navbar-height'],
338
        'topbarheight' => ['navbar-height'],
359
        'colortopbarbg1' => ['topbar-bg'],
339
        'colortopbarbg1' => ['topbar-bg'],
360
        'colortopbarbg2' => ['topbar-bg-2'],
340
        'colortopbarbg2' => ['topbar-bg-2'],
361
        'dmcolortopbarbg1' => ['topbar-bg'],
341
        'dmcolortopbarbg1' => ['dm-topbar-bg'],
362
        'dmcolortopbarbg2' => ['dm-topbar-bg-2'],
342
        'dmcolortopbarbg2' => ['dm-topbar-bg-2'],
363
        'colortopbartext' => ['dm-topbar-text'],
-
 
364
        'colortopbarlink' => ['topbar-link'],
343
        'colortopbarlink' => ['topbar-link'],
365
        'colortopbarlinkhover' => ['topbar-link-hover'],
344
        'colortopbarlinkhover' => ['topbar-link-hover'],
366
        'colortopbarbtntext' => ['topbar-btn-text'],
345
        'colortopbarbtntext' => ['topbar-btn-text'],
367
        'colortopbarbtnhover' => ['topbar-btn-hover'],
346
        'colortopbarbtnhover' => ['topbar-btn-hover'],
368
        'colortopbarbtnhovertext' => ['topbar-btn-hover-text'],
347
        'colortopbarbtnhovertext' => ['topbar-btn-hover-text'],
-
 
348
        'dmcolortopbarbtntext' => ['dm-topbar-btn-text'],
-
 
349
        'dmcolortopbarbtnhover' => ['dm-topbar-btn-hover'],
-
 
350
        'dmcolortopbarbtnhovertext' => ['dm-topbar-btn-hover-text'],
369
        // Buttons.
351
        // Buttons.
370
        'btnborderradius' => ['btn-border-radius'],
352
        'btnborderradius' => ['btn-border-radius'],
371
        // Sidebar.
353
        // Sidebar.
372
        'colordrawerbg' => ['drawer-bg'],
354
        'colordrawerbg' => ['drawer-bg'],
373
        'colordrawertext' => ['drawer-text'],
355
        'colordrawertext' => ['drawer-text'],
Línea 380... Línea 362...
380
        'colordrawernavbtntextlight' => ['drawer-nav-btn-text-light'],
362
        'colordrawernavbtntextlight' => ['drawer-nav-btn-text-light'],
381
        'colordrawerscrollbar' => ['drawer-scroll-bg-track'],
363
        'colordrawerscrollbar' => ['drawer-scroll-bg-track'],
382
        'colordrawerlink' => ['drawer-link'],
364
        'colordrawerlink' => ['drawer-link'],
383
        'colordrawerlinkh' => ['drawer-link-h'],
365
        'colordrawerlinkh' => ['drawer-link-h'],
384
        'colordrawernavboxbg' => ['drawer-nav-box-bg'],
366
        'colordrawernavboxbg' => ['drawer-nav-box-bg'],
385
        'colordrawernavbtnicon' => ['drawer-nav-btn-icon'],
-
 
386
        // Footer.
367
        // Footer.
387
        'colorfooterbg' => ['footer-bg'],
368
        'colorfooterbg' => ['footer-bg'],
388
        'colorfooterborder' => ['footer-border'],
369
        'colorfooterborder' => ['footer-border'],
389
        'colorfootertext' => ['footer-text-color'],
370
        'colorfootertext' => ['footer-text-color'],
390
        'colorfooterlink' => ['footer-link-color'],
371
        'colorfooterlink' => ['footer-link-color'],
391
        'colorfooterlinkhover' => ['footer-link-color-hover'],
372
        'colorfooterlinkhover' => ['footer-link-color-hover'],
392
        'colorcoursecardmask' => ['course-card-mask-color'],
-
 
393
        'showcolorcoursecardmask' => ['showcolorcoursecardmask'],
-
 
394
        // Login.
373
        // Login.
395
        'loginbgcolor' => ['login-bgcolor'],
374
        'loginbgcolor' => ['login-bgcolor'],
396
        // Icon Colors.
375
        // Icon Colors.
397
        'iconadministration' => ['icon-color-administraion'],
376
        'iconadministration' => ['icon-color-administraion'],
398
        'iconassessment' => ['icon-color-assessment'],
377
        'iconassessment' => ['icon-color-assessment'],
Línea 425... Línea 404...
425
 * Build the guest access hint HTML code.
404
 * Build the guest access hint HTML code.
426
 *
405
 *
427
 * @param int $courseid The course ID.
406
 * @param int $courseid The course ID.
428
 * @return string.
407
 * @return string.
429
 */
408
 */
430
function theme_universe_get_course_guest_access_hint($courseid)
409
function theme_universe_get_course_guest_access_hint($courseid) {
431
{
-
 
432
    global $CFG;
410
    global $CFG;
433
    require_once($CFG->dirroot . '/enrol/self/lib.php');
411
    require_once($CFG->dirroot . '/enrol/self/lib.php');
Línea 434... Línea 412...
434
 
412
 
435
    $html = '';
413
    $html = '';
Línea 457... Línea 435...
457
 * Build the course page information banners HTML code.
435
 * Build the course page information banners HTML code.
458
 * This function evaluates and composes all information banners which may appear on a course page below the full header.
436
 * This function evaluates and composes all information banners which may appear on a course page below the full header.
459
 *
437
 *
460
 * @return string.
438
 * @return string.
461
 */
439
 */
462
function theme_universe_get_course_information_banners()
440
function theme_universe_get_course_information_banners() {
463
{
-
 
464
    global $CFG, $COURSE, $PAGE, $USER, $OUTPUT;
441
    global $CFG, $COURSE, $PAGE, $USER, $OUTPUT;
Línea 465... Línea 442...
465
 
442
 
466
    // Require user library.
443
    // Require user library.
Línea 667... Línea 644...
667
            foreach ($selfenrolinstances as $selfenrolinstanceid => $selfenrolinstanceobject) {
644
            foreach ($selfenrolinstances as $selfenrolinstanceid => $selfenrolinstanceobject) {
668
                // If the user has the capability to config self enrolments, enrich the instance name with the settings link.
645
                // If the user has the capability to config self enrolments, enrich the instance name with the settings link.
669
                if (has_capability('enrol/self:config', \context_course::instance($COURSE->id))) {
646
                if (has_capability('enrol/self:config', \context_course::instance($COURSE->id))) {
670
                    $url = new moodle_url('/enrol/editinstance.php', array(
647
                    $url = new moodle_url('/enrol/editinstance.php', array(
671
                        'courseid' => $COURSE->id,
648
                        'courseid' => $COURSE->id,
672
                        'id' => $selfenrolinstanceid,
649
                        'id' => $selfenrolinstanceid, 'type' => 'self'
673
                        'type' => 'self'
-
 
674
                    ));
650
                    ));
675
                    $selfenrolinstanceobject->name = html_writer::link($url, $selfenrolinstanceobject->name);
651
                    $selfenrolinstanceobject->name = html_writer::link($url, $selfenrolinstanceobject->name);
676
                }
652
                }
Línea 677... Línea 653...
677
 
653
 
Línea 786... Línea 762...
786
 * @param string $filename The filename.
762
 * @param string $filename The filename.
787
 * @param theme_config $theme The theme config object.
763
 * @param theme_config $theme The theme config object.
788
 *
764
 *
789
 * @throws dml_exception
765
 * @throws dml_exception
790
 */
766
 */
791
function theme_universe_serve_hvp_css($filename, $theme)
767
function theme_universe_serve_hvp_css($filename, $theme) {
792
{
-
 
793
    global $CFG, $PAGE;
768
    global $CFG, $PAGE;
Línea 794... Línea 769...
794
 
769
 
Línea 795... Línea 770...
795
    require_once($CFG->dirroot . '/lib/configonlylib.php'); // For min_enable_zlib_compression.
770
    require_once($CFG->dirroot . '/lib/configonlylib.php'); // For min_enable_zlib_compression.
Línea 844... Línea 819...
844
 *
819
 *
845
 * @return array|null
820
 * @return array|null
846
 * @throws coding_exception
821
 * @throws coding_exception
847
 * @throws dml_exception
822
 * @throws dml_exception
848
 */
823
 */
849
function theme_universe_get_additionalresources_templatecontext()
824
function theme_universe_get_additionalresources_templatecontext() {
850
{
-
 
851
    global $OUTPUT;
825
    global $OUTPUT;
Línea 852... Línea 826...
852
 
826
 
853
    // Static variable to remember the files for subsequent calls of this function.
827
    // Static variable to remember the files for subsequent calls of this function.
Línea 864... Línea 838...
864
        $files = $fs->get_area_files($systemcontext->id, 'theme_universe', 'additionalresources', false, 'itemid', false);
838
        $files = $fs->get_area_files($systemcontext->id, 'theme_universe', 'additionalresources', false, 'itemid', false);
Línea 865... Línea 839...
865
 
839
 
866
        // Iterate over the files and fill the templatecontext of the file list.
840
        // Iterate over the files and fill the templatecontext of the file list.
867
        $filesforcontext = [];
841
        $filesforcontext = [];
868
        foreach ($files as $af) {
842
        foreach ($files as $af) {
869
            $urlpersistent = new moodle_url('/pluginfile.php/1/theme_universe/additionalresources/0/' . $af->get_filename());
843
            $urlpersistent = new moodle_url('/pluginfile.php/1/theme_universe/additionalresources/0/'.$af->get_filename());
870
            $urlrevisioned = new moodle_url('/pluginfile.php/1/theme_universe/additionalresources/' . theme_get_revision() .
844
            $urlrevisioned = new moodle_url('/pluginfile.php/1/theme_universe/additionalresources/'.theme_get_revision().
871
                '/' . $af->get_filename());
-
 
872
            $filesforcontext[] = [
845
                    '/'.$af->get_filename());
873
                'filename' => $af->get_filename(),
846
            $filesforcontext[] = ['filename' => $af->get_filename(),
874
                'filetype' => $af->get_mimetype(),
847
                                        'filetype' => $af->get_mimetype(),
875
                'filesize' => display_size($af->get_filesize()),
848
                                        'filesize' => display_size($af->get_filesize()),
876
                'fileicon' => $OUTPUT->image_icon(file_file_icon($af), get_mimetype_description($af)),
849
                                        'fileicon' => $OUTPUT->image_icon(file_file_icon($af), get_mimetype_description($af)),
877
                'fileurlpersistent' => $urlpersistent->out(),
850
                                        'fileurlpersistent' => $urlpersistent->out(),
878
                'fileurlrevisioned' => $urlrevisioned->out(),
-
 
879
            ];
851
                                        'fileurlrevisioned' => $urlrevisioned->out(), ];
880
        }
852
        }
Línea 881... Línea 853...
881
    }
853
    }
882
 
854
 
Línea 892... Línea 864...
892
 * @return array|null
864
 * @return array|null
893
 * @throws coding_exception
865
 * @throws coding_exception
894
 * @throws dml_exception
866
 * @throws dml_exception
895
 * Credits: Boost_Union
867
 * Credits: Boost_Union
896
 */
868
 */
897
function theme_universe_get_customfonts_templatecontext()
869
function theme_universe_get_customfonts_templatecontext() {
898
{
-
 
899
    global $OUTPUT;
870
    global $OUTPUT;
Línea 900... Línea 871...
900
 
871
 
901
    // Static variable to remember the files for subsequent calls of this function.
872
    // Static variable to remember the files for subsequent calls of this function.
Línea 922... Línea 893...
922
 
893
 
923
            // Check if the file is really a font file (as we can't really rely on the upload restriction in settings.php)
894
            // Check if the file is really a font file (as we can't really rely on the upload restriction in settings.php)
924
            // according to its file suffix (as the filetype might not have a known mimetype).
895
            // according to its file suffix (as the filetype might not have a known mimetype).
925
            // If it isn't a font file, skip it.
896
            // If it isn't a font file, skip it.
926
            $filenamesuffix = pathinfo($filename, PATHINFO_EXTENSION);
897
            $filenamesuffix = pathinfo($filename, PATHINFO_EXTENSION);
927
            if (!in_array('.' . $filenamesuffix, $webfonts)) {
898
            if (!in_array('.'.$filenamesuffix, $webfonts)) {
928
                continue;
899
                continue;
Línea 929... Línea 900...
929
            }
900
            }
930
 
901
 
931
            // Otherwise, fill the templatecontext of the file list.
-
 
932
            $urlpersistent = new moodle_url('/pluginfile.php/1/theme_universe/fontfiles/0/' . $filename);
902
            // Otherwise, fill the templatecontext of the file list.
933
            $filesforcontext[] = [
903
            $urlpersistent = new moodle_url('/pluginfile.php/1/theme_universe/fontfiles/0/'.$filename);
934
                'filename' => $filename,
-
 
935
                'fileurlpersistent' => $urlpersistent->out(),
904
            $filesforcontext[] = ['filename' => $filename,
936
            ];
905
                    'fileurlpersistent' => $urlpersistent->out(), ];
Línea 937... Línea 906...
937
        }
906
        }
938
    }
907
    }
Línea 944... Línea 913...
944
 * Helper function which returns an array of accepted webfonts extensions (including the dots).
913
 * Helper function which returns an array of accepted webfonts extensions (including the dots).
945
 *
914
 *
946
 * @return array
915
 * @return array
947
 * Credits: Boost_Union
916
 * Credits: Boost_Union
948
 */
917
 */
949
function theme_universe_get_webfonts_extensions()
918
function theme_universe_get_webfonts_extensions() {
950
{
-
 
951
    return ['.eot', '.otf', '.svg', '.ttf', '.woff', '.woff2'];
919
    return ['.eot', '.otf', '.svg', '.ttf', '.woff', '.woff2'];
952
}
920
}
Línea 953... Línea 921...
953
 
921
 
954
/**
922
/**
Línea 962... Línea 930...
962
 *
930
 *
963
 * @return boolean true if the filetypes were registered, false if not.
931
 * @return boolean true if the filetypes were registered, false if not.
964
 * @throws coding_exception
932
 * @throws coding_exception
965
 * Credits: Boost_Union
933
 * Credits: Boost_Union
966
 */
934
 */
967
function theme_universe_register_webfonts_filetypes()
935
function theme_universe_register_webfonts_filetypes() {
968
{
-
 
969
    global $CFG;
936
    global $CFG;
Línea 970... Línea 937...
970
 
937
 
971
    // If customfiletypes are set in config.php or PHP tests are running, we can't do anything.
938
    // If customfiletypes are set in config.php or PHP tests are running, we can't do anything.
972
    if (array_key_exists('customfiletypes', $CFG->config_php_settings) || PHPUNIT_TEST) {
939
    if (array_key_exists('customfiletypes', $CFG->config_php_settings) || PHPUNIT_TEST) {
Línea 975... Línea 942...
975
 
942
 
976
    // Our array of webfont file types to register.
943
    // Our array of webfont file types to register.
977
    // As we want to keep things simple, we do not set a particular icon for these file types.
944
    // As we want to keep things simple, we do not set a particular icon for these file types.
978
    // Likewise, we do not set any type groups or use descriptions from the language pack.
945
    // Likewise, we do not set any type groups or use descriptions from the language pack.
979
    $webfonts = [
946
    $webfonts = [
980
        'eot' => [
947
            'eot' => [
981
            'extension' => 'eot',
948
                    'extension' => 'eot',
982
            'mimetype' => 'application/vnd.ms-fontobject',
949
                    'mimetype' => 'application/vnd.ms-fontobject',
983
            'coreicon' => 'unknown',
950
                    'coreicon' => 'unknown',
984
        ],
951
            ],
985
        'otf' => [
952
            'otf' => [
986
            'extension' => 'otf',
953
                    'extension' => 'otf',
987
            'mimetype' => 'font/otf',
954
                    'mimetype' => 'font/otf',
988
            'coreicon' => 'unknown',
955
                    'coreicon' => 'unknown',
989
        ],
956
            ],
990
        'svg' => [
957
            'svg' => [
991
            'extension' => 'svg',
958
                    'extension' => 'svg',
992
            'mimetype' => 'image/svg+xml',
959
                    'mimetype' => 'image/svg+xml',
993
            'coreicon' => 'unknown',
960
                    'coreicon' => 'unknown',
994
        ],
961
            ],
995
        'ttf' => [
962
            'ttf' => [
996
            'extension' => 'ttf',
963
                    'extension' => 'ttf',
997
            'mimetype' => 'font/ttf',
964
                    'mimetype' => 'font/ttf',
998
            'coreicon' => 'unknown',
965
                    'coreicon' => 'unknown',
999
        ],
966
            ],
1000
        'woff' => [
967
            'woff' => [
1001
            'extension' => 'woff',
968
                    'extension' => 'woff',
1002
            'mimetype' => 'font/woff',
969
                    'mimetype' => 'font/woff',
1003
            'coreicon' => 'unknown',
970
                    'coreicon' => 'unknown',
1004
        ],
971
            ],
1005
        'woff2' => [
972
            'woff2' => [
1006
            'extension' => 'woff2',
973
                    'extension' => 'woff2',
1007
            'mimetype' => 'font/woff2',
974
                    'mimetype' => 'font/woff2',
1008
            'coreicon' => 'unknown',
975
                    'coreicon' => 'unknown',
1009
        ],
976
            ],
Línea 1010... Línea 977...
1010
    ];
977
    ];
1011
 
978