2014-03-26 16:22:31 +01:00
|
|
|
<?php
|
2016-09-10 19:11:09 +02:00
|
|
|
class WorldOfTanksBridge extends BridgeAbstract {
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2017-02-11 16:16:56 +01:00
|
|
|
const MAINTAINER = 'mitsukarenai';
|
|
|
|
const NAME = 'World of Tanks';
|
|
|
|
const URI = 'http://worldoftanks.eu/';
|
|
|
|
const DESCRIPTION = 'News about the tank slaughter game.';
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2017-02-11 16:16:56 +01:00
|
|
|
const PARAMETERS = array( array(
|
|
|
|
'category' => array(
|
|
|
|
// TODO: should be a list
|
|
|
|
'name' => 'nom de la catégorie'
|
|
|
|
),
|
|
|
|
'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 16:50:18 +01:00
|
|
|
|
2017-02-11 16:16:56 +01:00
|
|
|
private $title = '';
|
2016-08-30 00:31:59 +02:00
|
|
|
|
2017-02-11 16:16:56 +01:00
|
|
|
function getURI(){
|
|
|
|
$lang = $this->getInput('lang');
|
|
|
|
$uri = self::URI . $lang . '/news/';
|
|
|
|
if(!empty($this->getInput('category'))) {
|
|
|
|
$uri .= 'pc-browser/' . $this->getInput('category') . '/';
|
|
|
|
}
|
|
|
|
return $uri;
|
|
|
|
}
|
2016-08-25 17:15:52 +02:00
|
|
|
|
2017-02-11 16:16:56 +01:00
|
|
|
public function getName(){
|
2017-02-14 22:20:55 +01:00
|
|
|
return $this->title ?: parent::getName();
|
2017-02-11 16:16:56 +01:00
|
|
|
}
|
2016-08-30 00:31:59 +02:00
|
|
|
|
2017-02-11 16:16:56 +01:00
|
|
|
public function collectData(){
|
|
|
|
$html = getSimpleHTMLDOM($this->getURI())
|
|
|
|
or returnServerError('Could not request ' . $this->getURI());
|
|
|
|
debugMessage("loaded HTML from " . $this->getURI());
|
|
|
|
// customize name
|
|
|
|
$this->title = $html->find('title', 0)->innertext;
|
|
|
|
foreach($html->find('.b-imgblock_ico') as $infoLink){
|
|
|
|
$this->parseLine($infoLink);
|
|
|
|
}
|
|
|
|
}
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2017-02-11 16:16:56 +01:00
|
|
|
private function parseLine($infoLink){
|
|
|
|
$item = array();
|
|
|
|
$item['uri'] = self::URI . $infoLink->href;
|
|
|
|
// now load that uri from cache
|
|
|
|
debugMessage('loading page ' . $item['uri']);
|
|
|
|
$articlePage = getSimpleHTMLDOMCached($item['uri']);
|
|
|
|
$content = $articlePage->find('.l-content', 0);
|
|
|
|
defaultImageSrcTo($content, self::URI);
|
|
|
|
$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;
|
|
|
|
}
|
2014-03-26 16:22:31 +01:00
|
|
|
}
|