1
0

DauphineLibereBridge.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * @name DauphineLibereBridge Bridge
  4. * @homepage http://www.ledauphine.com/
  5. * @description Returns the newest articles. For choice « à la une » leave empty the input. For « France-Monde » input "france-monde". For « Faits Divers » input "faits-divers". For « Economie et Finance » input "economie-et-finance". For « Politique » input "politique". For « Sport » input "sport". For « Ain » input "ain". For « Alpes-de-Haute-Provence » input "haute-provence". For « Hautes-Alpes » input "hautes-alpes". For « Ardèche » input "ardeche". For « Drôme » input "drome". For « Isere Sud » input "isere-sud". For « Isere Nord » input "isere-nord". For « Savoie » input "savoie". For « Haute-Savoie » input "haute-savoie". For « Vaucluse » input "vaucluse".
  6. * @maintainer qwertygc
  7. * @use1(u="edition")
  8. */
  9. class DauphineLibereBridge extends BridgeAbstract{
  10. public function collectData(array $param){
  11. function ExtractContent($url) {
  12. $html2 = file_get_html($url);
  13. $text = $html2->find('div.column', 0)->innertext;
  14. $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
  15. return $text;
  16. }
  17. if (isset($param['u'])) { /* user timeline mode */
  18. $this->request = $param['u'];
  19. $html = file_get_html('http://www.ledauphine.com/'.$this->request.'/rss') or $this->returnError('Could not request DauphineLibere.', 404);
  20. }
  21. else {
  22. $html = file_get_html('http://www.ledauphine.com/rss') or $this->returnError('Could not request DauphineLibere.', 404);
  23. }
  24. $limit = 0;
  25. foreach($html->find('item') as $element) {
  26. if($limit < 10) {
  27. $item = new \Item();
  28. $item->title = $element->find('title', 0)->innertext;
  29. $item->uri = $element->find('guid', 0)->plaintext;
  30. $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
  31. $item->content = ExtractContent($item->uri);
  32. $this->items[] = $item;
  33. $limit++;
  34. }
  35. }
  36. }
  37. public function getName(){
  38. return 'Dauphine Bridge';
  39. }
  40. public function getURI(){
  41. return 'http://ledauphine.com/';
  42. }
  43. public function getCacheDuration(){
  44. return 3600*2; // 2 hours
  45. // return 0; // 2 hours
  46. }
  47. }