[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:
logmanoriginal 2016-11-12 22:04:42 +01:00
parent 14c689e7a3
commit 72f40fbd75
3 changed files with 44 additions and 15 deletions

View file

@ -27,9 +27,14 @@ class AtomFormat extends FormatAbstract{
$entryTimestamp = isset($item['timestamp']) ? $this->xml_encode(date(DATE_ATOM, $item['timestamp'])) : '';
$entryContent = isset($item['content']) ? $this->xml_encode($this->sanitizeHtml($item['content'])) : '';
$entryEnclosure = '';
if(isset($item['enclosure'])){
$entryEnclosure = '<link rel="enclosure" href="' . $this->xml_encode($item['enclosure']) . '"/>';
$entryEnclosures = '';
if(isset($item['enclosures'])){
foreach($item['enclosures'] as $enclosure){
$entryEnclosures .= '<link rel="enclosure" href="'
. $this->xml_encode($enclosure)
. '"/>'
. PHP_EOL;
}
}
$entries .= <<<EOD
@ -43,7 +48,7 @@ class AtomFormat extends FormatAbstract{
<id>{$entryUri}</id>
<updated>{$entryTimestamp}</updated>
<content type="html">{$entryContent}</content>
{$entryEnclosure}
{$entryEnclosures}
</entry>
EOD;