]>
git.wh0rd.org - tt-rss.git/blob - classes/feeditem/rss.php
bf08a1dfefe747a47c1192613d45cbd22eae0998
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");
117 array_push($encs, $enc);
120 $enclosures = $this->xpath
->query("media:content", $this->elem
);
122 foreach ($enclosures as $enclosure) {
123 $enc = new FeedEnclosure();
125 $enc->type
= $enclosure->getAttribute("type");
126 $enc->link
= $enclosure->getAttribute("url");
127 $enc->length
= $enclosure->getAttribute("length");
129 $desc = $this->xpath
->query("media:description", $enclosure)->item(0);
130 if ($desc) $enc->title
= strip_tags($desc->nodeValue
);
132 array_push($encs, $enc);
136 $enclosures = $this->xpath
->query("media:group", $this->elem
);
138 foreach ($enclosures as $enclosure) {
139 $enc = new FeedEnclosure();
141 $content = $this->xpath
->query("media:content", $enclosure)->item(0);
144 $enc->type
= $content->getAttribute("type");
145 $enc->link
= $content->getAttribute("url");
146 $enc->length
= $content->getAttribute("length");
148 $desc = $this->xpath
->query("media:description", $content)->item(0);
150 $enc->title
= strip_tags($desc->nodeValue
);
152 $desc = $this->xpath
->query("media:description", $enclosure)->item(0);
153 if ($desc) $enc->title
= strip_tags($desc->nodeValue
);
156 array_push($encs, $enc);
160 $enclosures = $this->xpath
->query("media:thumbnail", $this->elem
);
162 foreach ($enclosures as $enclosure) {
163 $enc = new FeedEnclosure();
165 $enc->type
= "image/generic";
166 $enc->link
= $enclosure->getAttribute("url");
168 array_push($encs, $enc);