diff --git a/Source/Kvester.php b/Source/Kvester.php index d145245..c51ed14 100644 --- a/Source/Kvester.php +++ b/Source/Kvester.php @@ -27,4 +27,20 @@ class Kvester extends Source { $this->output .= $game->print(); }); } + public function checkPage($url) { + return (strpos($url,'http://kvester.ru/game/') !== FALSE); + } + public function page($url) { + $game = new Game; + $game->url = $url; + $game->platform = 'Квестер'; + $game->title = trim($this->dom->filter(".qt-in-1 h2")->first()->text()); + $game->author = trim($this->dom->filter('.quest-info .author a')->text()); + $game->date = \DateTime::createFromFormat( + 'd.m.y', + trim($this->dom->filter('.quest-info .date')->first()->text()) + ); + $game->description = trim($this->dom->filter('.quest-profile .description')->first()->text()); + return $game; + } } diff --git a/Wikipage.php b/Wikipage.php index 8ded6f8..1796a70 100644 --- a/Wikipage.php +++ b/Wikipage.php @@ -23,13 +23,20 @@ class Wikipage { $this->game = $game; if (!$config['DUMMY']) { - // Log in to a wiki - $api = new MediawikiApi( $config['WIKI'] ); - $api->login( new ApiUser( $config['WIKIUSER'], $config['WIKIPASSWORD'] ) ); - $services = new MediawikiFactory( $api ); - $this->api = $api; - $this->services = $services; - $this->fileUploader = $services->newFileUploader(); + try { + // Log in to a wiki + $api = new MediawikiApi( $config['WIKI'] ); + $api->login( new ApiUser( $config['WIKIUSER'], $config['WIKIPASSWORD'] ) ); + $services = new MediawikiFactory( $api ); + $this->api = $api; + $this->services = $services; + $this->fileUploader = $services->newFileUploader(); + } catch (\Exception $e) { + echo 'Ошибка соединения.'.PHP_EOL; + echo $e->getMessage(); + echo $e->getTraceAsString(); + $config['DUMMY'] = true; + } } } public function create() { @@ -147,6 +154,10 @@ class Wikipage { * @return boolean */ protected function exists($pagename) { + global $config; + if ($config['DUMMY']) { + return false; + } $page = $this->services->newPageGetter()->getFromTitle((string) $pagename); return !($page->getId() === 0); }