EliteDangerousGalnetBridge.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 DESCRIPTION = "Returns the latest page of news from Galnet";
  8. public function collectData()
  9. {
  10. $html = getSimpleHTMLDOM(self::URI)
  11. or returnServerError('Error while downloading the website content');
  12. foreach($html->find('div.article') as $element) {
  13. $item = array();
  14. $uri = $element->find('h3 a', 0)->href;
  15. $uri = self::URI . substr($uri,strlen('/galnet/'));
  16. $item['uri'] = $uri;
  17. $title = $element->find('h3 a', 0)->plaintext;
  18. $item['title'] = substr($title, 1); //remove the space between icon and title
  19. $content = $element->find('p', -1)->innertext;
  20. $item['content'] = $content;
  21. $date = $element->find('p.small', 0)->innertext;
  22. $article_year = substr($date, -4) - 1286; //Convert E:D date to actual date
  23. $date = substr($date, 0, -4) . $article_year;
  24. $item['timestamp'] = strtotime($date);
  25. $this->items[] = $item;
  26. }
  27. }
  28. public function getCacheDuration()
  29. {
  30. return 3600 * 2; // 2 hours
  31. }
  32. }