You are here

public function FeedsSyndicationParser::parse in Feeds 7

Same name and namespace in other branches
  1. 6 plugins/FeedsSyndicationParser.inc \FeedsSyndicationParser::parse()
  2. 7.2 plugins/FeedsSyndicationParser.inc \FeedsSyndicationParser::parse()

Implements FeedsParser::parse().

Overrides FeedsParser::parse

File

plugins/FeedsSyndicationParser.inc, line 13

Class

FeedsSyndicationParser
Class definition for Common Syndication Parser.

Code

public function parse(FeedsImportBatch $batch, FeedsSource $source) {
  feeds_include_library('common_syndication_parser.inc', 'common_syndication_parser');
  $result = common_syndication_parser_parse($batch
    ->getRaw());
  $batch
    ->setTitle($result['title']);
  $batch
    ->setDescription($result['description']);
  $batch
    ->setLink($result['link']);
  if (is_array($result['items'])) {
    foreach ($result['items'] as $item) {
      if (isset($item['geolocations'])) {
        foreach ($item['geolocations'] as $k => $v) {
          $item['geolocations'][$k] = new FeedsGeoTermElement($v);
        }
      }
      $batch
        ->addItem($item);
    }
  }
}