FeedsOPMLParser.inc 890 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * @file
  4. * OPML Parser plugin.
  5. */
  6. /**
  7. * Feeds parser plugin that parses OPML feeds.
  8. */
  9. class FeedsOPMLParser extends FeedsParser {
  10. /**
  11. * Implements FeedsParser::parse().
  12. */
  13. public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
  14. feeds_include_library('opml_parser.inc', 'opml_parser');
  15. $opml = opml_parser_parse($fetcher_result->getRaw());
  16. $result = new FeedsParserResult($opml['items']);
  17. $result->title = $opml['title'];
  18. return $result;
  19. }
  20. /**
  21. * Return mapping sources.
  22. */
  23. public function getMappingSources() {
  24. return array(
  25. 'title' => array(
  26. 'name' => t('Feed title'),
  27. 'description' => t('Title of the feed.'),
  28. ),
  29. 'xmlurl' => array(
  30. 'name' => t('Feed URL'),
  31. 'description' => t('URL of the feed.'),
  32. ),
  33. ) + parent::getMappingSources();
  34. }
  35. }