2016-04-06 16:13:09 +02:00
|
|
|
<?php
|
|
|
|
class EliteDangerousGalnetBridge extends BridgeAbstract
|
|
|
|
{
|
2016-08-30 11:23:55 +02:00
|
|
|
const MAINTAINER = "corenting";
|
|
|
|
const NAME = "Elite: Dangerous Galnet";
|
|
|
|
const URI = "https://community.elitedangerous.com/galnet/";
|
2016-09-25 17:04:28 +02:00
|
|
|
const CACHE_TIMEOUT = 7200; // 2h
|
2016-08-30 11:23:55 +02:00
|
|
|
const DESCRIPTION = "Returns the latest page of news from Galnet";
|
2016-04-06 16:13:09 +02:00
|
|
|
|
2016-08-25 01:24:53 +02:00
|
|
|
public function collectData()
|
2016-04-06 16:13:09 +02:00
|
|
|
{
|
2016-09-25 23:22:33 +02:00
|
|
|
$html = getSimpleHTMLDOM(self::URI)
|
|
|
|
or returnServerError('Error while downloading the website content');
|
2016-04-06 16:13:09 +02:00
|
|
|
foreach($html->find('div.article') as $element) {
|
2016-08-22 18:55:59 +02:00
|
|
|
$item = array();
|
2016-04-06 16:13:09 +02:00
|
|
|
|
|
|
|
$uri = $element->find('h3 a', 0)->href;
|
2016-08-30 11:23:55 +02:00
|
|
|
$uri = self::URI . substr($uri,strlen('/galnet/'));
|
2016-08-22 18:55:59 +02:00
|
|
|
$item['uri'] = $uri;
|
2016-04-06 16:13:09 +02:00
|
|
|
|
|
|
|
$title = $element->find('h3 a', 0)->plaintext;
|
2016-08-22 18:55:59 +02:00
|
|
|
$item['title'] = substr($title, 1); //remove the space between icon and title
|
2016-04-06 16:13:09 +02:00
|
|
|
|
|
|
|
$content = $element->find('p', -1)->innertext;
|
2016-08-22 18:55:59 +02:00
|
|
|
$item['content'] = $content;
|
2016-04-06 16:13:09 +02:00
|
|
|
|
|
|
|
$date = $element->find('p.small', 0)->innertext;
|
|
|
|
$article_year = substr($date, -4) - 1286; //Convert E:D date to actual date
|
|
|
|
$date = substr($date, 0, -4) . $article_year;
|
2016-08-22 18:55:59 +02:00
|
|
|
$item['timestamp'] = strtotime($date);
|
2016-04-06 16:13:09 +02:00
|
|
|
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
2016-07-08 19:06:35 +02:00
|
|
|
}
|