]>
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 | } | |
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) { | |
96ce71f3 AD |
44 | if ($content->hasChildNodes()) { |
45 | ||
46 | if ($content->getElementsByTagName("*")->length > 1) { | |
47 | return $this->doc->saveXML($content->firstChild->nextSibling); | |
48 | } | |
49 | } | |
50 | ||
cd07592c AD |
51 | return $content->nodeValue; |
52 | } | |
53 | } | |
54 | ||
55 | function get_description() { | |
56 | $summary = $this->elem->getElementsByTagName("summary")->item(0); | |
57 | ||
58 | if ($summary) { | |
59 | return $summary->nodeValue; | |
60 | } | |
61 | } | |
62 | ||
cd07592c AD |
63 | function get_categories() { |
64 | $categories = $this->elem->getElementsByTagName("category"); | |
65 | $cats = array(); | |
66 | ||
67 | foreach ($categories as $cat) { | |
68 | if ($cat->hasAttribute("term")) | |
69 | array_push($cats, $cat->getAttribute("term")); | |
70 | } | |
71 | ||
d4992d6b AD |
72 | $categories = $this->xpath->query("dc:subject", $this->elem); |
73 | ||
74 | foreach ($categories as $cat) { | |
75 | array_push($cats, $cat->nodeValue); | |
76 | } | |
cd07592c AD |
77 | |
78 | return $cats; | |
79 | } | |
80 | ||
81 | function get_enclosures() { | |
82 | $links = $this->elem->getElementsByTagName("link"); | |
83 | ||
84 | $encs = array(); | |
85 | ||
86 | foreach ($links as $link) { | |
87 | if ($link && $link->hasAttribute("href") && $link->hasAttribute("rel")) { | |
88 | if ($link->getAttribute("rel") == "enclosure") { | |
89 | $enc = new FeedEnclosure(); | |
90 | ||
91 | $enc->type = $link->getAttribute("type"); | |
92 | $enc->link = $link->getAttribute("href"); | |
93 | $enc->length = $link->getAttribute("length"); | |
94 | ||
95 | array_push($encs, $enc); | |
96 | } | |
97 | } | |
98 | } | |
99 | ||
d4992d6b AD |
100 | $enclosures = $this->xpath->query("media:content", $this->elem); |
101 | ||
102 | foreach ($enclosures as $enclosure) { | |
103 | $enc = new FeedEnclosure(); | |
104 | ||
105 | $enc->type = $enclosure->getAttribute("type"); | |
106 | $enc->link = $enclosure->getAttribute("url"); | |
107 | $enc->length = $enclosure->getAttribute("length"); | |
108 | ||
109 | array_push($encs, $enc); | |
110 | } | |
111 | ||
cd07592c AD |
112 | return $encs; |
113 | } | |
114 | ||
cd07592c AD |
115 | } |
116 | ?> |