EliteDangerousGalnetBridge.php 1.1 KB

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