summaryrefslogtreecommitdiff
path: root/plugins/OStatus/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-03-19 15:23:30 -0500
committerEvan Prodromou <evan@status.net>2010-03-19 15:23:30 -0500
commit1e03968d911fe4bc757c01036365a5f544621088 (patch)
tree86fcce60925264f84f18aa7ca535f6cba0ad8218 /plugins/OStatus/lib
parentf0c54243bacb06fe10c330e5474dce55ee513ad8 (diff)
define a 'root' attribute for the channel or feed
Diffstat (limited to 'plugins/OStatus/lib')
-rw-r--r--plugins/OStatus/lib/feeddiscovery.php23
1 files changed, 21 insertions, 2 deletions
diff --git a/plugins/OStatus/lib/feeddiscovery.php b/plugins/OStatus/lib/feeddiscovery.php
index 7de80b335..4809f9d35 100644
--- a/plugins/OStatus/lib/feeddiscovery.php
+++ b/plugins/OStatus/lib/feeddiscovery.php
@@ -73,6 +73,7 @@ class FeedDiscovery
public $uri;
public $type;
public $feed;
+ public $root;
/** Post-initialize query helper... */
public function getLink($rel, $type=null)
@@ -83,7 +84,7 @@ class FeedDiscovery
public function getAtomLink($rel, $type=null)
{
- return ActivityUtils::getLink($this->feed->documentElement, $rel, $type);
+ return ActivityUtils::getLink($this->root, $rel, $type);
}
/**
@@ -154,9 +155,27 @@ class FeedDiscovery
$this->uri = $sourceurl;
$this->type = $type;
$this->feed = $feed;
+
+ $el = $this->feed->documentElement;
+
+ // Looking for the "root" element: RSS channel or Atom feed
+
+ if ($el->tagName == 'rss') {
+ $channels = $el->getElementsByTagName('channel');
+ if ($channels->length > 0) {
+ $this->root = $channels->item(0);
+ } else {
+ throw new FeedSubBadXmlException($sourceurl);
+ }
+ } else if ($el->tagName == 'feed') {
+ $this->root = $el;
+ } else {
+ throw new FeedSubBadXmlException($sourceurl);
+ }
+
return $this->uri;
} else {
- throw new FeedSubBadXmlException($url);
+ throw new FeedSubBadXmlException($sourceurl);
}
}