Skip to content

Instantly share code, notes, and snippets.

@andrewnicols
Created November 9, 2011 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewnicols/7fdcb8d2839f2c1e7f3e to your computer and use it in GitHub Desktop.
Save andrewnicols/7fdcb8d2839f2c1e7f3e to your computer and use it in GitHub Desktop.
diff --git a/mod/resource/locallib.php b/mod/resource/locallib.php
index 41b77cc..cedaac7 100644
--- a/mod/resource/locallib.php
+++ b/mod/resource/locallib.php
@@ -75,45 +75,10 @@ function resource_display_embed($resource, $cm, $course, $file) {
$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);
- }
+ $link = (html_writer::link($fullurl, $fullurl));
+ $fm = filter_manager::instance();
+ $text = $fm->filter_text($link, $context);
+ $code = html_writer::tag('div', $text, array('class' => 'resourcecontent'));
resource_print_header($resource, $cm, $course);
resource_print_heading($resource, $cm, $course);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment