@@ -5,10 +5,10 @@
|
||||
class Feed {
|
||||
|
||||
/** @var string The XML namespace for Atom feeds */
|
||||
public const ATOM_NS = 'http://www.w3.org/2005/Atom';
|
||||
public const string ATOM_NS = 'http://www.w3.org/2005/Atom';
|
||||
|
||||
/** @var string The XML namespace for the `<content>` tag that allows HTML content in a feed */
|
||||
public const CONTENT_NS = 'http://purl.org/rss/1.0/modules/content/';
|
||||
/** @var string The XML namespace for the `<content:encoded>` tag that allows HTML content in a feed */
|
||||
public const string CONTENT_NS = 'http://purl.org/rss/1.0/modules/content/';
|
||||
|
||||
/**
|
||||
* When parsing XML into a DOMDocument, errors are presented as warnings; this creates an exception for them
|
||||
@@ -142,8 +142,14 @@ class Feed {
|
||||
$channel = $feed['ok']->getElementsByTagName('channel')->item(0);
|
||||
if (!$channel instanceof DOMElement) return [ 'error' => "Channel element not found ($channel->nodeType)" ];
|
||||
|
||||
$feedId = Data::addFeed($feed['url'], self::eltValue($channel, 'title'),
|
||||
self::eltValue($channel, 'lastBuildDate'));
|
||||
// In Atom feeds, lastBuildDate contains the last time an item in the feed was updated; if that is not present,
|
||||
// use the pubDate element instead
|
||||
$updated = self::eltValue($channel, 'lastBuildDate');
|
||||
if ($updated == 'lastBuildDate not found') {
|
||||
$updated = self::eltValue($channel, 'pubDate');
|
||||
if ($updated == 'pubDate not found') $updated = null;
|
||||
}
|
||||
$feedId = Data::addFeed($feed['url'], self::eltValue($channel, 'title'), $updated);
|
||||
|
||||
$result = self::updateItems($feedId, $channel);
|
||||
if (array_key_exists('error', $result)) return $result;
|
||||
|
||||
Reference in New Issue
Block a user