/** * 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; }