diff options
Diffstat (limited to 'formats/AtomFormat.php')
-rw-r--r-- | formats/AtomFormat.php | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/formats/AtomFormat.php b/formats/AtomFormat.php index 9886e4b7..d59e42fe 100644 --- a/formats/AtomFormat.php +++ b/formats/AtomFormat.php @@ -16,6 +16,8 @@ class AtomFormat extends FormatAbstract public function stringify() { + $document = new \DomDocument('1.0', $this->getCharset()); + $feedUrl = get_current_url(); $extraInfos = $this->getExtraInfos(); @@ -25,7 +27,6 @@ class AtomFormat extends FormatAbstract $uri = $extraInfos['uri']; } - $document = new \DomDocument('1.0', $this->getCharset()); $document->formatOutput = true; $feed = $document->createElementNS(self::ATOM_NS, 'feed'); $document->appendChild($feed); @@ -81,6 +82,7 @@ class AtomFormat extends FormatAbstract $linkSelf->setAttribute('href', $feedUrl); foreach ($this->getItems() as $item) { + $itemArray = $item->toArray(); $entryTimestamp = $item->getTimestamp(); $entryTitle = $item->getTitle(); $entryContent = $item->getContent(); @@ -138,7 +140,19 @@ class AtomFormat extends FormatAbstract $entry->appendChild($id); $id->appendChild($document->createTextNode($entryID)); - if (!empty($entryUri)) { + if (isset($itemArray['itunes'])) { + $feed->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:itunes', self::ITUNES_NS); + foreach ($itemArray['itunes'] as $itunesKey => $itunesValue) { + $itunesProperty = $document->createElementNS(self::ITUNES_NS, $itunesKey); + $entry->appendChild($itunesProperty); + $itunesProperty->appendChild($document->createTextNode($itunesValue)); + } + $itunesEnclosure = $document->createElement('enclosure'); + $entry->appendChild($itunesEnclosure); + $itunesEnclosure->setAttribute('url', $itemArray['enclosure']['url']); + $itunesEnclosure->setAttribute('length', $itemArray['enclosure']['length']); + $itunesEnclosure->setAttribute('type', $itemArray['enclosure']['type']); + } elseif (!empty($entryUri)) { $entryLinkAlternate = $document->createElement('link'); $entry->appendChild($entryLinkAlternate); $entryLinkAlternate->setAttribute('rel', 'alternate'); |