From: danstowell
Date: Tue, 21 Mar 2006 22:35:23 +0000 (+0000)
Subject: Minor changes to RSSlib - main change is augnmented PHPdoc for the issues in RSS...
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=069b6daf76c4c29ca6fa2d0ba2de0e11f5cbc62a;p=moodle.git
Minor changes to RSSlib - main change is augnmented PHPdoc for the issues in RSS enclosures
---
diff --git a/lib/rsslib.php b/lib/rsslib.php
index 7d91b29c06..81d482cbb8 100644
--- a/lib/rsslib.php
+++ b/lib/rsslib.php
@@ -219,7 +219,7 @@ function rss_add_items($items) {
}
$result .= rss_full_tag('title',3,false,$item->title);
$result .= rss_full_tag('link',3,false,$item->link);
- $result .= '' . utf8_encode(htmlspecialchars($item->link)) . '';
+ $result .= rss_add_enclosures($item);
$result .= rss_full_tag('pubDate',3,false,date('D, d M Y H:i:s T',$item->pubdate));
//Include the author if exists
if (isset($item->author)) {
@@ -230,7 +230,7 @@ function rss_add_items($items) {
$item->description = get_string('byname','',$item->author).'. '.$item->description.'
';
}
$result .= rss_full_tag('description',3,false,$item->description);
- $result .= rss_add_enclosures($item);
+ $result .= " " . utf8_encode(htmlspecialchars($item->link)) . "\n";
$result .= rss_end_tag('item',2,true);
}
@@ -512,11 +512,22 @@ onClick=\"window.open('http://feedvalidator.org/check.cgi?url='+document.block_r
/**
-* Adds RSS Media Enclosures for "podcasting" by examining links to media files
+* Adds RSS Media Enclosures for "podcasting" by examining links to media files,
+* and attachments which are media files. Please note that the RSS that is
+* produced cannot be strictly valid for the linked files, since we do not know
+* the files' sizes and cannot include them in the "length" attribute. At
+* present, the validity (and therefore the podcast working in most software)
+* can only be ensured for attachments, and not for links.
+* Note also that iTunes does some things very badly - one thing it does is
+* refuse to download ANY of your files if you're using "file.php?file=blah"
+* and can't use the more elegant "file.php/blah" slasharguments setting. It
+* stops after ".php" and assumes the files are not media files, despite what
+* is specified in the "type" attribute. Dodgy coding all round!
*
* @param $item object representing an RSS item
* @return string RSS enclosure tags
* @author Hannes Gassert
+* @author Dan Stowell
*/
function rss_add_enclosures($item){
@@ -545,7 +556,7 @@ function rss_add_enclosures($item){
if (isset($item->attachments) && is_array($item->attachments)) {
foreach ($item->attachments as $attachment){
$type = $mediafiletypes[substr($attachment->url, strrpos($attachment->url, '.')+1)];
- $returnstring .= "\n\n";
+ $returnstring .= "\nurl\" length=\"$attachment->length\" type=\"$type\" />\n";
}
}