]>
Commit | Line | Data |
---|---|---|
cd07592c | 1 | <?php |
b4d16900 | 2 | class 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 | } | |
ce5d234d AD |
19 | |
20 | $date = $this->xpath->query("dc:date", $this->elem)->item(0); | |
21 | ||
22 | if ($date) { | |
23 | return strtotime($date->nodeValue); | |
24 | } | |
cd07592c AD |
25 | } |
26 | ||
27 | function get_link() { | |
28 | $links = $this->elem->getElementsByTagName("link"); | |
29 | ||
30 | foreach ($links as $link) { | |
df2655e0 AD |
31 | if ($link && $link->hasAttribute("href") && |
32 | (!$link->hasAttribute("rel") | |
33 | || $link->getAttribute("rel") == "alternate" | |
34 | || $link->getAttribute("rel") == "standout")) { | |
35 | ||
cd07592c AD |
36 | return $link->getAttribute("href"); |
37 | } | |
38 | } | |
39 | } | |
40 | ||
41 | function get_title() { | |
42 | $title = $this->elem->getElementsByTagName("title")->item(0); | |
43 | ||
44 | if ($title) { | |
45 | return $title->nodeValue; | |
46 | } | |
47 | } | |
48 | ||
49 | function get_content() { | |
50 | $content = $this->elem->getElementsByTagName("content")->item(0); | |
51 | ||
52 | if ($content) { | |
27004401 AD |
53 | if ($content->hasAttribute('type')) { |
54 | if ($content->getAttribute('type') == 'xhtml') { | |
96ce71f3 AD |
55 | return $this->doc->saveXML($content->firstChild->nextSibling); |
56 | } | |
57 | } | |
58 | ||
cd07592c AD |
59 | return $content->nodeValue; |
60 | } | |
61 | } | |
62 | ||
63 | function get_description() { | |
27004401 AD |
64 | $content = $this->elem->getElementsByTagName("summary")->item(0); |
65 | ||
66 | if ($content) { | |
67 | if ($content->hasAttribute('type')) { | |
68 | if ($content->getAttribute('type') == 'xhtml') { | |
69 | return $this->doc->saveXML($content->firstChild->nextSibling); | |
70 | } | |
71 | } | |
cd07592c | 72 | |
27004401 | 73 | return $content->nodeValue; |
cd07592c | 74 | } |
27004401 | 75 | |
cd07592c AD |
76 | } |
77 | ||
cd07592c AD |
78 | function get_categories() { |
79 | $categories = $this->elem->getElementsByTagName("category"); | |
80 | $cats = array(); | |
81 | ||
82 | foreach ($categories as $cat) { | |
83 | if ($cat->hasAttribute("term")) | |
84 | array_push($cats, $cat->getAttribute("term")); | |
85 | } | |
86 | ||
d4992d6b AD |
87 | $categories = $this->xpath->query("dc:subject", $this->elem); |
88 | ||
89 | foreach ($categories as $cat) { | |
90 | array_push($cats, $cat->nodeValue); | |
91 | } | |
cd07592c AD |
92 | |
93 | return $cats; | |
94 | } | |
95 | ||
96 | function get_enclosures() { | |
97 | $links = $this->elem->getElementsByTagName("link"); | |
98 | ||
99 | $encs = array(); | |
100 | ||
101 | foreach ($links as $link) { | |
102 | if ($link && $link->hasAttribute("href") && $link->hasAttribute("rel")) { | |
103 | if ($link->getAttribute("rel") == "enclosure") { | |
104 | $enc = new FeedEnclosure(); | |
105 | ||
106 | $enc->type = $link->getAttribute("type"); | |
107 | $enc->link = $link->getAttribute("href"); | |
108 | $enc->length = $link->getAttribute("length"); | |
109 | ||
110 | array_push($encs, $enc); | |
111 | } | |
112 | } | |
113 | } | |
114 | ||
d4992d6b AD |
115 | $enclosures = $this->xpath->query("media:content", $this->elem); |
116 | ||
117 | foreach ($enclosures as $enclosure) { | |
118 | $enc = new FeedEnclosure(); | |
119 | ||
120 | $enc->type = $enclosure->getAttribute("type"); | |
121 | $enc->link = $enclosure->getAttribute("url"); | |
122 | $enc->length = $enclosure->getAttribute("length"); | |
123 | ||
124 | array_push($encs, $enc); | |
125 | } | |
126 | ||
cd07592c AD |
127 | return $encs; |
128 | } | |
129 | ||
cd07592c AD |
130 | } |
131 | ?> |