]>
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, trim($link->getAttribute("href")));
48 return trim($link->getAttribute("href"));
54 function get_title() {
55 $title = $this->elem
->getElementsByTagName("title")->item(0);
58 return trim($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, trim($cat->getAttribute("term")));
112 $categories = $this->xpath
->query("dc:subject", $this->elem
);
114 foreach ($categories as $cat) {
115 array_push($cats, trim($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", $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");
148 $enc->height
= $enclosure->getAttribute("height");
149 $enc->width
= $enclosure->getAttribute("width");
151 $desc = $this->xpath
->query("media:description", $enclosure)->item(0);
152 if ($desc) $enc->title
= strip_tags($desc->nodeValue
);
154 array_push($encs, $enc);
158 $enclosures = $this->xpath
->query("media:group", $this->elem
);
160 foreach ($enclosures as $enclosure) {
161 $enc = new FeedEnclosure();
163 $content = $this->xpath
->query("media:content", $enclosure)->item(0);
166 $enc->type
= $content->getAttribute("type");
167 $enc->link
= $content->getAttribute("url");
168 $enc->length
= $content->getAttribute("length");
169 $enc->height
= $content->getAttribute("height");
170 $enc->width
= $content->getAttribute("width");
172 $desc = $this->xpath
->query("media:description", $content)->item(0);
174 $enc->title
= strip_tags($desc->nodeValue
);
176 $desc = $this->xpath
->query("media:description", $enclosure)->item(0);
177 if ($desc) $enc->title
= strip_tags($desc->nodeValue
);
180 array_push($encs, $enc);
184 $enclosures = $this->xpath
->query("media:thumbnail", $this->elem
);
186 foreach ($enclosures as $enclosure) {
187 $enc = new FeedEnclosure();
189 $enc->type
= "image/generic";
190 $enc->link
= $enclosure->getAttribute("url");
191 $enc->height
= $enclosure->getAttribute("height");
192 $enc->width
= $enclosure->getAttribute("width");
194 array_push($encs, $enc);