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