DauphineLibereBridge.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. class DauphineLibereBridge extends FeedExpander {
  3. const MAINTAINER = 'qwertygc';
  4. const NAME = 'Dauphine Bridge';
  5. const URI = 'http://www.ledauphine.com/';
  6. const CACHE_TIMEOUT = 7200; // 2h
  7. const DESCRIPTION = 'Returns the newest articles.';
  8. const PARAMETERS = array( array(
  9. 'u' => array(
  10. 'name' => 'Catégorie de l\'article',
  11. 'type' => 'list',
  12. 'values' => array(
  13. 'À la une' => '',
  14. 'France Monde' => 'france-monde',
  15. 'Faits Divers' => 'faits-divers',
  16. 'Économie et Finance' => 'economie-et-finance',
  17. 'Politique' => 'politique',
  18. 'Sport' => 'sport',
  19. 'Ain' => 'ain',
  20. 'Alpes-de-Haute-Provence' => 'haute-provence',
  21. 'Hautes-Alpes' => 'hautes-alpes',
  22. 'Ardèche' => 'ardeche',
  23. 'Drôme' => 'drome',
  24. 'Isère Sud' => 'isere-sud',
  25. 'Savoie' => 'savoie',
  26. 'Haute-Savoie' => 'haute-savoie',
  27. 'Vaucluse' => 'vaucluse'
  28. )
  29. )
  30. ));
  31. public function collectData(){
  32. $url = self::URI . 'rss';
  33. if(empty($this->getInput('u'))) {
  34. $url = self::URI . $this->getInput('u') . '/rss';
  35. }
  36. $this->collectExpandableDatas($url, 10);
  37. }
  38. protected function parseItem($newsItem){
  39. $item = parent::parseItem($newsItem);
  40. $item['content'] = $this->extractContent($item['uri']);
  41. return $item;
  42. }
  43. private function extractContent($url){
  44. $html2 = getSimpleHTMLDOMCached($url);
  45. $text = $html2->find('div.column', 0)->innertext;
  46. $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
  47. return $text;
  48. }
  49. }