1
0

WorldOfTanks.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. *
  4. * @name World of Tanks
  5. * @description News about the tank slaughter game. Language can be fr, ?
  6. * @update 26/03/2014
  7. * @use1(lang="Searched language",category="Category id")
  8. */
  9. define('WORLD_OF_TANKS', 'http://worldoftanks.eu/');
  10. define('NEWS', '/news/');
  11. class WorldOfTanks extends HttpCachingBridgeAbstract{
  12. private $lang = "fr";
  13. private $uri = WORLD_OF_TANKS;
  14. private $name = 'World of tanks news';
  15. public function collectData(array $param){
  16. if (!empty($param['lang'])) {
  17. $this->lang = $param['lang'];
  18. }
  19. if(empty($param['category'])) {
  20. $this->uri = WORLD_OF_TANKS.$this->lang.NEWS;
  21. } else {
  22. $this->uri = WORLD_OF_TANKS.$this->lang.NEWS.$param['category']."/";
  23. }
  24. $html = file_get_html($this->getURI()) or $this->returnError('Could not request '.$this->getURI(), 404);
  25. $this->message("loaded HTML from ".$this->getURI());
  26. // customize name
  27. $this->name = $html->find('title', 0)->innertext;
  28. foreach($html->find('.b-imgblock_ico') as $infoLink) {
  29. $this->parseLine($infoLink);
  30. }
  31. }
  32. public function parseLine($infoLink) {
  33. $item = new Item();
  34. $item->uri = WORLD_OF_TANKS.$infoLink->href;
  35. // now load that uri from cache
  36. // $this->message("loading page ".$item->uri);
  37. $articlePage = str_get_html($this->get_cached($item->uri));
  38. $content = $articlePage->find('.l-content', 0);
  39. $this->defaultImageSrcTo($content, WORLD_OF_TANKS);
  40. $item->title = $content->find('h1', 0)->innertext;
  41. $item->content = $content->find('.b-content', 0)->innertext;
  42. // $item->name = $auteur->innertext;
  43. $item->timestamp = $content->find('.b-statistic_time', 0)->getAttribute("data-timestamp");
  44. $this->items[] = $item;
  45. }
  46. public function getName(){
  47. return $this->name;
  48. }
  49. public function getURI(){
  50. return $this->uri;
  51. }
  52. public function getCacheDuration(){
  53. return 3600; // 2h hours
  54. }
  55. public function getDescription(){
  56. return "Toutes les actualités les plus brulantes de ce simulateur de destruction d'acier.";
  57. }
  58. }