]> git.wh0rd.org Git - tt-rss.git/commitdiff
support RDF-XML feeds
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 1 May 2013 16:30:52 +0000 (20:30 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 1 May 2013 16:30:52 +0000 (20:30 +0400)
classes/feedparser.php
include/rssfuncs.php

index eabbb5b2863668e80d57d7c8c687c34767c6a6c6..8cb736a8b5fd8a2b795dd557b1b3a14c7c0ecff9 100644 (file)
@@ -28,12 +28,16 @@ class FeedParser {
                $xpath = new DOMXPath($this->doc);
                $xpath->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
                $xpath->registerNamespace('media', 'http://search.yahoo.com/mrss/');
+               $xpath->registerNamespace('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
                $this->xpath = $xpath;
 
-               $root = $xpath->query("(//atom:feed|//channel)")->item(0);
+               $root = $xpath->query("(//atom:feed|//channel|//rdf:rdf|//rdf:RDF)")->item(0);
 
                if ($root) {
-                       switch ($root->tagName) {
+                       switch (mb_strtolower($root->tagName)) {
+                       case "rdf:rdf":
+                               $this->type = $this::FEED_RDF;
+                               break;
                        case "channel":
                                $this->type = $this::FEED_RSS;
                                break;
@@ -88,7 +92,33 @@ class FeedParser {
                                }
 
                                break;
+                       case $this::FEED_RDF:
+                               $xpath->registerNamespace('rssfake', 'http://purl.org/rss/1.0/');
+
+                               $title = $xpath->query("//rssfake:channel/rssfake:title")->item(0);
+
+                               if ($title) {
+                                       $this->title = $title->nodeValue;
+                               }
+
+                               $link = $xpath->query("//rssfake:channel/rssfake:link")->item(0);
+
+                               if ($link) {
+                                       $this->link = $link->nodeValue;
+                               }
+
+                               $articles = $xpath->query("//rssfake:item");
+
+                               foreach ($articles as $article) {
+                                       array_push($this->items, new FeedItem_RSS($article, $this->doc, $this->xpath));
+                               }
+
+                               break;
+
                        }
+               } else {
+                       $this->error = "Unknown/unsupported feed type";
+                       return;
                }
        }
 
index 2291546968336a06c9270b16529c2d90fad7b636..57e63b8737759dc8cf6947412b29402eb1952d57 100644 (file)
 
                                $feed_title = db_escape_string($rss->get_title());
 
-                               _debug("registering title: $feed_title", $debug_enabled);
+                               if ($feed_title) {
+                                       _debug("registering title: $feed_title", $debug_enabled);
 
-                               db_query("UPDATE ttrss_feeds SET
-                                       title = '$feed_title' WHERE id = '$feed'");
+                                       db_query("UPDATE ttrss_feeds SET
+                                               title = '$feed_title' WHERE id = '$feed'");
+                               }
                        }
 
                        if ($site_url && $orig_site_url != $site_url) {