]>
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);
45 return rewrite_relative_url($base, $link->getAttribute("href"));
50 function get_title() {
51 $title = $this->elem
->getElementsByTagName("title")->item(0);
54 return $title->nodeValue
;
58 function get_content() {
59 $content = $this->elem
->getElementsByTagName("content")->item(0);
62 if ($content->hasAttribute('type')) {
63 if ($content->getAttribute('type') == 'xhtml') {
64 for ($i = 0; $i < $content->childNodes
->length
; $i++
) {
65 $child = $content->childNodes
->item($i);
67 if ($child->hasChildNodes()) {
68 return $this->doc
->saveXML($child);
74 return $content->nodeValue
;
78 function get_description() {
79 $content = $this->elem
->getElementsByTagName("summary")->item(0);
82 if ($content->hasAttribute('type')) {
83 if ($content->getAttribute('type') == 'xhtml') {
84 for ($i = 0; $i < $content->childNodes
->length
; $i++
) {
85 $child = $content->childNodes
->item($i);
87 if ($child->hasChildNodes()) {
88 return $this->doc
->saveXML($child);
94 return $content->nodeValue
;
99 function get_categories() {
100 $categories = $this->elem
->getElementsByTagName("category");
103 foreach ($categories as $cat) {
104 if ($cat->hasAttribute("term"))
105 array_push($cats, $cat->getAttribute("term"));
108 $categories = $this->xpath
->query("dc:subject", $this->elem
);
110 foreach ($categories as $cat) {
111 array_push($cats, $cat->nodeValue
);
117 function get_enclosures() {
118 $links = $this->elem
->getElementsByTagName("link");
122 foreach ($links as $link) {
123 if ($link && $link->hasAttribute("href") && $link->hasAttribute("rel")) {
124 if ($link->getAttribute("rel") == "enclosure") {
125 $enc = new FeedEnclosure();
127 $enc->type
= $link->getAttribute("type");
128 $enc->link
= $link->getAttribute("href");
129 $enc->length
= $link->getAttribute("length");
131 array_push($encs, $enc);
136 $enclosures = $this->xpath
->query("media:content", $this->elem
);
138 foreach ($enclosures as $enclosure) {
139 $enc = new FeedEnclosure();
141 $enc->type
= $enclosure->getAttribute("type");
142 $enc->link
= $enclosure->getAttribute("url");
143 $enc->length
= $enclosure->getAttribute("length");
145 array_push($encs, $enc);