]>
Commit | Line | Data |
---|---|---|
04d2f9c8 | 1 | <?php |
b4d16900 | 2 | class FeedItem_RSS extends FeedItem_Common { |
04d2f9c8 | 3 | function get_id() { |
b09a4cdc AD |
4 | $id = $this->elem->getElementsByTagName("guid")->item(0); |
5 | ||
6 | if ($id) { | |
7 | return $id->nodeValue; | |
8 | } else { | |
9 | return $this->get_link(); | |
10 | } | |
04d2f9c8 AD |
11 | } |
12 | ||
13 | function get_date() { | |
14 | $pubDate = $this->elem->getElementsByTagName("pubDate")->item(0); | |
15 | ||
16 | if ($pubDate) { | |
17 | return strtotime($pubDate->nodeValue); | |
18 | } | |
19 | } | |
20 | ||
21 | function get_link() { | |
df2655e0 | 22 | $links = $this->xpath->query("atom:link", $this->elem); |
04d2f9c8 | 23 | |
df2655e0 AD |
24 | foreach ($links as $link) { |
25 | if ($link && $link->hasAttribute("href") && | |
26 | (!$link->hasAttribute("rel") | |
27 | || $link->getAttribute("rel") == "alternate" | |
28 | || $link->getAttribute("rel") == "standout")) { | |
29 | ||
30 | return $link->getAttribute("href"); | |
31 | } | |
04d2f9c8 | 32 | } |
f7d64d03 | 33 | |
042003d5 AD |
34 | $link = $this->elem->getElementsByTagName("guid")->item(0); |
35 | ||
36 | if ($link && $link->hasAttributes() && $link->getAttribute("isPermaLink") == "true") { | |
37 | return $link->nodeValue; | |
38 | } | |
39 | ||
2f6b75d5 | 40 | $link = $this->elem->getElementsByTagName("link")->item(0); |
f7d64d03 AD |
41 | |
42 | if ($link) { | |
43 | return $link->nodeValue; | |
44 | } | |
04d2f9c8 AD |
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() { | |
99b82567 | 56 | $content = $this->xpath->query("content:encoded", $this->elem)->item(0); |
04d2f9c8 AD |
57 | |
58 | if ($content) { | |
59 | return $content->nodeValue; | |
60 | } | |
8a95d630 | 61 | |
99b82567 | 62 | $content = $this->elem->getElementsByTagName("description")->item(0); |
8a95d630 AD |
63 | |
64 | if ($content) { | |
65 | return $content->nodeValue; | |
66 | } | |
04d2f9c8 AD |
67 | } |
68 | ||
69 | function get_description() { | |
70 | $summary = $this->elem->getElementsByTagName("description")->item(0); | |
71 | ||
72 | if ($summary) { | |
73 | return $summary->nodeValue; | |
74 | } | |
75 | } | |
76 | ||
04d2f9c8 AD |
77 | function get_categories() { |
78 | $categories = $this->elem->getElementsByTagName("category"); | |
79 | $cats = array(); | |
80 | ||
81 | foreach ($categories as $cat) { | |
82 | array_push($cats, $cat->nodeValue); | |
83 | } | |
84 | ||
d4992d6b AD |
85 | $categories = $this->xpath->query("dc:subject", $this->elem); |
86 | ||
87 | foreach ($categories as $cat) { | |
88 | array_push($cats, $cat->nodeValue); | |
89 | } | |
90 | ||
04d2f9c8 AD |
91 | return $cats; |
92 | } | |
93 | ||
94 | function get_enclosures() { | |
95 | $enclosures = $this->elem->getElementsByTagName("enclosure"); | |
96 | ||
97 | $encs = array(); | |
98 | ||
99 | foreach ($enclosures as $enclosure) { | |
100 | $enc = new FeedEnclosure(); | |
101 | ||
102 | $enc->type = $enclosure->getAttribute("type"); | |
103 | $enc->link = $enclosure->getAttribute("url"); | |
104 | $enc->length = $enclosure->getAttribute("length"); | |
105 | ||
106 | array_push($encs, $enc); | |
107 | } | |
108 | ||
4c00e15b AD |
109 | $enclosures = $this->xpath->query("media:content", $this->elem); |
110 | ||
4c00e15b AD |
111 | foreach ($enclosures as $enclosure) { |
112 | $enc = new FeedEnclosure(); | |
113 | ||
114 | $enc->type = $enclosure->getAttribute("type"); | |
115 | $enc->link = $enclosure->getAttribute("url"); | |
116 | $enc->length = $enclosure->getAttribute("length"); | |
117 | ||
118 | array_push($encs, $enc); | |
119 | } | |
120 | ||
04d2f9c8 AD |
121 | return $encs; |
122 | } | |
123 | ||
04d2f9c8 AD |
124 | } |
125 | ?> |