]> git.wh0rd.org - tt-rss.git/blame - classes/feeditem/atom.php
note: set inset shadow
[tt-rss.git] / classes / feeditem / atom.php
CommitLineData
cd07592c 1<?php
b4d16900 2class FeedItem_Atom extends FeedItem_Common {
cd07592c
AD
3 function get_id() {
4 $id = $this->elem->getElementsByTagName("id")->item(0);
5
6 if ($id) {
7 return $id->nodeValue;
8 } else {
9 return $this->get_link();
10 }
11 }
12
13 function get_date() {
04d2f9c8 14 $updated = $this->elem->getElementsByTagName("updated")->item(0);
cd07592c 15
04d2f9c8
AD
16 if ($updated) {
17 return strtotime($updated->nodeValue);
18 }
cd07592c
AD
19 }
20
21 function get_link() {
22 $links = $this->elem->getElementsByTagName("link");
23
24 foreach ($links as $link) {
72c29b65
AD
25 if ($link && $link->hasAttribute("href") && (!$link->hasAttribute("rel")
26 || $link->getAttribute("rel") == "alternate")) {
cd07592c
AD
27 return $link->getAttribute("href");
28 }
29 }
30 }
31
32 function get_title() {
33 $title = $this->elem->getElementsByTagName("title")->item(0);
34
35 if ($title) {
36 return $title->nodeValue;
37 }
38 }
39
40 function get_content() {
41 $content = $this->elem->getElementsByTagName("content")->item(0);
42
43 if ($content) {
27004401
AD
44 if ($content->hasAttribute('type')) {
45 if ($content->getAttribute('type') == 'xhtml') {
96ce71f3
AD
46 return $this->doc->saveXML($content->firstChild->nextSibling);
47 }
48 }
49
cd07592c
AD
50 return $content->nodeValue;
51 }
52 }
53
54 function get_description() {
27004401
AD
55 $content = $this->elem->getElementsByTagName("summary")->item(0);
56
57 if ($content) {
58 if ($content->hasAttribute('type')) {
59 if ($content->getAttribute('type') == 'xhtml') {
60 return $this->doc->saveXML($content->firstChild->nextSibling);
61 }
62 }
cd07592c 63
27004401 64 return $content->nodeValue;
cd07592c 65 }
27004401 66
cd07592c
AD
67 }
68
cd07592c
AD
69 function get_categories() {
70 $categories = $this->elem->getElementsByTagName("category");
71 $cats = array();
72
73 foreach ($categories as $cat) {
74 if ($cat->hasAttribute("term"))
75 array_push($cats, $cat->getAttribute("term"));
76 }
77
d4992d6b
AD
78 $categories = $this->xpath->query("dc:subject", $this->elem);
79
80 foreach ($categories as $cat) {
81 array_push($cats, $cat->nodeValue);
82 }
cd07592c
AD
83
84 return $cats;
85 }
86
87 function get_enclosures() {
88 $links = $this->elem->getElementsByTagName("link");
89
90 $encs = array();
91
92 foreach ($links as $link) {
93 if ($link && $link->hasAttribute("href") && $link->hasAttribute("rel")) {
94 if ($link->getAttribute("rel") == "enclosure") {
95 $enc = new FeedEnclosure();
96
97 $enc->type = $link->getAttribute("type");
98 $enc->link = $link->getAttribute("href");
99 $enc->length = $link->getAttribute("length");
100
101 array_push($encs, $enc);
102 }
103 }
104 }
105
d4992d6b
AD
106 $enclosures = $this->xpath->query("media:content", $this->elem);
107
108 foreach ($enclosures as $enclosure) {
109 $enc = new FeedEnclosure();
110
111 $enc->type = $enclosure->getAttribute("type");
112 $enc->link = $enclosure->getAttribute("url");
113 $enc->length = $enclosure->getAttribute("length");
114
115 array_push($encs, $enc);
116 }
117
cd07592c
AD
118 return $encs;
119 }
120
cd07592c
AD
121}
122?>