NextInpactBridge.php 1.5 KB

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