mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Merged fix for rss enclosure notices from 1.8
This commit is contained in:
parent
e0af42ef0f
commit
909409b5ef
1 changed files with 12 additions and 2 deletions
|
@ -557,7 +557,12 @@ function rss_add_enclosures($item){
|
||||||
// take into account attachments (e.g. from forum) - with these, we are able to know the file size
|
// 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)) {
|
if (isset($item->attachments) && is_array($item->attachments)) {
|
||||||
foreach ($item->attachments as $attachment){
|
foreach ($item->attachments as $attachment){
|
||||||
$type = $mediafiletypes[substr($attachment->url, strrpos($attachment->url, '.')+1)]['type'];
|
$extension = strtolower(substr($attachment->url, strrpos($attachment->url, '.')+1));
|
||||||
|
if (isset($mediafiletypes[$extension]['type'])) {
|
||||||
|
$type = $mediafiletypes[$extension]['type'];
|
||||||
|
} else {
|
||||||
|
$type = 'document/unknown';
|
||||||
|
}
|
||||||
$returnstring .= "\n<enclosure url=\"$attachment->url\" length=\"$attachment->length\" type=\"$type\" />\n";
|
$returnstring .= "\n<enclosure url=\"$attachment->url\" length=\"$attachment->length\" type=\"$type\" />\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -569,7 +574,12 @@ function rss_add_enclosures($item){
|
||||||
// loop over matches of regular expression
|
// loop over matches of regular expression
|
||||||
for ($i = 0; $i < count($matches[2]); $i++){
|
for ($i = 0; $i < count($matches[2]); $i++){
|
||||||
$url = htmlspecialchars($matches[2][$i]);
|
$url = htmlspecialchars($matches[2][$i]);
|
||||||
$type = $mediafiletypes[strtolower($matches[3][$i])]['type'];
|
$extension = strtolower($matches[3][$i]);
|
||||||
|
if (isset($mediafiletypes[$extension]['type'])) {
|
||||||
|
$type = $mediafiletypes[$extension]['type'];
|
||||||
|
} else {
|
||||||
|
$type = 'document/unknown';
|
||||||
|
}
|
||||||
|
|
||||||
// the rss_*_tag functions can't deal with methods, unfortunately
|
// the rss_*_tag functions can't deal with methods, unfortunately
|
||||||
$returnstring .= "\n<enclosure url='$url' type='$type' />\n";
|
$returnstring .= "\n<enclosure url='$url' type='$type' />\n";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue