From df2655e01566f3c59337a020b1d70054ff585d75 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 26 May 2013 10:21:54 +0400 Subject: [PATCH] better support for atom:link elements in rss feeds, support rel=standout (fuck you google and your nonstandard shit) --- classes/feeditem/atom.php | 7 +++++-- classes/feeditem/rss.php | 12 +++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/classes/feeditem/atom.php b/classes/feeditem/atom.php index 73a586d5b..489c5b148 100644 --- a/classes/feeditem/atom.php +++ b/classes/feeditem/atom.php @@ -22,8 +22,11 @@ class FeedItem_Atom extends FeedItem_Common { $links = $this->elem->getElementsByTagName("link"); foreach ($links as $link) { - if ($link && $link->hasAttribute("href") && (!$link->hasAttribute("rel") - || $link->getAttribute("rel") == "alternate")) { + if ($link && $link->hasAttribute("href") && + (!$link->hasAttribute("rel") + || $link->getAttribute("rel") == "alternate" + || $link->getAttribute("rel") == "standout")) { + return $link->getAttribute("href"); } } diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index 34dfee1f1..e09a1fbba 100644 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -19,10 +19,16 @@ class FeedItem_RSS extends FeedItem_Common { } function get_link() { - $link = $this->xpath->query("atom:link", $this->elem)->item(0); + $links = $this->xpath->query("atom:link", $this->elem); - if ($link) { - return $link->getAttribute("href"); + foreach ($links as $link) { + if ($link && $link->hasAttribute("href") && + (!$link->hasAttribute("rel") + || $link->getAttribute("rel") == "alternate" + || $link->getAttribute("rel") == "standout")) { + + return $link->getAttribute("href"); + } } $link = $this->elem->getElementsByTagName("guid")->item(0);