KoreusBridge.php 1.6 KB

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