diff options
Diffstat (limited to 'vendor/fguillot/picofeed/lib/PicoFeed/Parser')
-rw-r--r-- | vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php | 14 | ||||
-rw-r--r-- | vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php | 9 | ||||
-rw-r--r-- | vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss20.php | 9 |
3 files changed, 19 insertions, 13 deletions
diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php index 21566527e..0e53d2778 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php @@ -138,16 +138,20 @@ class Atom extends Parser * Find the item date * * @access public - * @param SimpleXMLElement $entry Feed item - * @param Item $item Item object + * @param SimpleXMLElement $entry Feed item + * @param Item $item Item object + * @param \PicoFeed\Parser\Feed $feed Feed object */ - public function findItemDate(SimpleXMLElement $entry, Item $item) + public function findItemDate(SimpleXMLElement $entry, Item $item, Feed $feed) { $published = isset($entry->published) ? $this->date->getDateTime((string) $entry->published) : null; $updated = isset($entry->updated) ? $this->date->getDateTime((string) $entry->updated) : null; - if ($published !== null && $updated !== null) { - $item->date = max($published, $updated); + if ($published === null && $updated === null) { + $item->date = $feed->getDate(); // We use the feed date if there is no date for the item + } + else if ($published !== null && $updated !== null) { + $item->date = max($published, $updated); // We use the most recent date between published and updated } else { $item->date = $updated ?: $published; diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php index 7ada6d10f..4d45f539c 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php @@ -164,7 +164,7 @@ abstract class Parser // Id generation can use the item url/title/content (order is important) $this->findItemId($entry, $item, $feed); - $this->findItemDate($entry, $item); + $this->findItemDate($entry, $item, $feed); $this->findItemEnclosure($entry, $item, $feed); $this->findItemLanguage($entry, $item, $feed); @@ -333,7 +333,7 @@ abstract class Parser if ($timezone) { $this->date->timezone = $timezone; } - + return $this; } @@ -532,9 +532,10 @@ abstract class Parser * * @access public * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object + * @param Item $item Item object + * @param \PicoFeed\Parser\Feed $feed Feed object */ - public abstract function findItemDate(SimpleXMLElement $entry, Item $item); + public abstract function findItemDate(SimpleXMLElement $entry, Item $item, Feed $feed); /** * Find the item content diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss20.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss20.php index b5fb09580..2529b5984 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss20.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss20.php @@ -142,9 +142,10 @@ class Rss20 extends Parser * * @access public * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object + * @param Item $item Item object + * @param \PicoFeed\Parser\Feed $feed Feed object */ - public function findItemDate(SimpleXMLElement $entry, Item $item) + public function findItemDate(SimpleXMLElement $entry, Item $item, Feed $feed) { $date = XmlParser::getNamespaceValue($entry, $this->namespaces, 'date'); @@ -156,7 +157,7 @@ class Rss20 extends Parser $date = (string) $entry->pubDate; } - $item->date = $this->date->getDateTime($date); + $item->date = empty($date) ? $feed->getDate() : $this->date->getDateTime($date); } /** @@ -208,7 +209,7 @@ class Rss20 extends Parser { $content = XmlParser::getNamespaceValue($entry, $this->namespaces, 'encoded'); - if (empty($content) && $entry->description->count() > 0) { + if (trim($content) === '' && $entry->description->count() > 0) { $content = (string) $entry->description; } |