parser: fix failing on empty media:group tags

This commit is contained in:
Andrew Dolgov 2014-01-12 08:53:30 +04:00
parent de0d8d1088
commit 2ab7ccb695
2 changed files with 26 additions and 22 deletions

View file

@ -160,19 +160,21 @@ class FeedItem_Atom extends FeedItem_Common {
$content = $this->xpath->query("media:content", $enclosure)->item(0);
$enc->type = $content->getAttribute("type");
$enc->link = $content->getAttribute("url");
$enc->length = $content->getAttribute("length");
if ($content) {
$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);
$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);
}
array_push($encs, $enc);
}
$enclosures = $this->xpath->query("media:thumbnail", $this->elem);

View file

@ -140,19 +140,21 @@ class FeedItem_RSS extends FeedItem_Common {
$content = $this->xpath->query("media:content", $enclosure)->item(0);
$enc->type = $content->getAttribute("type");
$enc->link = $content->getAttribute("url");
$enc->length = $content->getAttribute("length");
if ($content) {
$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);
$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);
}
array_push($encs, $enc);
}
$enclosures = $this->xpath->query("media:thumbnail", $this->elem);