Example #1
0
/**
 * Serves any files associated with the theme settings.
 *
 * @param stdClass $course
 * @param stdClass $cm
 * @param context $context
 * @param string $filearea
 * @param array $args
 * @param bool $forcedownload
 * @param array $options
 * @return bool
 */
function theme_essential_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
    static $theme;
    if (empty($theme)) {
        $theme = theme_config::load('essential');
    }
    if ($context->contextlevel == CONTEXT_SYSTEM) {
        if ($filearea === 'logo') {
            return $theme->setting_file_serve('logo', $args, $forcedownload, $options);
        } else if ($filearea === 'style') {
            theme_essential_serve_css($args[1]);
        } else if ($filearea === 'headerbackground') {
            return $theme->setting_file_serve('headerbackground', $args, $forcedownload, $options);
        } else if ($filearea === 'pagebackground') {
            return $theme->setting_file_serve('pagebackground', $args, $forcedownload, $options);
        } else if (preg_match("/^fontfile(eot|otf|svg|ttf|woff|woff2)(heading|body)$/", $filearea)) { // http://www.regexr.com/.
            return $theme->setting_file_serve($filearea, $args, $forcedownload, $options);
        } else if (preg_match("/^(marketing|slide)[1-9][0-9]*image$/", $filearea)) {
            return $theme->setting_file_serve($filearea, $args, $forcedownload, $options);
        } else if ($filearea === 'iphoneicon') {
            return $theme->setting_file_serve('iphoneicon', $args, $forcedownload, $options);
        } else if ($filearea === 'iphoneretinaicon') {
            return $theme->setting_file_serve('iphoneretinaicon', $args, $forcedownload, $options);
        } else if ($filearea === 'ipadicon') {
            return $theme->setting_file_serve('ipadicon', $args, $forcedownload, $options);
        } else if ($filearea === 'ipadretinaicon') {
            return $theme->setting_file_serve('ipadretinaicon', $args, $forcedownload, $options);
        } else {
            send_file_not_found();
        }
    } else {
        send_file_not_found();
    }
}
Example #2
0
File: lib.php Project: JOANMM/bcu
/**
 * Serves any files associated with the theme settings.
 *
 * @param stdClass $course
 * @param stdClass $cm
 * @param context $context
 * @param string $filearea
 * @param array $args
 * @param bool $forcedownload
 * @param array $options
 * @return bool
 */
function theme_bcu_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array())
{
    static $theme;
    if (empty($theme)) {
        $theme = theme_config::load('bcu');
    }
    if ($context->contextlevel == CONTEXT_SYSTEM) {
        if ($filearea === 'logo') {
            return $theme->setting_file_serve('logo', $args, $forcedownload, $options);
        } else {
            if ($filearea === 'style') {
                theme_essential_serve_css($args[1]);
            } else {
                if ($filearea === 'pagebackground') {
                    return $theme->setting_file_serve('pagebackground', $args, $forcedownload, $options);
                } else {
                    if (preg_match("/p[1-9][0-9]/", $filearea) !== false) {
                        return $theme->setting_file_serve($filearea, $args, $forcedownload, $options);
                    } else {
                        if (substr($filearea, 0, 9) === 'marketing' && substr($filearea, 10, 5) === 'image') {
                            return $theme->setting_file_serve($filearea, $args, $forcedownload, $options);
                        } else {
                            if ($filearea === 'iphoneicon') {
                                return $theme->setting_file_serve('iphoneicon', $args, $forcedownload, $options);
                            } else {
                                if ($filearea === 'iphoneretinaicon') {
                                    return $theme->setting_file_serve('iphoneretinaicon', $args, $forcedownload, $options);
                                } else {
                                    if ($filearea === 'ipadicon') {
                                        return $theme->setting_file_serve('ipadicon', $args, $forcedownload, $options);
                                    } else {
                                        if ($filearea === 'ipadretinaicon') {
                                            return $theme->setting_file_serve('ipadretinaicon', $args, $forcedownload, $options);
                                        } else {
                                            if ($filearea === 'fontfilettfheading') {
                                                return $theme->setting_file_serve('fontfilettfheading', $args, $forcedownload, $options);
                                            } else {
                                                if ($filearea === 'fontfilettfbody') {
                                                    return $theme->setting_file_serve('fontfilettfbody', $args, $forcedownload, $options);
                                                } else {
                                                    send_file_not_found();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    } else {
        send_file_not_found();
    }
}