From 42cbc2e8890f17fe7bb0c155d83c0558ac341a28 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Wed, 9 Nov 2016 18:59:17 +0100 Subject: [PATCH] [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 --- formats/AtomFormat.php | 11 +++++++---- formats/HtmlFormat.php | 8 ++++++++ formats/MrssFormat.php | 11 +++++++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/formats/AtomFormat.php b/formats/AtomFormat.php index 4168ff98..1944905f 100644 --- a/formats/AtomFormat.php +++ b/formats/AtomFormat.php @@ -26,9 +26,12 @@ class AtomFormat extends FormatAbstract{ $entryUri = isset($item['uri']) ? $this->xml_encode($item['uri']) : ''; $entryTimestamp = isset($item['timestamp']) ? $this->xml_encode(date(DATE_ATOM, $item['timestamp'])) : ''; $entryContent = isset($item['content']) ? $this->xml_encode($this->sanitizeHtml($item['content'])) : ''; - $entryEnclosures = ""; - foreach($item['enclosures'] as $enclosure) - $entryEnclosures .= "xml_encode($enclosure)."\"/>"; + + $entryEnclosure = ''; + if(isset($item['enclosure'])){ + $entryEnclosure = ''; + } + $entries .= << @@ -40,7 +43,7 @@ class AtomFormat extends FormatAbstract{ {$entryUri} {$entryTimestamp} {$entryContent} - {$entryEnclosures} + {$entryEnclosure} EOD; diff --git a/formats/HtmlFormat.php b/formats/HtmlFormat.php index b928d139..8f96466b 100644 --- a/formats/HtmlFormat.php +++ b/formats/HtmlFormat.php @@ -30,6 +30,13 @@ class HtmlFormat extends FormatAbstract { . ''; } + $entryEnclosure = ''; + if(isset($item['enclosure'])){ + $entryEnclosure = '
enclosure
'; + } + $entries .= << @@ -37,6 +44,7 @@ class HtmlFormat extends FormatAbstract { {$entryTimestamp} {$entryAuthor} {$entryContent} + {$entryEnclosure} EOD; diff --git a/formats/MrssFormat.php b/formats/MrssFormat.php index da75b77f..19c703ea 100644 --- a/formats/MrssFormat.php +++ b/formats/MrssFormat.php @@ -30,9 +30,12 @@ class MrssFormat extends FormatAbstract { $itemUri = isset($item['uri']) ? $this->xml_encode($item['uri']) : ''; $itemTimestamp = isset($item['timestamp']) ? $this->xml_encode(date(DATE_RFC2822, $item['timestamp'])) : ''; $itemContent = isset($item['content']) ? $this->xml_encode($this->sanitizeHtml($item['content'])) : ''; - $entryEnclosures = ""; - foreach($item['enclosures'] as $enclosure) - $entryEnclosures .= "xml_encode($enclosure)."\"/>"; + + $entryEnclosure = ''; + if(isset($item['enclosure'])){ + $entryEnclosure = ''; + } + $items .= << @@ -42,7 +45,7 @@ class MrssFormat extends FormatAbstract { {$itemTimestamp} {$itemContent} {$itemAuthor} - {$entryEnclosures} + {$entryEnclosure} EOD;