1
0

AcrimedBridge.php 1.3 KB

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