]> git.wh0rd.org - tt-rss.git/blame - classes/feeditem/rss.php
add basic rss support
[tt-rss.git] / classes / feeditem / rss.php
CommitLineData
04d2f9c8
AD
1<?php
2class FeedItem_RSS {
3 private $elem;
4
5 function __construct($elem) {
6 $this->elem = $elem;
7 }
8
9 function get_id() {
10 return $this->get_link();
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 // todo
54 function get_comments_url() {
55
56 }
57
58 // todo
59 function get_comments_count() {
60
61 }
62
63 function get_categories() {
64 $categories = $this->elem->getElementsByTagName("category");
65 $cats = array();
66
67 foreach ($categories as $cat) {
68 array_push($cats, $cat->nodeValue);
69 }
70
71 return $cats;
72 }
73
74 function get_enclosures() {
75 $enclosures = $this->elem->getElementsByTagName("enclosure");
76
77 $encs = array();
78
79 foreach ($enclosures as $enclosure) {
80 $enc = new FeedEnclosure();
81
82 $enc->type = $enclosure->getAttribute("type");
83 $enc->link = $enclosure->getAttribute("url");
84 $enc->length = $enclosure->getAttribute("length");
85
86 array_push($encs, $enc);
87 }
88
89 return $encs;
90 }
91
92 function get_author() {
93 $author = $this->elem->getElementsByTagName("author")->item(0);
94
95 if ($author) {
96 $name = $author->getElementsByTagName("name")->item(0);
97
98 if ($name) return $name->nodeValue;
99
100 $email = $author->getElementsByTagName("email")->item(0);
101
102 if ($email) return $email->nodeValue;
103
104 }
105 }
106}
107?>