Exemple #1
0
 /**
  * Find the item date.
  *
  * @param SimpleXMLElement      $entry Feed item
  * @param Item                  $item  Item object
  * @param \AsteFeed\Parser\Feed $feed  Feed object
  */
 public function findItemDate(SimpleXMLElement $entry, Item $item, Feed $feed)
 {
     $published = XmlParser::getXPathResult($entry, 'atom:published', $this->namespaces) ?: XmlParser::getXPathResult($entry, 'published');
     $updated = XmlParser::getXPathResult($entry, 'atom:updated', $this->namespaces) ?: XmlParser::getXPathResult($entry, 'updated');
     $published = !empty($published) ? $this->date->getDateTime((string) current($published)) : null;
     $updated = !empty($updated) ? $this->date->getDateTime((string) current($updated)) : null;
     if ($published === null && $updated === null) {
         $item->date = $feed->getDate();
         // We use the feed date if there is no date for the item
     } elseif ($published !== null && $updated !== null) {
         $item->date = max($published, $updated);
         // We use the most recent date between published and updated
     } else {
         $item->date = $updated ?: $published;
     }
 }
Exemple #2
0
 /**
  * Find the item date.
  *
  * @param SimpleXMLElement      $entry Feed item
  * @param Item                  $item  Item object
  * @param \AsteFeed\Parser\Feed $feed  Feed object
  */
 public function findItemDate(SimpleXMLElement $entry, Item $item, Feed $feed)
 {
     $date = XmlParser::getXPathResult($entry, 'dc:date', $this->namespaces);
     $item->date = empty($date) ? $feed->getDate() : $this->date->getDateTime((string) current($date));
 }