2014-03-26 19:22:31 +04:00
|
|
|
<?php
|
2018-04-22 13:58:07 +03:00
|
|
|
class WorldOfTanksBridge extends FeedExpander {
|
2015-11-05 18:50:18 +03:00
|
|
|
|
2018-04-22 13:58:07 +03:00
|
|
|
const MAINTAINER = 'Riduidel';
|
2017-02-11 18:16:56 +03:00
|
|
|
const NAME = 'World of Tanks';
|
2019-06-28 20:32:26 +03:00
|
|
|
const URI = 'https://worldoftanks.eu/';
|
2017-02-11 18:16:56 +03:00
|
|
|
const DESCRIPTION = 'News about the tank slaughter game.';
|
2015-11-05 18:50:18 +03:00
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
const PARAMETERS = array( array(
|
|
|
|
'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
|
|
|
|
2019-06-28 20:32:26 +03:00
|
|
|
const POSSIBLE_ARTICLES = array('article', 'rich-article');
|
|
|
|
|
2018-04-22 13:58:07 +03:00
|
|
|
public function collectData() {
|
|
|
|
$this->collectExpandableDatas(sprintf('https://worldoftanks.eu/%s/rss/news/', $this->getInput('lang')));
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|
2016-08-25 18:15:52 +03:00
|
|
|
|
2018-04-22 13:58:07 +03:00
|
|
|
protected function parseItem($newsItem){
|
|
|
|
$item = parent::parseItem($newsItem);
|
|
|
|
$item['content'] = $this->loadFullArticle($item['uri']);
|
|
|
|
return $item;
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|
2016-08-30 01:31:59 +03:00
|
|
|
|
2018-04-22 13:58:07 +03:00
|
|
|
/**
|
|
|
|
* Loads the full article and returns the contents
|
|
|
|
* @param $uri The article URI
|
|
|
|
* @return The article content
|
|
|
|
*/
|
|
|
|
private function loadFullArticle($uri){
|
|
|
|
$html = getSimpleHTMLDOMCached($uri);
|
|
|
|
|
2019-06-28 20:32:26 +03:00
|
|
|
foreach(self::POSSIBLE_ARTICLES as $article_class) {
|
|
|
|
$content = $html->find('article', 0);
|
2018-04-22 13:58:07 +03:00
|
|
|
|
2019-06-28 20:32:26 +03:00
|
|
|
if($content !== null) {
|
|
|
|
// Remove the scripts, please
|
|
|
|
foreach($content->find('script') as $script) {
|
|
|
|
$script->outertext = '';
|
|
|
|
}
|
|
|
|
return $content->innertext;
|
|
|
|
}
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|
2019-06-28 20:32:26 +03:00
|
|
|
return null;
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|
2014-03-26 19:22:31 +04:00
|
|
|
}
|