1
0

PlanetLibreBridge.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * RssBridgePlanetLibre
  4. * Returns the 5 newest posts from PlanetLibre (full text)
  5. *
  6. * @name PlanetLibre
  7. * @homepage http://www.planet-libre.org
  8. * @description Returns the 5 newest posts from PlanetLibre (full text)
  9. * @maintainer pit-fgfjiudghdf
  10. * @update 2014-05-26
  11. */
  12. class PlanetLibreBridge extends BridgeAbstract{
  13. public function collectData(array $param){
  14. function PlanetLibreExtractContent($url) {
  15. $html2 = file_get_html($url);
  16. $text = $html2->find('div[class="post-text"]', 0)->innertext;
  17. return $text;
  18. }
  19. $html = file_get_html('http://www.planet-libre.org/') or $this->returnError('Could not request PlanetLibre.', 404);
  20. $limit = 0;
  21. foreach($html->find('div.post') as $element) {
  22. if($limit < 5) {
  23. $item = new \Item();
  24. $item->title = $element->find('h1', 0)->plaintext;
  25. $item->uri = $element->find('a', 0)->href;
  26. $item->timestamp = strtotime(str_replace('/', '-', $element->find('div[class="post-date"]', 0)->plaintext));
  27. $item->content = PlanetLibreExtractContent($item->uri);
  28. $this->items[] = $item;
  29. $limit++;
  30. }
  31. }
  32. }
  33. public function getName(){
  34. return 'PlanetLibre';
  35. }
  36. public function getURI(){
  37. return 'http://www.planet-libre.org/';
  38. }
  39. public function getCacheDuration(){
  40. return 3600*2; // 1 hour
  41. }
  42. }