Follow the spec for <media:group>s

Each <media:group> section specifies multiple representations of the
same content.
This commit is contained in:
Jeffrey Tolar 2013-11-17 17:58:43 -06:00
parent 15d8bd7dbf
commit ed449a9aaa
2 changed files with 48 additions and 2 deletions

View File

@ -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) { foreach ($enclosures as $enclosure) {
$enc = new FeedEnclosure(); $enc = new FeedEnclosure();
@ -152,6 +152,29 @@ class FeedItem_Atom extends FeedItem_Common {
array_push($encs, $enc); 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; return $encs;
} }

View File

@ -112,7 +112,7 @@ class FeedItem_RSS extends FeedItem_Common {
array_push($encs, $enc); 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) { foreach ($enclosures as $enclosure) {
$enc = new FeedEnclosure(); $enc = new FeedEnclosure();
@ -127,6 +127,29 @@ class FeedItem_RSS extends FeedItem_Common {
array_push($encs, $enc); 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; return $encs;
} }