From d4992d6b48ed458ae3ff39c5cd5ac19244ccd6a8 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 1 May 2013 20:55:08 +0400 Subject: add support for dc:subject and slash:comments --- classes/feeditem/atom.php | 24 +++++++++++++++++++++++- classes/feeditem/rss.php | 13 ++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) (limited to 'classes/feeditem') diff --git a/classes/feeditem/atom.php b/classes/feeditem/atom.php index 7dc4ce5c1..d21933897 100644 --- a/classes/feeditem/atom.php +++ b/classes/feeditem/atom.php @@ -1,9 +1,11 @@ elem = $elem; + $this->xpath = $xpath; } function get_id() { @@ -63,9 +65,12 @@ class FeedItem_Atom { } - // todo function get_comments_count() { + $comments = $this->xpath->query("slash:comments", $this->elem)->item(0); + if ($comments) { + return $comments->nodeValue; + } } function get_categories() { @@ -77,6 +82,11 @@ class FeedItem_Atom { array_push($cats, $cat->getAttribute("term")); } + $categories = $this->xpath->query("dc:subject", $this->elem); + + foreach ($categories as $cat) { + array_push($cats, $cat->nodeValue); + } return $cats; } @@ -100,6 +110,18 @@ class FeedItem_Atom { } } + $enclosures = $this->xpath->query("media:content", $this->elem); + + foreach ($enclosures as $enclosure) { + $enc = new FeedEnclosure(); + + $enc->type = $enclosure->getAttribute("type"); + $enc->link = $enclosure->getAttribute("url"); + $enc->length = $enclosure->getAttribute("length"); + + array_push($encs, $enc); + } + return $encs; } diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index e5e2a8e56..7a3b0d342 100644 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -63,9 +63,12 @@ class FeedItem_RSS { } - // todo function get_comments_count() { + $comments = $this->xpath->query("slash:comments", $this->elem)->item(0); + if ($comments) { + return $comments->nodeValue; + } } function get_categories() { @@ -76,6 +79,12 @@ class FeedItem_RSS { array_push($cats, $cat->nodeValue); } + $categories = $this->xpath->query("dc:subject", $this->elem); + + foreach ($categories as $cat) { + array_push($cats, $cat->nodeValue); + } + return $cats; } @@ -96,8 +105,6 @@ class FeedItem_RSS { $enclosures = $this->xpath->query("media:content", $this->elem); - $encs = array(); - foreach ($enclosures as $enclosure) { $enc = new FeedEnclosure(); -- cgit v1.2.3-54-g00ecf