]> git.wh0rd.org - tt-rss.git/blobdiff - classes/feeditem/atom.php
Store size of enclosure to database
[tt-rss.git] / classes / feeditem / atom.php
index 244fb1f84671ac61de286ea06ea8441f2e0b4b07..dfac7149f6cb4981cd6d768dd36e3600b80dd438 100644 (file)
@@ -43,9 +43,9 @@ class FeedItem_Atom extends FeedItem_Common {
                                $base = $this->xpath->evaluate("string(ancestor-or-self::*[@xml:base][1]/@xml:base)", $link);
 
                                if ($base)
-                                       return rewrite_relative_url($base, $link->getAttribute("href"));
+                                       return rewrite_relative_url($base, trim($link->getAttribute("href")));
                                else
-                                       return $link->getAttribute("href");
+                                       return trim($link->getAttribute("href"));
 
                        }
                }
@@ -55,7 +55,7 @@ class FeedItem_Atom extends FeedItem_Common {
                $title = $this->elem->getElementsByTagName("title")->item(0);
 
                if ($title) {
-                       return $title->nodeValue;
+                       return trim($title->nodeValue);
                }
        }
 
@@ -106,13 +106,13 @@ class FeedItem_Atom extends FeedItem_Common {
 
                foreach ($categories as $cat) {
                        if ($cat->hasAttribute("term"))
-                               array_push($cats, $cat->getAttribute("term"));
+                               array_push($cats, trim($cat->getAttribute("term")));
                }
 
                $categories = $this->xpath->query("dc:subject", $this->elem);
 
                foreach ($categories as $cat) {
-                       array_push($cats, $cat->nodeValue);
+                       array_push($cats, trim($cat->nodeValue));
                }
 
                return $cats;
@@ -145,6 +145,8 @@ class FeedItem_Atom extends FeedItem_Common {
                        $enc->type = $enclosure->getAttribute("type");
                        $enc->link = $enclosure->getAttribute("url");
                        $enc->length = $enclosure->getAttribute("length");
+                       $enc->height = $enclosure->getAttribute("height");
+                       $enc->width = $enclosure->getAttribute("width");
 
                        $desc = $this->xpath->query("media:description", $enclosure)->item(0);
                        if ($desc) $enc->title = strip_tags($desc->nodeValue);
@@ -160,19 +162,23 @@ class FeedItem_Atom extends FeedItem_Common {
 
                        $content = $this->xpath->query("media:content", $enclosure)->item(0);
 
-                       $enc->type = $content->getAttribute("type");
-                       $enc->link = $content->getAttribute("url");
-                       $enc->length = $content->getAttribute("length");
+                       if ($content) {
+                               $enc->type = $content->getAttribute("type");
+                               $enc->link = $content->getAttribute("url");
+                               $enc->length = $content->getAttribute("length");
+                               $enc->height = $content->getAttribute("height");
+                               $enc->width = $content->getAttribute("width");
+
+                               $desc = $this->xpath->query("media:description", $content)->item(0);
+                               if ($desc) {
+                                       $enc->title = strip_tags($desc->nodeValue);
+                               } else {
+                                       $desc = $this->xpath->query("media:description", $enclosure)->item(0);
+                                       if ($desc) $enc->title = strip_tags($desc->nodeValue);
+                               }
 
-                       $desc = $this->xpath->query("media:description", $content)->item(0);
-                       if ($desc) {
-                               $enc->title = strip_tags($desc->nodeValue);
-                       } else {
-                               $desc = $this->xpath->query("media:description", $enclosure)->item(0);
-                               if ($desc) $enc->title = strip_tags($desc->nodeValue);
+                               array_push($encs, $enc);
                        }
-
-                       array_push($encs, $enc);
                }
 
                $enclosures = $this->xpath->query("media:thumbnail", $this->elem);
@@ -182,6 +188,8 @@ class FeedItem_Atom extends FeedItem_Common {
 
                        $enc->type = "image/generic";
                        $enc->link = $enclosure->getAttribute("url");
+                       $enc->height = $enclosure->getAttribute("height");
+                       $enc->width = $enclosure->getAttribute("width");
 
                        array_push($encs, $enc);
                }