2014-03-26 19:22:31 +04:00
|
|
|
<?php
|
2016-09-10 20:11:09 +03:00
|
|
|
class WorldOfTanksBridge extends BridgeAbstract {
|
2015-11-05 18:50:18 +03:00
|
|
|
|
2016-08-30 12:23:55 +03: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 18:50:18 +03:00
|
|
|
|
2016-08-30 12:23:55 +03:00
|
|
|
const PARAMETERS = array( array(
|
2016-08-27 22:03:26 +03:00
|
|
|
'category'=>array(
|
|
|
|
// TODO: should be a list
|
|
|
|
'name'=>'nom de la catégorie'
|
|
|
|
),
|
|
|
|
'lang'=>array(
|
2016-08-22 02:25:56 +03:00
|
|
|
'name'=>'Langue',
|
|
|
|
'type'=>'list',
|
|
|
|
'values'=>array(
|
2016-08-27 22:03:26 +03:00
|
|
|
'Français'=>'fr',
|
|
|
|
'English'=>'en',
|
|
|
|
'Español'=>'es',
|
|
|
|
'Deutsch'=>'de',
|
|
|
|
'Čeština'=>'cs',
|
|
|
|
'Polski'=>'pl',
|
|
|
|
'Türkçe'=>'tr'
|
2016-08-22 02:25:56 +03:00
|
|
|
)
|
2016-08-27 22:03:26 +03:00
|
|
|
)
|
|
|
|
));
|
2015-11-05 18:50:18 +03:00
|
|
|
|
2016-08-30 01:31:59 +03:00
|
|
|
private $title='';
|
|
|
|
|
2016-08-25 18:15:52 +03:00
|
|
|
function getURI(){
|
2016-08-30 01:11:25 +03:00
|
|
|
$lang = $this->getInput('lang');
|
2016-08-30 12:23:55 +03:00
|
|
|
$uri = self::URI.$lang.'/news/';
|
2016-08-28 02:25:33 +03:00
|
|
|
if(!empty($this->getInput('category'))) {
|
|
|
|
$uri .= 'pc-browser/'.$this->getInput('category')."/";
|
2014-03-26 19:22:31 +04:00
|
|
|
}
|
2016-08-25 18:15:52 +03:00
|
|
|
return $uri;
|
|
|
|
}
|
|
|
|
|
2016-08-30 01:31:59 +03:00
|
|
|
public function getName(){
|
2016-08-30 12:23:55 +03:00
|
|
|
return $this->title?:self::NAME;
|
2016-08-30 01:31:59 +03:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:15:52 +03:00
|
|
|
public function collectData(){
|
2016-09-26 00:22:33 +03:00
|
|
|
$html = getSimpleHTMLDOM($this->getURI())
|
|
|
|
or returnServerError('Could not request '.$this->getURI());
|
|
|
|
debugMessage("loaded HTML from ".$this->getURI());
|
2016-07-08 20:06:35 +03:00
|
|
|
// customize name
|
2016-08-30 01:31:59 +03:00
|
|
|
$this->title = $html->find('title', 0)->innertext;
|
2014-03-26 19:22:31 +04:00
|
|
|
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();
|
2016-08-30 12:23:55 +03:00
|
|
|
$item['uri'] = self::URI.$infoLink->href;
|
2014-03-26 19:22:31 +04:00
|
|
|
// now load that uri from cache
|
2016-09-26 00:22:33 +03:00
|
|
|
debugMessage("loading page ".$item['uri']);
|
|
|
|
$articlePage = getSimpleHTMLDOMCached($item['uri']);
|
2014-03-26 19:22:31 +04:00
|
|
|
$content = $articlePage->find('.l-content', 0);
|
2016-09-26 00:58:52 +03:00
|
|
|
defaultImageSrcTo($content, self::URI);
|
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;
|
|
|
|
}
|
|
|
|
}
|