<?php
class FeedItem_Atom extends FeedItem_Common {
+ const NS_XML = "http://www.w3.org/XML/1998/namespace";
function get_id() {
$id = $this->elem->getElementsByTagName("id")->item(0);
$child = $content->childNodes->item($i);
if ($child->hasChildNodes()) {
- return $this->doc->saveXML($child);
+ return $this->doc->saveHTML($child);
}
}
}
}
- return $content->nodeValue;
+ return $this->subtree_or_text($content);
}
}
$child = $content->childNodes->item($i);
if ($child->hasChildNodes()) {
- return $this->doc->saveXML($child);
+ return $this->doc->saveHTML($child);
}
}
}
}
- return $content->nodeValue;
+ return $this->subtree_or_text($content);
}
}
}
}
- $enclosures = $this->xpath->query("media:content", $this->elem);
+ $encs = array_merge($encs, parent::get_enclosures());
- foreach ($enclosures as $enclosure) {
- $enc = new FeedEnclosure();
-
- $enc->type = $enclosure->getAttribute("type");
- $enc->link = $enclosure->getAttribute("url");
- $enc->length = $enclosure->getAttribute("length");
-
- $desc = $this->xpath->query("media:description", $enclosure)->item(0);
- if ($desc) $enc->title = strip_tags($desc->nodeValue);
-
- 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);
+ return $encs;
+ }
- if ($content) {
- $enc->type = $content->getAttribute("type");
- $enc->link = $content->getAttribute("url");
- $enc->length = $content->getAttribute("length");
+ function get_language() {
+ $lang = $this->elem->getAttributeNS(self::NS_XML, "lang");
- $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);
+ if (!empty($lang)) {
+ return $lang;
+ } else {
+ // Fall back to the language declared on the feed, if any.
+ foreach ($this->doc->childNodes as $child) {
+ if (method_exists($child, "getAttributeNS")) {
+ return $child->getAttributeNS(self::NS_XML, "lang");
}
-
- array_push($encs, $enc);
}
}
-
- $enclosures = $this->xpath->query("media:thumbnail", $this->elem);
-
- foreach ($enclosures as $enclosure) {
- $enc = new FeedEnclosure();
-
- $enc->type = "image/generic";
- $enc->link = $enclosure->getAttribute("url");
-
- array_push($encs, $enc);
- }
-
- return $encs;
}
-
}
-?>