GuruMedBridge.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * RssBridgeGuruMed
  4. * Returns the 5 newest posts from http://www.gurumed.org (full text)
  5. *
  6. * @name GuruMed
  7. * @description Returns the 5 newest posts from Gurumed (full text)
  8. * @homepage http://www.gurumed.org
  9. *@maintainer qwertygc
  10. */
  11. class GuruMedBridge extends BridgeAbstract{
  12. public function collectData(array $param){
  13. function GurumedStripCDATA($string) {
  14. $string = str_replace('<![CDATA[', '', $string);
  15. $string = str_replace(']]>', '', $string);
  16. return $string;
  17. }
  18. function GurumedExtractContent($url) {
  19. $html2 = file_get_html($url);
  20. $text = $html2->find('div.entry', 0)->innertext;
  21. return $text;
  22. }
  23. $html = file_get_html('http://gurumed.org/feed') or $this->returnError('Could not request Gurumed.', 404);
  24. $limit = 0;
  25. foreach($html->find('item') as $element) {
  26. if($limit < 5) {
  27. $item = new \Item();
  28. $item->title = GurumedStripCDATA($element->find('title', 0)->innertext);
  29. $item->uri = GurumedStripCDATA($element->find('guid', 0)->plaintext);
  30. $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
  31. $item->content = GurumedExtractContent($item->uri);
  32. $this->items[] = $item;
  33. $limit++;
  34. }
  35. }
  36. }
  37. public function getName(){
  38. return 'Gurumed';
  39. }
  40. public function getURI(){
  41. return 'http://gurumed.org/';
  42. }
  43. public function getCacheDuration(){
  44. return 3600; // 1 hour
  45. }
  46. }