1
0

ScilogsBridge.php 1.4 KB

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