ScilogsBridge.php 1.4 KB

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