[formats] Fix enclosures

All bridges failed due to missing 'enclosures' element in
the items array. With this commit all formats (ATOM, RSS
and HTML) provide support for a single 'enclosure' element
This commit is contained in:
logmanoriginal 2016-11-09 18:59:17 +01:00
parent 3a2cb9ea1e
commit 42cbc2e889
3 changed files with 22 additions and 8 deletions

View File

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

View File

@ -30,6 +30,13 @@ class HtmlFormat extends FormatAbstract {
. '</div>'; . '</div>';
} }
$entryEnclosure = '';
if(isset($item['enclosure'])){
$entryEnclosure = '<div class="enclosure"><a href="'
. $this->sanitizeHtml($item['enclosure'])
. '">enclosure</a><div>';
}
$entries .= <<<EOD $entries .= <<<EOD
<section class="feeditem"> <section class="feeditem">
@ -37,6 +44,7 @@ class HtmlFormat extends FormatAbstract {
{$entryTimestamp} {$entryTimestamp}
{$entryAuthor} {$entryAuthor}
{$entryContent} {$entryContent}
{$entryEnclosure}
</section> </section>
EOD; EOD;

View File

@ -30,9 +30,12 @@ class MrssFormat extends FormatAbstract {
$itemUri = isset($item['uri']) ? $this->xml_encode($item['uri']) : ''; $itemUri = isset($item['uri']) ? $this->xml_encode($item['uri']) : '';
$itemTimestamp = isset($item['timestamp']) ? $this->xml_encode(date(DATE_RFC2822, $item['timestamp'])) : ''; $itemTimestamp = isset($item['timestamp']) ? $this->xml_encode(date(DATE_RFC2822, $item['timestamp'])) : '';
$itemContent = isset($item['content']) ? $this->xml_encode($this->sanitizeHtml($item['content'])) : ''; $itemContent = isset($item['content']) ? $this->xml_encode($this->sanitizeHtml($item['content'])) : '';
$entryEnclosures = "";
foreach($item['enclosures'] as $enclosure) $entryEnclosure = '';
$entryEnclosures .= "<enclosure url=\"".$this->xml_encode($enclosure)."\"/>"; if(isset($item['enclosure'])){
$entryEnclosure = '<enclosure url="' . $this->xml_encode($item['enclosure']) . '"/>';
}
$items .= <<<EOD $items .= <<<EOD
<item> <item>
@ -42,7 +45,7 @@ class MrssFormat extends FormatAbstract {
<pubDate>{$itemTimestamp}</pubDate> <pubDate>{$itemTimestamp}</pubDate>
<description>{$itemContent}</description> <description>{$itemContent}</description>
<author>{$itemAuthor}</author> <author>{$itemAuthor}</author>
{$entryEnclosures} {$entryEnclosure}
</item> </item>
EOD; EOD;