/** * 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; }
/** * 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'); }
/** * 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; }
function get_date($date_format = 'j F Y, g:i a') { return apply_filters('feedwordpie_item_get_date', parent::get_date($date_format), $date_format, $this); }
/** * 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()); }
/** * 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; }