2014-03-26 16:22:31 +01:00
|
|
|
<?php
|
|
|
|
define('WORLD_OF_TANKS', 'http://worldoftanks.eu/');
|
|
|
|
define('NEWS', '/news/');
|
|
|
|
class WorldOfTanks extends HttpCachingBridgeAbstract{
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2014-03-26 16:22:31 +01:00
|
|
|
private $lang = "fr";
|
2015-11-04 00:05:10 +01:00
|
|
|
public $uri = WORLD_OF_TANKS;
|
2015-11-05 16:50:18 +01:00
|
|
|
|
|
|
|
public function loadMetadatas() {
|
|
|
|
|
|
|
|
$this->maintainer = "mitsukarenai";
|
|
|
|
$this->name = "World of Tanks";
|
|
|
|
$this->uri = "http://worldoftanks.eu/";
|
|
|
|
$this->description = "News about the tank slaughter game.";
|
|
|
|
|
|
|
|
$this->parameters[] =
|
|
|
|
'[
|
|
|
|
{
|
|
|
|
"name" : "ID de la catégorie",
|
|
|
|
"type" : "number",
|
|
|
|
"identifier" : "category"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Langue",
|
|
|
|
"identifier" : "lang",
|
|
|
|
"type" : "list",
|
|
|
|
"values" : [
|
|
|
|
{
|
|
|
|
"name" : "Français",
|
|
|
|
"value" : "fr"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "English",
|
|
|
|
"value" : "en"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Español",
|
|
|
|
"value" : "es"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Deutsch",
|
|
|
|
"value" : "de"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Čeština",
|
|
|
|
"value" : "cs"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Polski",
|
|
|
|
"value" : "pl"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Türkçe",
|
|
|
|
"value" : "tr"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
]';
|
|
|
|
}
|
|
|
|
|
2014-03-26 16:22:31 +01:00
|
|
|
|
|
|
|
public function collectData(array $param){
|
|
|
|
if (!empty($param['lang'])) {
|
|
|
|
$this->lang = $param['lang'];
|
|
|
|
}
|
|
|
|
if(empty($param['category'])) {
|
|
|
|
$this->uri = WORLD_OF_TANKS.$this->lang.NEWS;
|
|
|
|
} else {
|
2015-09-12 20:00:26 +02:00
|
|
|
$this->uri = WORLD_OF_TANKS.$this->lang.NEWS.'pc-browser/'.$param['category']."/";
|
2014-03-26 16:22:31 +01:00
|
|
|
}
|
2016-07-08 19:06:35 +02:00
|
|
|
$html = $this->getSimpleHTMLDOM($this->getURI()) or $this->returnServerError('Could not request '.$this->getURI());
|
2014-03-26 16:22:31 +01:00
|
|
|
$this->message("loaded HTML from ".$this->getURI());
|
2016-07-08 19:06:35 +02:00
|
|
|
// customize name
|
2014-03-26 16:22:31 +01:00
|
|
|
$this->name = $html->find('title', 0)->innertext;
|
|
|
|
foreach($html->find('.b-imgblock_ico') as $infoLink) {
|
|
|
|
$this->parseLine($infoLink);
|
|
|
|
}
|
|
|
|
}
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2016-08-06 16:00:56 +02:00
|
|
|
private function parseLine($infoLink) {
|
2014-03-26 16:22:31 +01:00
|
|
|
$item = new Item();
|
|
|
|
$item->uri = WORLD_OF_TANKS.$infoLink->href;
|
|
|
|
// now load that uri from cache
|
|
|
|
// $this->message("loading page ".$item->uri);
|
|
|
|
$articlePage = str_get_html($this->get_cached($item->uri));
|
|
|
|
$content = $articlePage->find('.l-content', 0);
|
2015-11-27 15:20:33 +01:00
|
|
|
HTMLSanitizer::defaultImageSrcTo($content, WORLD_OF_TANKS);
|
2014-03-26 16:22:31 +01:00
|
|
|
$item->title = $content->find('h1', 0)->innertext;
|
|
|
|
$item->content = $content->find('.b-content', 0)->innertext;
|
|
|
|
$item->timestamp = $content->find('.b-statistic_time', 0)->getAttribute("data-timestamp");
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|