NotAlwaysBridge.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. class NotAlwaysBridge extends BridgeAbstract {
  3. const MAINTAINER = 'mozes';
  4. const NAME = 'Not Always family Bridge';
  5. const URI = 'https://notalwaysright.com/';
  6. const DESCRIPTION = 'Returns the latest stories';
  7. const CACHE_TIMEOUT = 1800; // 30 minutes
  8. const PARAMETERS = array( array(
  9. 'filter' => array(
  10. 'type' => 'list',
  11. 'name' => 'Filter',
  12. 'values' => array(
  13. 'All' => 'all',
  14. 'Right' => 'right',
  15. 'Working' => 'working',
  16. 'Romantic' => 'romantic',
  17. 'Related' => 'related',
  18. 'Learning' => 'learning',
  19. 'Friendly' => 'friendly',
  20. 'Hopeless' => 'hopeless',
  21. 'Unfiltered' => 'unfiltered'
  22. ),
  23. 'required' => true
  24. )
  25. ));
  26. public function collectData(){
  27. $html = getSimpleHTMLDOM($this->getURI())
  28. or returnServerError('Could not request NotAlways.');
  29. foreach($html->find('.post') as $post) {
  30. #print_r($post);
  31. $item = array();
  32. $item['uri'] = $post->find('h1', 0)->find('a', 0)->href;
  33. $item['content'] = $post;
  34. $item['title'] = $post->find('h1', 0)->find('a', 0)->innertext;
  35. $this->items[] = $item;
  36. }
  37. }
  38. public function getName(){
  39. if(!is_null($this->getInput('filter'))) {
  40. return $this->getInput('filter') . ' - NotAlways Bridge';
  41. }
  42. return parent::getName();
  43. }
  44. public function getURI(){
  45. if(!is_null($this->getInput('filter'))) {
  46. return self::URI . $this->getInput('filter') . '/';
  47. }
  48. return parent::getURI();
  49. }
  50. }