]>
git.wh0rd.org - tt-rss.git/blob - classes/feeditem/rss.php
c9a7467cda6581b6d00ec788c08a64d5c7d6345e
2 class FeedItem_RSS
extends FeedItem_Common
{
4 $id = $this->elem
->getElementsByTagName("guid")->item(0);
9 return $this->get_link();
14 $pubDate = $this->elem
->getElementsByTagName("pubDate")->item(0);
17 return strtotime($pubDate->nodeValue
);
20 $date = $this->xpath
->query("dc:date", $this->elem
)->item(0);
23 return strtotime($date->nodeValue
);
28 $links = $this->xpath
->query("atom:link", $this->elem
);
30 foreach ($links as $link) {
31 if ($link && $link->hasAttribute("href") &&
32 (!$link->hasAttribute("rel")
33 ||
$link->getAttribute("rel") == "alternate"
34 ||
$link->getAttribute("rel") == "standout")) {
36 return trim($link->getAttribute("href"));
40 $link = $this->elem
->getElementsByTagName("guid")->item(0);
42 if ($link && $link->hasAttributes() && $link->getAttribute("isPermaLink") == "true") {
43 return trim($link->nodeValue
);
46 $link = $this->elem
->getElementsByTagName("link")->item(0);
49 return trim($link->nodeValue
);
53 function get_title() {
54 $title = $this->elem
->getElementsByTagName("title")->item(0);
57 return trim($title->nodeValue
);
61 function get_content() {
62 $contentA = $this->xpath
->query("content:encoded", $this->elem
)->item(0);
63 $contentB = $this->elem
->getElementsByTagName("description")->item(0);
65 if ($contentA && !$contentB) {
66 return $contentA->nodeValue
;
70 if ($contentB && !$contentA) {
71 return $contentB->nodeValue
;
74 if ($contentA && $contentB) {
75 return mb_strlen($contentA->nodeValue
) > mb_strlen($contentB->nodeValue
) ?
76 $contentA->nodeValue
: $contentB->nodeValue
;
80 function get_description() {
81 $summary = $this->elem
->getElementsByTagName("description")->item(0);
84 return $summary->nodeValue
;
88 function get_categories() {
89 $categories = $this->elem
->getElementsByTagName("category");
92 foreach ($categories as $cat) {
93 array_push($cats, trim($cat->nodeValue
));
96 $categories = $this->xpath
->query("dc:subject", $this->elem
);
98 foreach ($categories as $cat) {
99 array_push($cats, trim($cat->nodeValue
));
105 function get_enclosures() {
106 $enclosures = $this->elem
->getElementsByTagName("enclosure");
110 foreach ($enclosures as $enclosure) {
111 $enc = new FeedEnclosure();
113 $enc->type
= $enclosure->getAttribute("type");
114 $enc->link
= $enclosure->getAttribute("url");
115 $enc->length
= $enclosure->getAttribute("length");
116 $enc->height
= $enclosure->getAttribute("height");
117 $enc->width
= $enclosure->getAttribute("width");
119 array_push($encs, $enc);
122 $enclosures = $this->xpath
->query("media:content", $this->elem
);
124 foreach ($enclosures as $enclosure) {
125 $enc = new FeedEnclosure();
127 $enc->type
= $enclosure->getAttribute("type");
128 $enc->link
= $enclosure->getAttribute("url");
129 $enc->length
= $enclosure->getAttribute("length");
130 $enc->height
= $enclosure->getAttribute("height");
131 $enc->width
= $enclosure->getAttribute("width");
133 $desc = $this->xpath
->query("media:description", $enclosure)->item(0);
134 if ($desc) $enc->title
= strip_tags($desc->nodeValue
);
136 array_push($encs, $enc);
140 $enclosures = $this->xpath
->query("media:group", $this->elem
);
142 foreach ($enclosures as $enclosure) {
143 $enc = new FeedEnclosure();
145 $content = $this->xpath
->query("media:content", $enclosure)->item(0);
148 $enc->type
= $content->getAttribute("type");
149 $enc->link
= $content->getAttribute("url");
150 $enc->length
= $content->getAttribute("length");
151 $enc->height
= $content->getAttribute("height");
152 $enc->width
= $content->getAttribute("width");
154 $desc = $this->xpath
->query("media:description", $content)->item(0);
156 $enc->title
= strip_tags($desc->nodeValue
);
158 $desc = $this->xpath
->query("media:description", $enclosure)->item(0);
159 if ($desc) $enc->title
= strip_tags($desc->nodeValue
);
162 array_push($encs, $enc);
166 $enclosures = $this->xpath
->query("media:thumbnail", $this->elem
);
168 foreach ($enclosures as $enclosure) {
169 $enc = new FeedEnclosure();
171 $enc->type
= "image/generic";
172 $enc->link
= $enclosure->getAttribute("url");
173 $enc->height
= $enclosure->getAttribute("height");
174 $enc->width
= $enclosure->getAttribute("width");
176 array_push($encs, $enc);