]>
git.wh0rd.org - tt-rss.git/blob - classes/feeditem/atom.php
2 class FeedItem_Atom
extends FeedItem_Common
{
5 $id = $this->elem
->getElementsByTagName("id")->item(0);
10 return $this->get_link();
15 $updated = $this->elem
->getElementsByTagName("updated")->item(0);
18 return strtotime($updated->nodeValue
);
21 $published = $this->elem
->getElementsByTagName("published")->item(0);
24 return strtotime($published->nodeValue
);
27 $date = $this->xpath
->query("dc:date", $this->elem
)->item(0);
30 return strtotime($date->nodeValue
);
36 $links = $this->elem
->getElementsByTagName("link");
38 foreach ($links as $link) {
39 if ($link && $link->hasAttribute("href") &&
40 (!$link->hasAttribute("rel")
41 ||
$link->getAttribute("rel") == "alternate"
42 ||
$link->getAttribute("rel") == "standout")) {
43 $base = $this->xpath
->evaluate("string(ancestor-or-self::*[@xml:base][1]/@xml:base)", $link);
46 return rewrite_relative_url($base, $link->getAttribute("href"));
48 return $link->getAttribute("href");
54 function get_title() {
55 $title = $this->elem
->getElementsByTagName("title")->item(0);
58 return $title->nodeValue
;
62 function get_content() {
63 $content = $this->elem
->getElementsByTagName("content")->item(0);
66 if ($content->hasAttribute('type')) {
67 if ($content->getAttribute('type') == 'xhtml') {
68 for ($i = 0; $i < $content->childNodes
->length
; $i++
) {
69 $child = $content->childNodes
->item($i);
71 if ($child->hasChildNodes()) {
72 return $this->doc
->saveXML($child);
78 return $content->nodeValue
;
82 function get_description() {
83 $content = $this->elem
->getElementsByTagName("summary")->item(0);
86 if ($content->hasAttribute('type')) {
87 if ($content->getAttribute('type') == 'xhtml') {
88 for ($i = 0; $i < $content->childNodes
->length
; $i++
) {
89 $child = $content->childNodes
->item($i);
91 if ($child->hasChildNodes()) {
92 return $this->doc
->saveXML($child);
98 return $content->nodeValue
;
103 function get_categories() {
104 $categories = $this->elem
->getElementsByTagName("category");
107 foreach ($categories as $cat) {
108 if ($cat->hasAttribute("term"))
109 array_push($cats, $cat->getAttribute("term"));
112 $categories = $this->xpath
->query("dc:subject", $this->elem
);
114 foreach ($categories as $cat) {
115 array_push($cats, $cat->nodeValue
);
121 function get_enclosures() {
122 $links = $this->elem
->getElementsByTagName("link");
126 foreach ($links as $link) {
127 if ($link && $link->hasAttribute("href") && $link->hasAttribute("rel")) {
128 if ($link->getAttribute("rel") == "enclosure") {
129 $enc = new FeedEnclosure();
131 $enc->type
= $link->getAttribute("type");
132 $enc->link
= $link->getAttribute("href");
133 $enc->length
= $link->getAttribute("length");
135 array_push($encs, $enc);
140 $enclosures = $this->xpath
->query("media:content | media:group/media:content", $this->elem
);
142 foreach ($enclosures as $enclosure) {
143 $enc = new FeedEnclosure();
145 $enc->type
= $enclosure->getAttribute("type");
146 $enc->link
= $enclosure->getAttribute("url");
147 $enc->length
= $enclosure->getAttribute("length");
149 array_push($encs, $enc);