本文整理汇总了PHP中resourcelib_get_extension函数的典型用法代码示例。如果您正苦于以下问题:PHP resourcelib_get_extension函数的具体用法?PHP resourcelib_get_extension怎么用?PHP resourcelib_get_extension使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resourcelib_get_extension函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resource_display_embed
/**
* Display embedded resource file.
* @param object $resource
* @param object $cm
* @param object $course
* @param stored_file $file main file
* @return does not return
*/
function resource_display_embed($resource, $cm, $course, $file) {
global $CFG, $PAGE, $OUTPUT;
$clicktoopen = resource_get_clicktoopen($file, $resource->revision);
$context = context_module::instance($cm->id);
$path = '/'.$context->id.'/mod_resource/content/'.$resource->revision.$file->get_filepath().$file->get_filename();
$fullurl = file_encode_url($CFG->wwwroot.'/pluginfile.php', $path, false);
$moodleurl = new moodle_url('/pluginfile.php' . $path);
$mimetype = $file->get_mimetype();
$title = $resource->name;
$extension = resourcelib_get_extension($file->get_filename());
$mediarenderer = $PAGE->get_renderer('core', 'media');
$embedoptions = array(
core_media::OPTION_TRUSTED => true,
core_media::OPTION_BLOCK => true,
);
if (file_mimetype_in_typegroup($mimetype, 'web_image')) { // It's an image
$code = resourcelib_embed_image($fullurl, $title);
} else if ($mimetype === 'application/pdf') {
// PDF document
$code = resourcelib_embed_pdf($fullurl, $title, $clicktoopen);
} else if ($mediarenderer->can_embed_url($moodleurl, $embedoptions)) {
// Media (audio/video) file.
$code = $mediarenderer->embed_url($moodleurl, $title, 0, 0, $embedoptions);
} else {
// anything else - just try object tag enlarged as much as possible
$code = resourcelib_embed_general($fullurl, $title, $clicktoopen, $mimetype);
}
resource_print_header($resource, $cm, $course);
resource_print_heading($resource, $cm, $course);
echo $code;
resource_print_intro($resource, $cm, $course);
echo $OUTPUT->footer();
die;
}
示例2: url_display_embed
/**
* Display embedded url file.
* @param object $url
* @param object $cm
* @param object $course
* @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);
$moodleurl = new moodle_url($fullurl);
$extension = resourcelib_get_extension($url->externalurl);
$mediamanager = core_media_manager::instance();
$embedoptions = array(core_media_manager::OPTION_TRUSTED => true, core_media_manager::OPTION_BLOCK => true);
if (in_array($mimetype, array('image/gif', 'image/jpeg', 'image/png'))) {
// It's an image
$code = resourcelib_embed_image($fullurl, $title);
} else {
if ($mediamanager->can_embed_url($moodleurl, $embedoptions)) {
// Media (audio/video) file.
$code = $mediamanager->embed_url($moodleurl, $title, 0, 0, $embedoptions);
} 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;
}
示例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));
$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;
}
示例4: mediaelementjs_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 mediaelementjs_display_embed($url, $cm, $course)
{
global $CFG, $PAGE, $OUTPUT;
$mimetype = resourcelib_guess_url_mimetype($url->externalurl);
$cloud_storage_mimetype = mediaelementjs_guess_cloud_storage_mimetype($url->externalurl);
if ($cloud_storage_mimetype) {
$mimetype = $cloud_storage_mimetype;
}
$fullurl = mediaelementjs_get_full_url($url, $cm, $course);
$title = $url->name;
$link = html_writer::tag('a', $fullurl, array('href' => str_replace('&', '&', $fullurl)));
$clicktoopen = get_string('clicktoopen', 'mediaelementjs', $link);
$extension = resourcelib_get_extension($url->externalurl);
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' || $mimetype == 'audio/x-pn-realaudio-plugin') {
// MP3 audio file
$code = GcrFileLib::getAudioEmbedHtml($fullurl, $mimetype);
} else {
if ($mimetype == 'application/x-shockwave-flash') {
// Flash file
$code = resourcelib_embed_flash($fullurl, $title, $clicktoopen);
} else {
if ($mimetype == 'video/x-ms' || $mimetype == 'video/mpeg' || $mimetype == 'video/quicktime' || $mimetype == 'video/webm' || $mimetype == 'video/ogv' || $mimetype == 'video/ogg' || $mimetype == 'video/mp4') {
$code = GcrFileLib::getVideoEmbedHtml($fullurl, '100%', '100%', $mimetype);
} else {
// anything else - just try object tag enlarged as much as possible
$code = resourcelib_embed_general($fullurl, $title, $clicktoopen, $mimetype);
}
}
}
}
mediaelementjs_print_header($url, $cm, $course);
mediaelementjs_print_heading($url, $cm, $course);
echo $code;
mediaelementjs_print_intro($url, $cm, $course);
echo $OUTPUT->footer();
die;
}
示例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, $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);
$extension = resourcelib_get_extension($url->externalurl);
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' or $extension === 'f4v') {
// 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;
}
示例6: 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;
}
示例7: resource_display_embed
/**
* Display embedded resource file.
* @param object $resource
* @param object $cm
* @param object $course
* @param stored_file $file main file
* @return does not return
*/
function resource_display_embed($resource, $cm, $course, $file)
{
global $CFG, $PAGE, $OUTPUT;
$clicktoopen = resource_get_clicktoopen($file, $resource->revision);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$path = '/' . $context->id . '/mod_resource/content/' . $resource->revision . $file->get_filepath() . $file->get_filename();
$fullurl = file_encode_url($CFG->wwwroot . '/pluginfile.php', $path, false);
$mimetype = $file->get_mimetype();
$title = $resource->name;
$extension = resourcelib_get_extension($file->get_filename());
if (in_array($mimetype, array('image/gif', 'image/jpeg', 'image/png'))) {
// It's an image
$code = resourcelib_embed_image($fullurl, $title);
} else {
if ($mimetype === 'application/pdf') {
// PDF document
$code = resourcelib_embed_pdf($fullurl, $title, $clicktoopen);
} else {
if ($mimetype === 'audio/mp3') {
// MP3 audio file
$code = resourcelib_embed_mp3($fullurl, $title, $clicktoopen);
} else {
if ($mimetype === 'video/x-flv' or $extension === 'f4v') {
// 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);
}
}
}
}
}
}
}
}
}
resource_print_header($resource, $cm, $course);
resource_print_heading($resource, $cm, $course);
echo $code;
resource_print_intro($resource, $cm, $course);
echo $OUTPUT->footer();
die;
}
示例8: flexpaper_display_embed
/**
* Display embedded flexpaper file.
* @param object $flexpaper
* @param object $cm
* @param object $course
* @param stored_file $file main file
* @return does not return
*/
function flexpaper_display_embed($flexpaper, $cm, $course, $file) {
global $CFG, $PAGE, $OUTPUT,$DB;
$clicktoopen = flexpaper_get_clicktoopen($file, $flexpaper->revision);
$context = context_module::instance($cm->id);
$path = '/'.$context->id.'/mod_flexpaper/content/'.$flexpaper->revision.$file->get_filepath().$file->get_filename();
$fullurl = file_encode_url($CFG->wwwroot.'/pluginfile.php', $path, false);
$moodleurl = new moodle_url('/pluginfile.php' . $path);
$mimetype = $file->get_mimetype();
$title = $flexpaper->name;
$extension = resourcelib_get_extension($file->get_filename());
$mediarenderer = $PAGE->get_renderer('core', 'media');
// if (file_mimetype_in_typegroup($mimetype, 'web_image')) { // It's an image
// $code = flexpaperlib_embed_image($fullurl, $title);
//
// } else if ($mimetype === 'application/pdf') {
// // PDF document
// $code = resourcelib_embed_pdf($fullurl, $title, $clicktoopen);
//
// } else if ($mediarenderer->can_embed_url($moodleurl, $embedoptions)) {
// // Media (audio/video) file.
// $code = $mediarenderer->embed_url($moodleurl, $title, 0, 0, $embedoptions);
//
// } else {
// // anything else - just try object tag enlarged as much as possible
// $code = resourcelib_embed_general($fullurl, $title, $clicktoopen, $mimetype);
// }
//print_object($code);
flexpaper_print_header($flexpaper, $cm, $course);
// flexpaper_print_heading($flexpaper, $cm, $course);
// echo $code;
echo '<div id="documentViewer" class="flexpaper_viewer" style="position:relative;width:100%;height:100%;"></div>';
$key=$DB->get_field('config_plugins','value',array('name'=>'key','plugin'=>'flexpaper'));
?>
<script type="text/javascript" src="<?php echo $CFG->wwwroot.'/mod/flexpaper/js/jquery.min.js';?>"></script>
<script type="text/javascript" src="<?php echo $CFG->wwwroot.'/mod/flexpaper/js/jquery.extensions.min.js';?>"></script>
<!--[if gte IE 10 | !IE ]><!-->
<script type="text/javascript" src="<?php echo $CFG->wwwroot.'/mod/flexpaper/js/three.min.js';?>"></script>
<!--<![endif]-->
<script type="text/javascript" src="<?php echo $CFG->wwwroot.'/mod/flexpaper/js/flexpaper.js';?>"></script>
<script type="text/javascript" src="<?php echo $CFG->wwwroot.'/mod/flexpaper/js/flexpaper_handlers.js';?>"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $CFG->wwwroot.'/mod/flexpaper/css/flexpaper.css';?>" />
<script type="text/javascript">
$('#documentViewer').FlexPaperViewer(
{ config : {
IMGFiles : 'pdf/12.png',
PDFFile : '<?php echo $fullurl;?>',
Scale : 0.6,
ZoomTransition : 'easeOut',
ZoomTime : 0.5,
ZoomInterval : 0.1,
FitPageOnLoad : true,
FitWidthOnLoad : false,
FullScreenAsMaxWindow : false,
ProgressiveLoading : false,
MinZoomSize : 0.2,
MaxZoomSize : 5,
SearchMatchAll : false,
InitViewMode : '',
MixedMode : false,
EnableWebGL : true,
ViewModeToolsVisible : true,
ZoomToolsVisible : true,
NavToolsVisible : true,
CursorToolsVisible : true,
SearchToolsVisible : true,
JSONDataType : 'jsonp',
key : '<?php echo $key; ?>',
WMode : 'transparent',
localeChain: 'en_US'
}}
);
</script>
<?php
//flexpaper_print_intro($flexpaper, $cm, $course);
echo $OUTPUT->footer();
die;
}