GuruMedBridge.php 1.1 KB

123456789101112131415161718192021222324252627282930313233
  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. }
  9. private function GurumedStripCDATA($string) {
  10. $string = str_replace('<![CDATA[', '', $string);
  11. $string = str_replace(']]>', '', $string);
  12. return $string;
  13. }
  14. public function collectData(array $param){
  15. $html = $this->getSimpleHTMLDOM('http://gurumed.org/feed') or $this->returnServerError('Could not request Gurumed.');
  16. $limit = 0;
  17. foreach($html->find('item') as $element) {
  18. if($limit < 5) {
  19. $item = array();
  20. $item['title'] = $this->GurumedStripCDATA($element->find('title', 0)->innertext);
  21. $item['uri'] = $this->GurumedStripCDATA($element->find('guid', 0)->plaintext);
  22. $item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
  23. $item['content'] = $this->GurumedStripCDATA(strip_tags($element->find('description', 0), '<p><a><br>'));
  24. $this->items[] = $item;
  25. $limit++;
  26. }
  27. }
  28. }
  29. }