-
Notifications
You must be signed in to change notification settings - Fork 1k
/
EliteDangerousGalnetBridge.php
61 lines (50 loc) · 1.98 KB
/
EliteDangerousGalnetBridge.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
class EliteDangerousGalnetBridge extends BridgeAbstract
{
const MAINTAINER = 'corenting';
const NAME = 'Elite: Dangerous Galnet';
const URI = 'https://community.elitedangerous.com/galnet/';
const CACHE_TIMEOUT = 7200; // 2h
const DESCRIPTION = 'Returns the latest page of news from Galnet';
const PARAMETERS = [
[
'language' => [
'name' => 'Language',
'type' => 'list',
'values' => [
'English' => 'en-US',
'French' => 'fr-FR',
'German' => 'de-DE',
'Russian' => 'ru-RU',
'Spanish' => 'es-ES',
],
'defaultValue' => 'en-US'
]
]
];
public function collectData()
{
$language = $this->getInput('language');
$url = 'https://cms.zaonce.net/';
$url = $url . $language . '/jsonapi/node/galnet_article';
$url = $url . '?&sort=-published_at&page[offset]=0&page[limit]=12';
$html = getSimpleHTMLDOM($url);
$json = json_decode($html);
foreach ($json->data as $element) {
$item = [];
$uri = 'https://www.elitedangerous.com/news/galnet/';
$uri = $uri . $element->attributes->field_slug;
$item['uri'] = $uri;
$item['title'] = $element->attributes->title;
$picture = 'https://hosting.zaonce.net/elite-dangerous/galnet/';
$picture = $picture . $element->attributes->field_galnet_image . '.png';
$picture = '<img src="' . $picture . '"/>';
$content = $element->attributes->body->processed;
$item['content'] = $picture . $content;
$item['timestamp'] = strtotime($element->attributes->published_at);
$this->items[] = $item;
}
//Remove duplicates that sometimes show up on the website
$this->items = array_unique($this->items, SORT_REGULAR);
}
}