]> git.wh0rd.org - tt-rss.git/blob - classes/feeditem/rss.php
parser/rss: try to get link from guid isPermaLink=true
[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->xpath->query("atom:link", $this->elem)->item(0);
23
24 if ($link) {
25 return $link->getAttribute("href");
26 }
27
28 $link = $this->elem->getElementsByTagName("guid")->item(0);
29
30 if ($link && $link->hasAttributes() && $link->getAttribute("isPermaLink") == "true") {
31 return $link->nodeValue;
32 }
33
34 $link = $this->elem->getElementsByTagName("link")->item(0);
35
36 if ($link) {
37 return $link->nodeValue;
38 }
39 }
40
41 function get_title() {
42 $title = $this->elem->getElementsByTagName("title")->item(0);
43
44 if ($title) {
45 return $title->nodeValue;
46 }
47 }
48
49 function get_content() {
50 $content = $this->xpath->query("content:encoded", $this->elem)->item(0);
51
52 if ($content) {
53 return $content->nodeValue;
54 }
55
56 $content = $this->elem->getElementsByTagName("description")->item(0);
57
58 if ($content) {
59 return $content->nodeValue;
60 }
61 }
62
63 function get_description() {
64 $summary = $this->elem->getElementsByTagName("description")->item(0);
65
66 if ($summary) {
67 return $summary->nodeValue;
68 }
69 }
70
71 function get_categories() {
72 $categories = $this->elem->getElementsByTagName("category");
73 $cats = array();
74
75 foreach ($categories as $cat) {
76 array_push($cats, $cat->nodeValue);
77 }
78
79 $categories = $this->xpath->query("dc:subject", $this->elem);
80
81 foreach ($categories as $cat) {
82 array_push($cats, $cat->nodeValue);
83 }
84
85 return $cats;
86 }
87
88 function get_enclosures() {
89 $enclosures = $this->elem->getElementsByTagName("enclosure");
90
91 $encs = array();
92
93 foreach ($enclosures as $enclosure) {
94 $enc = new FeedEnclosure();
95
96 $enc->type = $enclosure->getAttribute("type");
97 $enc->link = $enclosure->getAttribute("url");
98 $enc->length = $enclosure->getAttribute("length");
99
100 array_push($encs, $enc);
101 }
102
103 $enclosures = $this->xpath->query("media:content", $this->elem);
104
105 foreach ($enclosures as $enclosure) {
106 $enc = new FeedEnclosure();
107
108 $enc->type = $enclosure->getAttribute("type");
109 $enc->link = $enclosure->getAttribute("url");
110 $enc->length = $enclosure->getAttribute("length");
111
112 array_push($encs, $enc);
113 }
114
115 return $encs;
116 }
117
118 }
119 ?>