From acde8a2cea035d11a6197943c7d726ea4e9ae703 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sun, 4 Sep 2016 13:46:57 +0200 Subject: [PATCH] [Bridge] Support 'dc:date' for RSS 2.0 parser --- lib/Bridge.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/Bridge.php b/lib/Bridge.php index 342c395..72734df 100644 --- a/lib/Bridge.php +++ b/lib/Bridge.php @@ -718,18 +718,21 @@ abstract class FeedExpander extends HttpCachingBridgeAbstract { } protected function parseRSS_2_0_Item($feedItem){ - // Primary data is compatible to 0.91 + // Primary data is compatible to 0.91 with some additional data $item = $this->parseRSS_0_9_1_Item($feedItem); - if(isset($feedItem->pubDate)) $item['timestamp'] = strtotime($feedItem->pubDate); + + $namespaces = $feedItem->getNamespaces(true); + if(isset($namespaces['dc'])) $dc = $feedItem->children($namespaces['dc']); + + if(isset($feedItem->pubDate)){ + $item['timestamp'] = strtotime($feedItem->pubDate); + } elseif(isset($dc->date)){ + $item['timestamp'] = strtotime($dc->date); + } if(isset($feedItem->author)){ $item['author'] = $feedItem->author; - } else { - // Feed might use 'dc' namespace - $namespaces = $feedItem->getNamespaces(true); - if(isset($namespaces['dc'])){ - $dc = $feedItem->children($namespaces['dc']); - if(isset($dc->creator)) $item['author'] = $dc->creator; - } + } elseif(isset($dc->creator)){ + $item['author'] = $dc->creator; } return $item; }