/** * 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; }
); $event = \mod_url\event\course_module_viewed::create($params); $event->add_record_snapshot('url', $url); $event->trigger(); // Update 'viewed' state if required by completion system $completion = new completion_info($course); $completion->set_module_viewed($cm); $PAGE->set_url('/mod/url/view.php', array('id' => $cm->id)); // Make sure URL exists before generating output - some older sites may contain empty urls // Do not use PARAM_URL here, it is too strict and does not support general URIs! $exturl = trim($url->externalurl); if (empty($exturl) or $exturl === 'http://') { url_print_header($url, $cm, $course); url_print_heading($url, $cm, $course); url_print_intro($url, $cm, $course); notice(get_string('invalidstoredurl', 'url'), new moodle_url('/course/view.php', array('id'=>$cm->course))); die; } unset($exturl); $displaytype = url_get_final_display_type($url); if ($displaytype == RESOURCELIB_DISPLAY_OPEN) { // For 'open' links, we always redirect to the content - except if the user // just chose 'save and display' from the form then that would be confusing if (!isset($_SERVER['HTTP_REFERER']) || strpos($_SERVER['HTTP_REFERER'], 'modedit.php') === false) { $redirect = true; } }
/** * 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; }
/** * 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; }