get_author() 공개 메소드

Get an author for the item
public get_author ( integer $key ) : SimplePie_Author | null
$key integer The author that you want to return. Remember that arrays begin with 0, not 1
리턴 SimplePie_Author | null
예제 #1
0
 /**
  * Parses a since feed item.
  *
  * @param \Devour\Table\TableInterface $table
  *   A table obeject.
  * @param \SimplePie_Item $item
  *   A SimplePie item.
  */
 protected function parseItem(TableInterface $table, \SimplePie_Item $item)
 {
     // @todo Add more fields.
     $row = $table->getNewRow();
     $row->set('id', $item->get_id())->set('permalink', $item->get_permalink())->set('title', $item->get_title())->set('date', $item->get_gmdate('U'))->set('content', $item->get_content());
     if ($author = $item->get_author()) {
         $row->set('author_name', $author->get_name())->set('author_email', $author->get_email());
     }
 }
예제 #2
0
 /**
  * The constructor stores feed item attributes as properties.
  * 
  * @param type $feed the feed the new item belongs to
  * @param SimplePie_Item $item SimplePie_Item that contains information
  * about the item
  */
 public function __construct($feed, $item)
 {
     $this->_feed = $feed;
     $this->_title = $item->get_title();
     $this->_link = $item->get_permalink();
     $this->_description = $item->get_content();
     $this->_date = $item->get_date('U');
     $author = $item->get_author();
     $author_name = $author ? $author->get_name() : NULL;
     $this->_author = $author && empty($author_name) ? $author->get_email() : $author_name;
 }
예제 #3
0
 /**
  * Implements CollectionAbstract::buildDocument().
  *
  * @param IndexDocument $document
  * @param \SimplePie_Item $data
  */
 public function buildDocument(IndexDocument $document, $data)
 {
     $document->source = $this->_feed->get_title();
     $document->subject = $this->_feed->get_description();
     $document->title = $data->get_title();
     $document->link = $data->get_link();
     $document->description = $data->get_description();
     $document->creator = (array) $data->get_author();
     $document->date = $data->get_date();
     // PHP properties cannot have dashes (-), and the fields below have
     // dashes in the field name.
     $document->source_link = $this->_feed->get_link();
     $document->getField('source_link')->setName('source-link');
     $document->item_subject = $this->_feed->get_link();
     $document->getField('item_subject')->setName('item-subject');
 }
예제 #4
0
 /**
  * Parses the simplepie item to a content item
  * @param \SimplePie_Item $tweet
  * @param \Swiftriver\Core\ObjectModel\Channel $channel
  */
 private function ParseTweetFromATOMItem($tweet, $channel)
 {
     //Extract all the relevant feedItem info
     $title = $tweet->get_title();
     //$description = $tweet->get_description();
     $contentLink = $tweet->get_permalink();
     $date = $tweet->get_date();
     //Create the source
     $author = $tweet->get_author();
     $source_name = $author != null ? $author->get_name() : $channel->name;
     $source = \Swiftriver\Core\ObjectModel\ObjectFactories\SourceFactory::CreateSourceFromIdentifier($source_name, $channel->trusted);
     $source->name = $source_name;
     $source->email = $author != null ? $tweet->get_author()->get_email() : null;
     $source->link = $author != null ? $tweet->get_author()->get_link() : null;
     $source->parent = $channel->id;
     $source->type = $channel->type;
     $source->subType = $channel->subType;
     //Add location data
     //Long and lat
     $location = $tweet->get_item_tags("http://www.georss.org/georss", "point");
     $long = 0;
     $lat = 0;
     $name = "";
     if (is_array($location)) {
         $lat_lon_array = split(" ", $location[0]["data"]);
         $long = $lat_lon_array[1];
         $lat = $lat_lon_array[0];
         //Name
         $location_name = $tweet->get_item_tags("http://api.twitter.com", "place");
         if (is_array($location_name)) {
             if (isset($location_name[0]["child"]["http://api.twitter.com"]["full_name"][0]["data"])) {
                 $name = $location_name[0]["child"]["http://api.twitter.com"]["full_name"][0]["data"];
             }
         }
         $source->gisData = array(new \Swiftriver\Core\ObjectModel\GisData($long, $lat, $name));
     }
     //Create a new Content item
     $item = \Swiftriver\Core\ObjectModel\ObjectFactories\ContentFactory::CreateContent($source);
     //Fill the Content Item
     $item->text[] = new \Swiftriver\Core\ObjectModel\LanguageSpecificText(null, $title, array());
     $item->link = $contentLink;
     $item->date = strtotime($date);
     //Sanitize the tweet text into a DIF collection
     $sanitizedTweetDiffCollection = $this->ParseTweetToSanitizedTweetDiffCollection($tweet);
     //Add the dif collection to the item
     $item->difs = array($sanitizedTweetDiffCollection);
     //return the item
     return $item;
 }
예제 #5
0
 /**
  * Populate an item from a feed item
  *
  * @param $item \Planetflow3\Domain\Model\Item
  * @param $feedItem \SimplePie_Item
  * @return void
  */
 protected function populateItemProperties(Item $item, \SimplePie_Item $feedItem)
 {
     $item->setLink($feedItem->get_link());
     $item->setTitle($feedItem->get_title());
     $item->setDescription($feedItem->get_description());
     $item->setContent($feedItem->get_content(TRUE));
     $item->setPublicationDate(new \DateTime($feedItem->get_date()));
     $item->setAuthor($feedItem->get_author());
 }
예제 #6
0
 /**
  * Parses the simplepie item to a content item
  * @param \SimplePie_Item $tweet
  * @param \Swiftriver\Core\ObjectModel\Source
  * @return \Swiftriver\Core\ObjectModel\Content
  */
 private function ParseTweetFromATOMItem($tweet, $channel)
 {
     //Extract all the relevant feedItem info
     $title = $tweet->get_title();
     //$description = $tweet->get_description();
     $contentLink = $tweet->get_permalink();
     $date = $tweet->get_date();
     //Create the source
     $author = $tweet->get_author();
     $source_name = $author != null ? $author->get_name() : $channel->name;
     $source = \Swiftriver\Core\ObjectModel\ObjectFactories\SourceFactory::CreateSourceFromIdentifier($source_name);
     $source->name = $source_name;
     $source->email = $author != null ? $tweet->get_author()->get_email() : null;
     $source->link = $author != null ? $tweet->get_author()->get_link() : null;
     $source->parent = $channel->id;
     $source->type = $channel->type;
     $source->subType = $channel->subType;
     //Create a new Content item
     $item = \Swiftriver\Core\ObjectModel\ObjectFactories\ContentFactory::CreateContent($source);
     //Fill the Content Item
     $item->text[] = new \Swiftriver\Core\ObjectModel\LanguageSpecificText(null, $title, array());
     $item->link = $contentLink;
     $item->date = strtotime($date);
     return $item;
 }