FeedExpanderExampleBridge.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. class FeedExpanderExampleBridge extends FeedExpander {
  3. const MAINTAINER = 'logmanoriginal';
  4. const NAME = 'FeedExpander Example';
  5. const URI = '#';
  6. const DESCRIPTION = 'Example bridge to test FeedExpander';
  7. const PARAMETERS = array(
  8. 'Feed' => array(
  9. 'version' => array(
  10. 'name' => 'Version',
  11. 'type' => 'list',
  12. 'required' => true,
  13. 'title' => 'Select your feed format/version',
  14. 'defaultValue' => 'RSS 2.0',
  15. 'values' => array(
  16. 'RSS 0.91' => 'rss_0_9_1',
  17. 'RSS 1.0' => 'rss_1_0',
  18. 'RSS 2.0' => 'rss_2_0',
  19. 'ATOM 1.0' => 'atom_1_0'
  20. )
  21. )
  22. )
  23. );
  24. public function collectData(){
  25. switch($this->getInput('version')) {
  26. case 'rss_0_9_1':
  27. parent::collectExpandableDatas('http://static.userland.com/gems/backend/sampleRss.xml');
  28. break;
  29. case 'rss_1_0':
  30. parent::collectExpandableDatas('http://feeds.nature.com/nature/rss/current?format=xml');
  31. break;
  32. case 'rss_2_0':
  33. parent::collectExpandableDatas('http://feeds.rssboard.org/rssboard?format=xml');
  34. break;
  35. case 'atom_1_0':
  36. parent::collectExpandableDatas('http://segfault.linuxmint.com/feed/atom/');
  37. break;
  38. default: returnClientError('Unknown version ' . $this->getInput('version') . '!');
  39. }
  40. }
  41. protected function parseItem($newsItem) {
  42. switch($this->getInput('version')) {
  43. case 'rss_0_9_1':
  44. return $this->parseRSS_0_9_1_Item($newsItem);
  45. break;
  46. case 'rss_1_0':
  47. return $this->parseRSS_1_0_Item($newsItem);
  48. break;
  49. case 'rss_2_0':
  50. return $this->parseRSS_2_0_Item($newsItem);
  51. break;
  52. case 'atom_1_0':
  53. return $this->parseATOMItem($newsItem);
  54. break;
  55. default: returnClientError('Unknown version ' . $this->getInput('version') . '!');
  56. }
  57. }
  58. }