From 4b9db5ac0c780a1e0b6efa79b862057c781c8674 Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Wed, 28 Mar 2018 21:43:01 +0700 Subject: [PATCH] =?UTF-8?q?=D0=AF=D0=B7=D1=8B=D0=BA=D0=B8=20=D0=B8=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=82=D0=B5=D0=B3=D0=BE=D1=80=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Game.php | 2 ++ Source/Steam.php | 7 +++++++ Wikipage.php | 9 +++++++++ 3 files changed, 18 insertions(+) diff --git a/Game.php b/Game.php index 1557759..148d8c2 100644 --- a/Game.php +++ b/Game.php @@ -17,6 +17,8 @@ class Game { public $url_download; public $url_discussion; public $url_download_description; + public $language; + public $categories; public function print() { $converter = new HtmlConverter(); if (STYLE === 'RUS') { diff --git a/Source/Steam.php b/Source/Steam.php index 204dda8..ad91c8e 100644 --- a/Source/Steam.php +++ b/Source/Steam.php @@ -62,6 +62,13 @@ class Steam extends Source { $game->author = array_map('trim', $game->author); } $game->image = $game_page->filter('img.game_header_image_full')->first()->attr('src'); + $game->categories = 'Коммерческая ИЛ'; + $languages = $game_page->filter('.game_language_options tr td:first-child'); + $game->language = []; + foreach ($languages as $language) { + $game->language[] = trim($language->nodeValue); + } + $game->language = implode(', ', $game->language); $date = $game_page->filter('div.date')->first()->text(); $game->date = \DateTime::createFromFormat('d M, Y', $date); if ($game->date === FALSE) { // если Steam отдал страницу на русском diff --git a/Wikipage.php b/Wikipage.php index f63de77..d50cde6 100644 --- a/Wikipage.php +++ b/Wikipage.php @@ -101,6 +101,7 @@ class Wikipage { } $this->txtadd('platform', ' |платформа='.$this->game->platform); $this->txtadd('image', ' |обложка='.$this->covername); + $this->txtadd('language', ' |язык='.$this->game->language); $this->content .= "\n}}\n"; @@ -117,6 +118,14 @@ class Wikipage { } $this->txtadd('url_discussion', '* ['.$this->game->url_discussion.' Обсуждение игры]'); $this->txtadd('url', '* ['.$this->game->url.' Страница игры]'); + if (is_array($this->game->categories)) { + $this->content .= PHP_EOL; + foreach ($this->game->categories as $category) { + $this->content .= '[[Категория:'.$category.']]'; + } + } else { + $this->content .= PHP_EOL.'[[Категория:'.$this->game->categories.']]'; + } } protected function txtadd($param, $text) {