当前位置: 首页>>代码示例>>PHP>>正文


PHP resourcelib_guess_url_mimetype函数代码示例

本文整理汇总了PHP中resourcelib_guess_url_mimetype函数的典型用法代码示例。如果您正苦于以下问题:PHP resourcelib_guess_url_mimetype函数的具体用法?PHP resourcelib_guess_url_mimetype怎么用?PHP resourcelib_guess_url_mimetype使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了resourcelib_guess_url_mimetype函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: url_get_final_display_type

/**
 * Decide the best display format.
 * @param object $url
 * @return int display type constant
 */
function url_get_final_display_type($url)
{
    global $CFG;
    if ($url->display != RESOURCELIB_DISPLAY_AUTO) {
        return $url->display;
    }
    // detect links to local moodle pages
    if (strpos($url->externalurl, $CFG->wwwroot) === 0) {
        if (strpos($url->externalurl, 'file.php') === false and strpos($url->externalurl, '.php') !== false) {
            // most probably our moodle page with navigation
            return RESOURCELIB_DISPLAY_OPEN;
        }
    }
    static $download = array('application/zip', 'application/x-tar', 'application/g-zip', 'application/pdf', 'text/html');
    // these are known to cause trouble for external links, sorry
    static $embed = array('image/gif', 'image/jpeg', 'image/png', 'image/svg+xml', 'application/x-shockwave-flash', 'video/x-flv', 'video/x-ms-wm', 'video/quicktime', 'video/mpeg', 'video/mp4', 'audio/mp3', 'audio/x-realaudio-plugin', 'x-realaudio-plugin');
    $mimetype = resourcelib_guess_url_mimetype($url->externalurl);
    if (in_array($mimetype, $download)) {
        return RESOURCELIB_DISPLAY_DOWNLOAD;
    }
    if (in_array($mimetype, $embed)) {
        return RESOURCELIB_DISPLAY_EMBED;
    }
    // let the browser deal with it somehow
    return RESOURCELIB_DISPLAY_OPEN;
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:31,代码来源:locallib.php

示例2: lesson_get_media_html

/**
 * This is a function used to detect media types and generate html code.
 *
 * @global object $CFG
 * @global object $PAGE
 * @param object $lesson
 * @param object $context
 * @return string $code the html code of media
 */
function lesson_get_media_html($lesson, $context)
{
    global $CFG, $PAGE, $OUTPUT;
    require_once "{$CFG->libdir}/resourcelib.php";
    // get the media file link
    if (strpos($lesson->mediafile, '://') !== false) {
        $url = new moodle_url($lesson->mediafile);
    } else {
        // the timemodified is used to prevent caching problems, instead of '/' we should better read from files table and use sortorder
        $url = moodle_url::make_pluginfile_url($context->id, 'mod_lesson', 'mediafile', $lesson->timemodified, '/', ltrim($lesson->mediafile, '/'));
    }
    $title = $lesson->mediafile;
    $clicktoopen = html_writer::link($url, get_string('download'));
    $mimetype = resourcelib_guess_url_mimetype($url);
    $extension = resourcelib_get_extension($url->out(false));
    $mediarenderer = $PAGE->get_renderer('core', 'media');
    $embedoptions = array(core_media::OPTION_TRUSTED => true, core_media::OPTION_BLOCK => true);
    // find the correct type and print it out
    if (in_array($mimetype, array('image/gif', 'image/jpeg', 'image/png'))) {
        // It's an image
        $code = resourcelib_embed_image($url, $title);
    } else {
        if ($mediarenderer->can_embed_url($url, $embedoptions)) {
            // Media (audio/video) file.
            $code = $mediarenderer->embed_url($url, $title, 0, 0, $embedoptions);
        } else {
            // anything else - just try object tag enlarged as much as possible
            $code = resourcelib_embed_general($url, $title, $clicktoopen, $mimetype);
        }
    }
    return $code;
}
开发者ID:nikitskynikita,项目名称:moodle,代码行数:41,代码来源:locallib.php

示例3: lesson_get_media_html

/**
 * This is a function used to detect media types and generate html code.
 *
 * @global object $CFG
 * @global object $PAGE
 * @param object $lesson
 * @param object $context
 * @return string $code the html code of media
 */
function lesson_get_media_html($lesson, $context)
{
    global $CFG, $PAGE, $OUTPUT;
    require_once "{$CFG->libdir}/resourcelib.php";
    // get the media file link
    if (strpos($lesson->mediafile, '://') !== false) {
        $url = new moodle_url($lesson->mediafile);
    } else {
        // the timemodified is used to prevent caching problems, instead of '/' we should better read from files table and use sortorder
        $url = moodle_url::make_pluginfile_url($context->id, 'mod_lesson', 'mediafile', $lesson->timemodified, '/', ltrim($lesson->mediafile, '/'));
    }
    $title = $lesson->mediafile;
    $clicktoopen = html_writer::link($url, get_string('download'));
    $mimetype = resourcelib_guess_url_mimetype($url);
    $extension = resourcelib_get_extension($url->out(false));
    // find the correct type and print it out
    if (in_array($mimetype, array('image/gif', 'image/jpeg', 'image/png'))) {
        // It's an image
        $code = resourcelib_embed_image($url, $title);
    } else {
        if ($mimetype == 'audio/mp3') {
            // MP3 audio file
            $code = resourcelib_embed_mp3($url, $title, $clicktoopen);
        } else {
            if ($mimetype == 'video/x-flv' or $extension === 'f4v') {
                // Flash video file
                $code = resourcelib_embed_flashvideo($url, $title, $clicktoopen);
            } else {
                if ($mimetype == 'application/x-shockwave-flash') {
                    // Flash file
                    $code = resourcelib_embed_flash($url, $title, $clicktoopen);
                } else {
                    if (substr($mimetype, 0, 10) == 'video/x-ms') {
                        // Windows Media Player file
                        $code = resourcelib_embed_mediaplayer($url, $title, $clicktoopen);
                    } else {
                        if ($mimetype == 'video/quicktime') {
                            // Quicktime file
                            $code = resourcelib_embed_quicktime($url, $title, $clicktoopen);
                        } else {
                            if ($mimetype == 'video/mpeg') {
                                // Mpeg file
                                $code = resourcelib_embed_mpeg($url, $title, $clicktoopen);
                            } else {
                                if ($mimetype == 'audio/x-pn-realaudio-plugin') {
                                    // RealMedia file
                                    $code = resourcelib_embed_real($url, $title, $clicktoopen);
                                } else {
                                    // anything else - just try object tag enlarged as much as possible
                                    $code = resourcelib_embed_general($url, $title, $clicktoopen, $mimetype);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return $code;
}
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:69,代码来源:locallib.php

示例4: url_display_embed

/**
 * Display embedded url file.
 * @param object $url
 * @param object $cm
 * @param object $course
 * @param stored_file $file main file
 * @return does not return
 */
function url_display_embed($url, $cm, $course)
{
    global $CFG, $PAGE, $OUTPUT;
    $mimetype = resourcelib_guess_url_mimetype($url->externalurl);
    $fullurl = url_get_full_url($url, $cm, $course);
    $title = $url->name;
    $link = html_writer::tag('a', $fullurl, array('href' => str_replace('&', '&', $fullurl)));
    $clicktoopen = get_string('clicktoopen', 'url', $link);
    if (in_array($mimetype, array('image/gif', 'image/jpeg', 'image/png'))) {
        // It's an image
        $code = resourcelib_embed_image($fullurl, $title);
    } else {
        if ($mimetype == 'audio/mp3') {
            // MP3 audio file
            $code = resourcelib_embed_mp3($fullurl, $title, $clicktoopen);
        } else {
            if ($mimetype == 'video/x-flv') {
                // Flash video file
                $code = resourcelib_embed_flashvideo($fullurl, $title, $clicktoopen);
            } else {
                if ($mimetype == 'application/x-shockwave-flash') {
                    // Flash file
                    $code = resourcelib_embed_flash($fullurl, $title, $clicktoopen);
                } else {
                    if (substr($mimetype, 0, 10) == 'video/x-ms') {
                        // Windows Media Player file
                        $code = resourcelib_embed_mediaplayer($fullurl, $title, $clicktoopen);
                    } else {
                        if ($mimetype == 'video/quicktime') {
                            // Quicktime file
                            $code = resourcelib_embed_quicktime($fullurl, $title, $clicktoopen);
                        } else {
                            if ($mimetype == 'video/mpeg') {
                                // Mpeg file
                                $code = resourcelib_embed_mpeg($fullurl, $title, $clicktoopen);
                            } else {
                                if ($mimetype == 'audio/x-pn-realaudio-plugin') {
                                    // RealMedia file
                                    $code = resourcelib_embed_real($fullurl, $title, $clicktoopen);
                                } else {
                                    // anything else - just try object tag enlarged as much as possible
                                    $code = resourcelib_embed_general($fullurl, $title, $clicktoopen, $mimetype);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    url_print_header($url, $cm, $course);
    url_print_heading($url, $cm, $course);
    echo $code;
    url_print_intro($url, $cm, $course);
    echo $OUTPUT->footer();
    die;
}
开发者ID:vuchannguyen,项目名称:web,代码行数:65,代码来源:locallib.php

示例5: url_display_embed

/**
 * Display embedded url file.
 * @param object $url
 * @param object $cm
 * @param object $course
 * @param stored_file $file main file
 * @return does not return
 */
function url_display_embed($url, $cm, $course)
{
    global $CFG, $PAGE;
    $clicktoopen = get_string('clicktoopen', 'url', $url->externalurl);
    $mimetype = resourcelib_guess_url_mimetype($url->externalurl);
    $fullurl = url_get_full_url($url, $cm, $course);
    $title = $url->name;
    if (in_array($mimetype, array('image/gif', 'image/jpeg', 'image/png'))) {
        // It's an image
        $code = resourcelib_embed_image($fullurl, $title);
    } else {
        if ($mimetype == 'audio/mp3') {
            // MP3 audio file
            $code = resourcelib_embed_mp3($fullurl, $title, $clicktoopen);
        } else {
            if ($mimetype == 'video/x-flv') {
                // Flash video file
                $code = resourcelib_embed_flashvideo($fullurl, $title, $clicktoopen);
            } else {
                if ($mimetype == 'application/x-shockwave-flash') {
                    // Flash file
                    $code = resourcelib_embed_flash($fullurl, $title, $clicktoopen);
                } else {
                    if (substr($mimetype, 0, 10) == 'video/x-ms') {
                        // Windows Media Player file
                        $code = resourcelib_embed_mediaplayer($fullurl, $title, $clicktoopen);
                    } else {
                        if ($mimetype == 'video/quicktime') {
                            // Quicktime file
                            $code = resourcelib_embed_quicktime($fullurl, $title, $clicktoopen);
                        } else {
                            if ($mimetype == 'video/mpeg') {
                                // Mpeg file
                                $code = resourcelib_embed_mpeg($fullurl, $title, $clicktoopen);
                            } else {
                                if ($mimetype == 'audio/x-pn-realaudio') {
                                    // RealMedia file
                                    $code = resourcelib_embed_real($fullurl, $title, $clicktoopen);
                                } else {
                                    // anything else - just try object tag enlarged as much as possible
                                    $code = resourcelib_embed_general($fullurl, $title, $clicktoopen, $mimetype);
                                    $PAGE->requires->yui_lib('dom')->in_head();
                                    $PAGE->requires->js('mod/url/functions.js')->in_head();
                                    $PAGE->requires->js_function_call('url_init_object');
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    url_print_header($url, $cm, $course);
    url_print_heading($url, $cm, $course);
    echo $code;
    url_print_intro($url, $cm, $course);
    print_footer();
    die;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:67,代码来源:locallib.php


注:本文中的resourcelib_guess_url_mimetype函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。