2014-03-26 19:22:31 +04:00
|
|
|
<?php
|
|
|
|
define('WORLD_OF_TANKS', 'http://worldoftanks.eu/');
|
|
|
|
define('NEWS', '/news/');
|
2016-08-24 20:06:07 +03:00
|
|
|
class WorldOfTanksBridge extends HttpCachingBridgeAbstract{
|
2015-11-05 18:50:18 +03:00
|
|
|
|
2014-03-26 19:22:31 +04:00
|
|
|
private $lang = "fr";
|
2015-11-04 02:05:10 +03:00
|
|
|
public $uri = WORLD_OF_TANKS;
|
2015-11-05 18:50:18 +03: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.";
|
|
|
|
|
2016-08-22 02:25:56 +03:00
|
|
|
$this->parameters[] = array(
|
|
|
|
'category'=>array(
|
|
|
|
'name'=>'ID de la catégorie',
|
|
|
|
'type'=>'number'
|
|
|
|
),
|
|
|
|
'lang'=>array(
|
|
|
|
'name'=>'Langue',
|
|
|
|
'type'=>'list',
|
|
|
|
'values'=>array(
|
|
|
|
'Français'=>'fr',
|
|
|
|
'English'=>'en',
|
|
|
|
'Español'=>'es',
|
|
|
|
'Deutsch'=>'de',
|
|
|
|
'Čeština'=>'cs',
|
|
|
|
'Polski'=>'pl',
|
|
|
|
'Türkçe'=>'tr'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2015-11-05 18:50:18 +03:00
|
|
|
}
|
|
|
|
|
2014-03-26 19:22:31 +04:00
|
|
|
|
2016-08-25 02:24:53 +03:00
|
|
|
public function collectData(){
|
|
|
|
$param=$this->parameters[$this->queriedContext];
|
|
|
|
if (!empty($param['lang']['value'])) {
|
|
|
|
$this->lang = $param['lang']['value'];
|
2014-03-26 19:22:31 +04:00
|
|
|
}
|
2016-08-25 02:24:53 +03:00
|
|
|
if(empty($param['category']['value'])) {
|
2014-03-26 19:22:31 +04:00
|
|
|
$this->uri = WORLD_OF_TANKS.$this->lang.NEWS;
|
|
|
|
} else {
|
2016-08-25 02:24:53 +03:00
|
|
|
$this->uri = WORLD_OF_TANKS.$this->lang.NEWS.'pc-browser/'.$param['category']['value']."/";
|
2014-03-26 19:22:31 +04:00
|
|
|
}
|
2016-07-08 20:06:35 +03:00
|
|
|
$html = $this->getSimpleHTMLDOM($this->getURI()) or $this->returnServerError('Could not request '.$this->getURI());
|
2016-08-24 21:19:30 +03:00
|
|
|
$this->debugMessage("loaded HTML from ".$this->getURI());
|
2016-07-08 20:06:35 +03:00
|
|
|
// customize name
|
2014-03-26 19:22:31 +04:00
|
|
|
$this->name = $html->find('title', 0)->innertext;
|
|
|
|
foreach($html->find('.b-imgblock_ico') as $infoLink) {
|
|
|
|
$this->parseLine($infoLink);
|
|
|
|
}
|
|
|
|
}
|
2016-07-08 20:06:35 +03:00
|
|
|
|
2016-08-06 17:00:56 +03:00
|
|
|
private function parseLine($infoLink) {
|
2016-08-22 19:55:59 +03:00
|
|
|
$item = array();
|
|
|
|
$item['uri'] = WORLD_OF_TANKS.$infoLink->href;
|
2014-03-26 19:22:31 +04:00
|
|
|
// now load that uri from cache
|
2016-08-24 21:19:30 +03:00
|
|
|
$this->debugMessage("loading page ".$item['uri']);
|
2016-08-22 19:55:59 +03:00
|
|
|
$articlePage = str_get_html($this->get_cached($item['uri']));
|
2014-03-26 19:22:31 +04:00
|
|
|
$content = $articlePage->find('.l-content', 0);
|
2015-11-27 17:20:33 +03:00
|
|
|
HTMLSanitizer::defaultImageSrcTo($content, WORLD_OF_TANKS);
|
2016-08-22 19:55:59 +03: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");
|
2014-03-26 19:22:31 +04:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|