]>
Commit | Line | Data |
---|---|---|
04d2f9c8 AD |
1 | <?php |
2 | class FeedItem_RSS { | |
3 | private $elem; | |
4 | ||
5 | function __construct($elem) { | |
6 | $this->elem = $elem; | |
7 | } | |
8 | ||
9 | function get_id() { | |
b09a4cdc AD |
10 | $id = $this->elem->getElementsByTagName("guid")->item(0); |
11 | ||
12 | if ($id) { | |
13 | return $id->nodeValue; | |
14 | } else { | |
15 | return $this->get_link(); | |
16 | } | |
04d2f9c8 AD |
17 | } |
18 | ||
19 | function get_date() { | |
20 | $pubDate = $this->elem->getElementsByTagName("pubDate")->item(0); | |
21 | ||
22 | if ($pubDate) { | |
23 | return strtotime($pubDate->nodeValue); | |
24 | } | |
25 | } | |
26 | ||
27 | function get_link() { | |
28 | $link = $this->elem->getElementsByTagName("link")->item(0); | |
29 | ||
30 | if ($link) { | |
31 | return $link->nodeValue; | |
32 | } | |
33 | } | |
34 | ||
35 | function get_title() { | |
36 | $title = $this->elem->getElementsByTagName("title")->item(0); | |
37 | ||
38 | if ($title) { | |
39 | return $title->nodeValue; | |
40 | } | |
41 | } | |
42 | ||
43 | function get_content() { | |
44 | $content = $this->elem->getElementsByTagName("description")->item(0); | |
45 | ||
46 | if ($content) { | |
47 | return $content->nodeValue; | |
48 | } | |
49 | } | |
50 | ||
51 | function get_description() { | |
52 | $summary = $this->elem->getElementsByTagName("description")->item(0); | |
53 | ||
54 | if ($summary) { | |
55 | return $summary->nodeValue; | |
56 | } | |
57 | } | |
58 | ||
59 | // todo | |
60 | function get_comments_url() { | |
61 | ||
62 | } | |
63 | ||
64 | // todo | |
65 | function get_comments_count() { | |
66 | ||
67 | } | |
68 | ||
69 | function get_categories() { | |
70 | $categories = $this->elem->getElementsByTagName("category"); | |
71 | $cats = array(); | |
72 | ||
73 | foreach ($categories as $cat) { | |
74 | array_push($cats, $cat->nodeValue); | |
75 | } | |
76 | ||
77 | return $cats; | |
78 | } | |
79 | ||
80 | function get_enclosures() { | |
81 | $enclosures = $this->elem->getElementsByTagName("enclosure"); | |
82 | ||
83 | $encs = array(); | |
84 | ||
85 | foreach ($enclosures as $enclosure) { | |
86 | $enc = new FeedEnclosure(); | |
87 | ||
88 | $enc->type = $enclosure->getAttribute("type"); | |
89 | $enc->link = $enclosure->getAttribute("url"); | |
90 | $enc->length = $enclosure->getAttribute("length"); | |
91 | ||
92 | array_push($encs, $enc); | |
93 | } | |
94 | ||
95 | return $encs; | |
96 | } | |
97 | ||
98 | function get_author() { | |
99 | $author = $this->elem->getElementsByTagName("author")->item(0); | |
100 | ||
101 | if ($author) { | |
102 | $name = $author->getElementsByTagName("name")->item(0); | |
103 | ||
104 | if ($name) return $name->nodeValue; | |
105 | ||
106 | $email = $author->getElementsByTagName("email")->item(0); | |
107 | ||
108 | if ($email) return $email->nodeValue; | |
109 | ||
110 | } | |
111 | } | |
112 | } | |
113 | ?> |