From 6db0338e0ef49ee907390c207680c09a504007c7 Mon Sep 17 00:00:00 2001 From: moodler Date: Mon, 5 Mar 2007 16:43:40 +0000 Subject: [PATCH] Merged rss mediatypes fix from 1.8 --- lib/rsslib.php | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/lib/rsslib.php b/lib/rsslib.php index f3f333b5ab..b530dbb8a7 100644 --- a/lib/rsslib.php +++ b/lib/rsslib.php @@ -542,23 +542,14 @@ onClick=\"window.open('http://feedvalidator.org/check.cgi?url='+getElementId('bl */ function rss_add_enclosures($item){ + global $CFG; + $returnstring = ''; $rss_text = $item->description; // list of media file extensions and their respective mime types - // could/should we put this to some more central place? - $mediafiletypes = array( - 'mp3' => 'audio/mpeg', - 'm3u' => 'audio/x-mpegurl', - 'pls' => 'audio/x-mpegurl', - 'ogg' => 'application/ogg', - 'm4b' => 'audio/x-m4b', - 'mpeg' => 'video/mpg', - 'mpg' => 'video/mpg', - 'mov' => 'video/quicktime', - 'avi' => 'video/x-msvideo', - 'wmv' => 'video/x-msvideo' - ); + include_once($CFG->libdir.'/filelib.php'); + $mediafiletypes = get_mimetypes_array(); // regular expression (hopefully) matching all links to media files $medialinkpattern = '@href\s*=\s*(\'|")(\S+(' . implode('|', array_keys($mediafiletypes)) . '))\1@Usie'; @@ -566,7 +557,7 @@ function rss_add_enclosures($item){ // take into account attachments (e.g. from forum) - with these, we are able to know the file size if (isset($item->attachments) && is_array($item->attachments)) { foreach ($item->attachments as $attachment){ - $type = $mediafiletypes[substr($attachment->url, strrpos($attachment->url, '.')+1)]; + $type = $mediafiletypes[substr($attachment->url, strrpos($attachment->url, '.')+1)]['type']; $returnstring .= "\nurl\" length=\"$attachment->length\" type=\"$type\" />\n"; } } @@ -578,7 +569,7 @@ function rss_add_enclosures($item){ // loop over matches of regular expression for ($i = 0; $i < count($matches[2]); $i++){ $url = htmlspecialchars($matches[2][$i]); - $type = $mediafiletypes[strtolower($matches[3][$i])]; + $type = $mediafiletypes[strtolower($matches[3][$i])]['type']; // the rss_*_tag functions can't deal with methods, unfortunately $returnstring .= "\n\n"; -- 2.39.5