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