KoreusBridge.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. class KoreusBridge extends BridgeAbstract{
  3. public function loadMetadatas() {
  4. $this->maintainer = "pit-fgfjiudghdf";
  5. $this->name = "Koreus";
  6. $this->uri = "http://www.koreus.com/";
  7. $this->description = "Returns the 5 newest posts from Koreus (full text)";
  8. $this->update = "2014-05-26";
  9. }
  10. public function collectData(array $param){
  11. function KoreusStripCDATA($string) {
  12. $string = str_replace('<![CDATA[', '', $string);
  13. $string = str_replace(']]>', '', $string);
  14. return $string;
  15. }
  16. function KoreusExtractContent($url) {
  17. $html2 = $this->file_get_html($url);
  18. $text = $html2->find('p[class=itemText]', 0)->innertext;
  19. $text = utf8_encode(preg_replace('/(Sur le m.+?)+$/i','',$text));
  20. return $text;
  21. }
  22. $html = $this->file_get_html('http://feeds.feedburner.com/Koreus-articles') or $this->returnError('Could not request Koreus.', 404);
  23. $limit = 0;
  24. foreach($html->find('item') as $element) {
  25. if($limit < 5) {
  26. $item = new \Item();
  27. $item->title = KoreusStripCDATA($element->find('title', 0)->innertext);
  28. $item->uri = KoreusStripCDATA($element->find('guid', 0)->plaintext);
  29. $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
  30. $item->content = KoreusExtractContent($item->uri);
  31. $this->items[] = $item;
  32. $limit++;
  33. }
  34. }
  35. }
  36. public function getName(){
  37. return 'Koreus';
  38. }
  39. public function getURI(){
  40. return 'http://www.koreus.com/';
  41. }
  42. public function getCacheDuration(){
  43. return 3600; // 1 hour
  44. }
  45. }