GuruMedBridge.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. class GuruMedBridge extends BridgeAbstract{
  3. public function loadMetadatas() {
  4. $this->maintainer = "qwertygc";
  5. $this->name = "GuruMed";
  6. $this->uri = "http://www.gurumed.org";
  7. $this->description = "Returns the 5 newest posts from Gurumed (full text)";
  8. $this->update = "2016-08-06";
  9. }
  10. private function GurumedStripCDATA($string) {
  11. $string = str_replace('<![CDATA[', '', $string);
  12. $string = str_replace(']]>', '', $string);
  13. return $string;
  14. }
  15. public function collectData(array $param){
  16. $html = $this->file_get_html('http://gurumed.org/feed') or $this->returnError('Could not request Gurumed.', 404);
  17. $limit = 0;
  18. foreach($html->find('item') as $element) {
  19. if($limit < 5) {
  20. $item = new \Item();
  21. $item->title = $this->GurumedStripCDATA($element->find('title', 0)->innertext);
  22. $item->uri = $this->GurumedStripCDATA($element->find('guid', 0)->plaintext);
  23. $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
  24. $item->content = $this->GurumedStripCDATA(strip_tags($element->find('description', 0), '<p><a><br>'));
  25. $this->items[] = $item;
  26. $limit++;
  27. }
  28. }
  29. }
  30. public function getName(){
  31. return 'Gurumed';
  32. }
  33. public function getURI(){
  34. return 'http://gurumed.org/';
  35. }
  36. }