From ed449a9aaa08d507b92dad934239f4c371f5ca3e Mon Sep 17 00:00:00 2001 From: Jeffrey Tolar Date: Sun, 17 Nov 2013 17:58:43 -0600 Subject: [PATCH] Follow the spec for s Each section specifies multiple representations of the same content. --- classes/feeditem/atom.php | 25 ++++++++++++++++++++++++- classes/feeditem/rss.php | 25 ++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/classes/feeditem/atom.php b/classes/feeditem/atom.php index b7a228ae..5f0400fe 100644 --- a/classes/feeditem/atom.php +++ b/classes/feeditem/atom.php @@ -137,7 +137,7 @@ class FeedItem_Atom extends FeedItem_Common { } } - $enclosures = $this->xpath->query("media:content | media:group/media:content", $this->elem); + $enclosures = $this->xpath->query("media:content", $this->elem); foreach ($enclosures as $enclosure) { $enc = new FeedEnclosure(); @@ -152,6 +152,29 @@ class FeedItem_Atom extends FeedItem_Common { array_push($encs, $enc); } + + $enclosures = $this->xpath->query("media:group", $this->elem); + + foreach ($enclosures as $enclosure) { + $enc = new FeedEnclosure(); + + $content = $this->xpath->query("media:content", $enclosure)->item(0); + + $enc->type = $content->getAttribute("type"); + $enc->link = $content->getAttribute("url"); + $enc->length = $content->getAttribute("length"); + + $desc = $this->xpath->query("media:description", $content)->item(0); + if ($desc) { + $enc->title = strip_tags($desc->nodeValue); + } else { + $desc = $this->xpath->query("media:description", $enclosure)->item(0); + if ($desc) $enc->title = strip_tags($desc->nodeValue); + } + + array_push($encs, $enc); + } + return $encs; } diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index 1f59f061..b5d9695e 100644 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -112,7 +112,7 @@ class FeedItem_RSS extends FeedItem_Common { array_push($encs, $enc); } - $enclosures = $this->xpath->query("media:content | media:group/media:content", $this->elem); + $enclosures = $this->xpath->query("media:content", $this->elem); foreach ($enclosures as $enclosure) { $enc = new FeedEnclosure(); @@ -127,6 +127,29 @@ class FeedItem_RSS extends FeedItem_Common { array_push($encs, $enc); } + + $enclosures = $this->xpath->query("media:group", $this->elem); + + foreach ($enclosures as $enclosure) { + $enc = new FeedEnclosure(); + + $content = $this->xpath->query("media:content", $enclosure)->item(0); + + $enc->type = $content->getAttribute("type"); + $enc->link = $content->getAttribute("url"); + $enc->length = $content->getAttribute("length"); + + $desc = $this->xpath->query("media:description", $content)->item(0); + if ($desc) { + $enc->title = strip_tags($desc->nodeValue); + } else { + $desc = $this->xpath->query("media:description", $enclosure)->item(0); + if ($desc) $enc->title = strip_tags($desc->nodeValue); + } + + array_push($encs, $enc); + } + return $encs; } -- 2.39.5