EliteDangerousGalnetBridge.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. class EliteDangerousGalnetBridge extends BridgeAbstract
  3. {
  4. const MAINTAINER = "corenting";
  5. const NAME = "Elite: Dangerous Galnet";
  6. const URI = "https://community.elitedangerous.com/galnet/";
  7. const CACHE_TIMEOUT = 7200; // 2h
  8. const DESCRIPTION = "Returns the latest page of news from Galnet";
  9. public function collectData()
  10. {
  11. $html = getSimpleHTMLDOM(self::URI)
  12. or returnServerError('Error while downloading the website content');
  13. foreach($html->find('div.article') as $element) {
  14. $item = array();
  15. $uri = $element->find('h3 a', 0)->href;
  16. $uri = self::URI . substr($uri,strlen('/galnet/'));
  17. $item['uri'] = $uri;
  18. $title = $element->find('h3 a', 0)->plaintext;
  19. $item['title'] = substr($title, 1); //remove the space between icon and title
  20. $content = $element->find('p', -1)->innertext;
  21. $item['content'] = $content;
  22. $date = $element->find('p.small', 0)->innertext;
  23. $article_year = substr($date, -4) - 1286; //Convert E:D date to actual date
  24. $date = substr($date, 0, -4) . $article_year;
  25. $item['timestamp'] = strtotime($date);
  26. $this->items[] = $item;
  27. }
  28. }
  29. }