mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-01 16:45:02 +02:00
[formats] Allow multiple enclosures
All formats now support multiple enclosures. RSS will show a warning if more than one enclosure is used since many feed reader don't support multiple enclosures with RSS (also not clearly specified in the specification)
This commit is contained in:
parent
14c689e7a3
commit
72f40fbd75
3 changed files with 44 additions and 15 deletions
|
@ -31,9 +31,23 @@ class MrssFormat extends FormatAbstract {
|
|||
$itemTimestamp = isset($item['timestamp']) ? $this->xml_encode(date(DATE_RFC2822, $item['timestamp'])) : '';
|
||||
$itemContent = isset($item['content']) ? $this->xml_encode($this->sanitizeHtml($item['content'])) : '';
|
||||
|
||||
$entryEnclosure = '';
|
||||
if(isset($item['enclosure'])){
|
||||
$entryEnclosure = '<enclosure url="' . $this->xml_encode($item['enclosure']) . '"/>';
|
||||
$entryEnclosuresWarning = '';
|
||||
$entryEnclosures = '';
|
||||
if(isset($item['enclosures'])){
|
||||
$entryEnclosures .= '<enclosure url="'
|
||||
. $this->xml_encode($item['enclosures'][0])
|
||||
. '"/>';
|
||||
|
||||
if(count($item['enclosures']) > 1){
|
||||
$entryEnclosures .= PHP_EOL;
|
||||
$entryEnclosuresWarning = '<br>Warning:
|
||||
Some media files might not be shown to you. Consider using the ATOM format instead!';
|
||||
foreach($item['enclosures'] as $enclosure){
|
||||
$entryEnclosures .= '<atom:link rel="enclosure" href="'
|
||||
. $enclosure . '" />'
|
||||
. PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$items .= <<<EOD
|
||||
|
@ -43,9 +57,9 @@ class MrssFormat extends FormatAbstract {
|
|||
<link>{$itemUri}</link>
|
||||
<guid isPermaLink="true">{$itemUri}</guid>
|
||||
<pubDate>{$itemTimestamp}</pubDate>
|
||||
<description>{$itemContent}</description>
|
||||
<description>{$itemContent}{$entryEnclosuresWarning}</description>
|
||||
<author>{$itemAuthor}</author>
|
||||
{$entryEnclosure}
|
||||
{$entryEnclosures}
|
||||
</item>
|
||||
|
||||
EOD;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue