]> git.wh0rd.org - tt-rss.git/blob - classes/feeditem/rss.php
move common methods to feeditem_common
[tt-rss.git] / classes / feeditem / rss.php
1 <?php
2 class FeedItem_RSS extends FeedItem_Common {
3 function get_id() {
4 $id = $this->elem->getElementsByTagName("guid")->item(0);
5
6 if ($id) {
7 return $id->nodeValue;
8 } else {
9 return $this->get_link();
10 }
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() {
22 $link = $this->elem->getElementsByTagName("link")->item(0);
23
24 if ($link) {
25 return $link->nodeValue;
26 }
27 }
28
29 function get_title() {
30 $title = $this->elem->getElementsByTagName("title")->item(0);
31
32 if ($title) {
33 return $title->nodeValue;
34 }
35 }
36
37 function get_content() {
38 $content = $this->elem->getElementsByTagName("description")->item(0);
39
40 if ($content) {
41 return $content->nodeValue;
42 }
43 }
44
45 function get_description() {
46 $summary = $this->elem->getElementsByTagName("description")->item(0);
47
48 if ($summary) {
49 return $summary->nodeValue;
50 }
51 }
52
53 function get_categories() {
54 $categories = $this->elem->getElementsByTagName("category");
55 $cats = array();
56
57 foreach ($categories as $cat) {
58 array_push($cats, $cat->nodeValue);
59 }
60
61 $categories = $this->xpath->query("dc:subject", $this->elem);
62
63 foreach ($categories as $cat) {
64 array_push($cats, $cat->nodeValue);
65 }
66
67 return $cats;
68 }
69
70 function get_enclosures() {
71 $enclosures = $this->elem->getElementsByTagName("enclosure");
72
73 $encs = array();
74
75 foreach ($enclosures as $enclosure) {
76 $enc = new FeedEnclosure();
77
78 $enc->type = $enclosure->getAttribute("type");
79 $enc->link = $enclosure->getAttribute("url");
80 $enc->length = $enclosure->getAttribute("length");
81
82 array_push($encs, $enc);
83 }
84
85 $enclosures = $this->xpath->query("media:content", $this->elem);
86
87 foreach ($enclosures as $enclosure) {
88 $enc = new FeedEnclosure();
89
90 $enc->type = $enclosure->getAttribute("type");
91 $enc->link = $enclosure->getAttribute("url");
92 $enc->length = $enclosure->getAttribute("length");
93
94 array_push($encs, $enc);
95 }
96
97 return $encs;
98 }
99
100 }
101 ?>