summaryrefslogtreecommitdiff
path: root/classes/feeditem
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-12-19 13:19:30 +0400
committerAndrew Dolgov <[email protected]>2013-12-19 13:19:30 +0400
commitf6c61b2d55ff70819bc1582791fdc8df149eb22f (patch)
tree5f8a3b863fd8253cba5c33ba7cc81442920f16ca /classes/feeditem
parent416a9b1c9ced16bdf8e45a8471ecef9f1569b09c (diff)
rss: choose between description and content:encoded based on which one is longer because publishers are idiots and can't use tags properly
Diffstat (limited to 'classes/feeditem')
-rw-r--r--classes/feeditem/rss.php17
1 files changed, 11 insertions, 6 deletions
diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php
index f632d3bbf..7d445a6c3 100644
--- a/classes/feeditem/rss.php
+++ b/classes/feeditem/rss.php
@@ -59,16 +59,21 @@ class FeedItem_RSS extends FeedItem_Common {
}
function get_content() {
- $content = $this->xpath->query("content:encoded", $this->elem)->item(0);
+ $contentA = $this->xpath->query("content:encoded", $this->elem)->item(0);
+ $contentB = $this->elem->getElementsByTagName("description")->item(0);
- if ($content) {
- return $content->nodeValue;
+ if ($contentA && !$contentB) {
+ return $contentA->nodeValue;
}
- $content = $this->elem->getElementsByTagName("description")->item(0);
- if ($content) {
- return $content->nodeValue;
+ if ($contentB && !$contentA) {
+ return $contentB->nodeValue;
+ }
+
+ if ($contentA && $contentB) {
+ return mb_strlen($contentA->nodeValue) > mb_strlen($contentB->nodeValue) ?
+ $contentA->nodeValue : $contentB->nodeValue;
}
}