2016-04-06 17:13:09 +03:00
|
|
|
|
|
|
|
<?php
|
|
|
|
class EliteDangerousGalnetBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
public function loadMetadatas()
|
|
|
|
{
|
|
|
|
$this->maintainer = "corenting";
|
|
|
|
$this->name = "Elite: Dangerous Galnet";
|
|
|
|
$this->uri = "https://community.elitedangerous.com/galnet";
|
|
|
|
$this->description = "Returns the latest page of news from Galnet";
|
|
|
|
}
|
|
|
|
|
2016-08-25 02:24:53 +03:00
|
|
|
public function collectData()
|
2016-04-06 17:13:09 +03:00
|
|
|
{
|
2016-07-08 20:06:35 +03:00
|
|
|
$html = $this->getSimpleHTMLDOM('https://community.elitedangerous.com/galnet') or $this->returnServerError('Error while downloading the website content');
|
2016-04-06 17:13:09 +03:00
|
|
|
foreach($html->find('div.article') as $element) {
|
2016-08-22 19:55:59 +03:00
|
|
|
$item = array();
|
2016-04-06 17:13:09 +03:00
|
|
|
|
|
|
|
$uri = $element->find('h3 a', 0)->href;
|
|
|
|
$uri = 'https://community.elitedangerous.com' . $uri;
|
2016-08-22 19:55:59 +03:00
|
|
|
$item['uri'] = $uri;
|
2016-04-06 17:13:09 +03:00
|
|
|
|
|
|
|
$title = $element->find('h3 a', 0)->plaintext;
|
2016-08-22 19:55:59 +03:00
|
|
|
$item['title'] = substr($title, 1); //remove the space between icon and title
|
2016-04-06 17:13:09 +03:00
|
|
|
|
|
|
|
$content = $element->find('p', -1)->innertext;
|
2016-08-22 19:55:59 +03:00
|
|
|
$item['content'] = $content;
|
2016-04-06 17:13:09 +03: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 19:55:59 +03:00
|
|
|
$item['timestamp'] = strtotime($date);
|
2016-04-06 17:13:09 +03:00
|
|
|
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration()
|
|
|
|
{
|
|
|
|
return 3600 * 2; // 2 hours
|
|
|
|
}
|
2016-07-08 20:06:35 +03:00
|
|
|
}
|