You are here

public function Rss::getAuthors in Zircon Profile 8

Same name in this branch
  1. 8 vendor/zendframework/zend-feed/src/Reader/Entry/Rss.php \Zend\Feed\Reader\Entry\Rss::getAuthors()
  2. 8 vendor/zendframework/zend-feed/src/Reader/Feed/Rss.php \Zend\Feed\Reader\Feed\Rss::getAuthors()
Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-feed/src/Reader/Entry/Rss.php \Zend\Feed\Reader\Entry\Rss::getAuthors()

Get an array with feed authors

Return value

array

Overrides EntryInterface::getAuthors

1 call to Rss::getAuthors()
Rss::getAuthor in vendor/zendframework/zend-feed/src/Reader/Entry/Rss.php
Get an author entry

File

vendor/zendframework/zend-feed/src/Reader/Entry/Rss.php, line 87

Class

Rss

Namespace

Zend\Feed\Reader\Entry

Code

public function getAuthors() {
  if (array_key_exists('authors', $this->data)) {
    return $this->data['authors'];
  }
  $authors = [];
  $authorsDc = $this
    ->getExtension('DublinCore')
    ->getAuthors();
  if (!empty($authorsDc)) {
    foreach ($authorsDc as $author) {
      $authors[] = [
        'name' => $author['name'],
      ];
    }
  }
  if ($this
    ->getType() !== Reader\Reader::TYPE_RSS_10 && $this
    ->getType() !== Reader\Reader::TYPE_RSS_090) {
    $list = $this->xpath
      ->query($this->xpathQueryRss . '//author');
  }
  else {
    $list = $this->xpath
      ->query($this->xpathQueryRdf . '//rss:author');
  }
  if ($list->length) {
    foreach ($list as $author) {
      $string = trim($author->nodeValue);
      $data = [];

      // Pretty rough parsing - but it's a catchall
      if (preg_match("/^.*@[^ ]*/", $string, $matches)) {
        $data['email'] = trim($matches[0]);
        if (preg_match("/\\((.*)\\)\$/", $string, $matches)) {
          $data['name'] = $matches[1];
        }
        $authors[] = $data;
      }
    }
  }
  if (count($authors) == 0) {
    $authors = $this
      ->getExtension('Atom')
      ->getAuthors();
  }
  else {
    $authors = new Reader\Collection\Author(Reader\Reader::arrayUnique($authors));
  }
  if (count($authors) == 0) {
    $authors = null;
  }
  $this->data['authors'] = $authors;
  return $this->data['authors'];
}