]> git.wh0rd.org - tt-rss.git/commitdiff
rss: choose between description and content:encoded based on which one is longer...
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 19 Dec 2013 09:19:30 +0000 (13:19 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 19 Dec 2013 09:19:30 +0000 (13:19 +0400)
classes/feeditem/rss.php

index f632d3bbfe2617d43319f00ab9cbdc740f938219..7d445a6c348d1f79aac6d8ca9bced1076933a12f 100644 (file)
@@ -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;
                }
        }