EstCeQuonMetEnProdBridge.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. class EstCeQuonMetEnProdBridge extends BridgeAbstract {
  3. public function loadMetadatas() {
  4. $this->maintainer = 'ORelio';
  5. $this->name = $this->getName();
  6. $this->uri = $this->getURI();
  7. $this->description = $this->getDescription();
  8. $this->update = "02/07/2016";
  9. }
  10. public function collectData(array $param) {
  11. function ExtractFromDelimiters($string, $start, $end) {
  12. if (strpos($string, $start) !== false) {
  13. $section_retrieved = substr($string, strpos($string, $start) + strlen($start));
  14. $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
  15. return $section_retrieved;
  16. } return false;
  17. }
  18. $html = $this->file_get_html($this->getURI()) or $this->returnError('Could not request EstCeQuonMetEnProd: '.$this->getURI(), 500);
  19. $img = $html->find('img', 0);
  20. if (is_object($img)) {
  21. $img = $img->src;
  22. if ($img[0] == '/')
  23. $img = substr($this->getURI(), 0, strlen($this->getURI()) - 1).$img;
  24. }
  25. $item = new \Item();
  26. $item->uri = $this->getURI().'#'.date('Y-m-d');
  27. $item->thumbnailUri = $img;
  28. $item->title = $this->getName();
  29. $item->author = 'Nicolas Hoffmann';
  30. $item->timestamp = strtotime('today midnight');
  31. $item->content = str_replace('src="/', 'src="'.$this->getURI(), trim(ExtractFromDelimiters($html->outertext, '<body role="document">', '<br /><br />')));
  32. $this->items[] = $item;
  33. }
  34. public function getName() {
  35. return 'Est-ce qu\'on met en prod aujourd\'hui ?';
  36. }
  37. public function getURI() {
  38. return 'https://www.estcequonmetenprodaujourdhui.info/';
  39. }
  40. public function getDescription() {
  41. return 'Should we put a website in production today? (French)';
  42. }
  43. public function getCacheDuration() {
  44. return 21600; // 6 hours
  45. }
  46. }
  47. ?>