WorldOfTanksBridge.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. class WorldOfTanksBridge extends FeedExpander {
  3. const MAINTAINER = 'Riduidel';
  4. const NAME = 'World of Tanks';
  5. const URI = 'http://worldoftanks.eu/';
  6. const DESCRIPTION = 'News about the tank slaughter game.';
  7. const PARAMETERS = array( array(
  8. 'lang' => array(
  9. 'name' => 'Langue',
  10. 'type' => 'list',
  11. 'values' => array(
  12. 'Français' => 'fr',
  13. 'English' => 'en',
  14. 'Español' => 'es',
  15. 'Deutsch' => 'de',
  16. 'Čeština' => 'cs',
  17. 'Polski' => 'pl',
  18. 'Türkçe' => 'tr'
  19. )
  20. )
  21. ));
  22. public function collectData() {
  23. $this->collectExpandableDatas(sprintf('https://worldoftanks.eu/%s/rss/news/', $this->getInput('lang')));
  24. }
  25. protected function parseItem($newsItem){
  26. $item = parent::parseItem($newsItem);
  27. $item['content'] = $this->loadFullArticle($item['uri']);
  28. return $item;
  29. }
  30. /**
  31. * Loads the full article and returns the contents
  32. * @param $uri The article URI
  33. * @return The article content
  34. */
  35. private function loadFullArticle($uri){
  36. $html = getSimpleHTMLDOMCached($uri);
  37. $content = $html->find('article', 0);
  38. // Remove the scripts, please
  39. foreach($content->find('script') as $script) {
  40. $script->outertext = '';
  41. }
  42. return $content->innertext;
  43. }
  44. }