<?php
class FeedItem_RSS {
private $elem;
+ private $xpath;
- function __construct($elem) {
+ function __construct($elem, $doc, $xpath) {
$this->elem = $elem;
+ $this->xpath = $xpath;
}
function get_id() {
array_push($encs, $enc);
}
+ $enclosures = $this->xpath->query("media:content", $this->elem);
+
+ $encs = array();
+
+ 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;
}
$root = $this->doc->firstChild;
$xpath = new DOMXPath($this->doc);
$xpath->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
+ $xpath->registerNamespace('media', 'http://search.yahoo.com/mrss/');
$this->xpath = $xpath;
$root = $xpath->query("(//atom:feed|//channel)")->item(0);
$articles = $xpath->query("//atom:entry");
foreach ($articles as $article) {
- array_push($this->items, new FeedItem_Atom($article));
+ array_push($this->items, new FeedItem_Atom($article, $this->doc, $this->xpath));
}
break;
$articles = $xpath->query("//channel/item");
foreach ($articles as $article) {
- array_push($this->items, new FeedItem_RSS($article));
+ array_push($this->items, new FeedItem_RSS($article, $this->doc, $this->xpath));
}
break;