50 lines
1.9 KiB
PHP
50 lines
1.9 KiB
PHP
<?php
|
|
namespace Source;
|
|
|
|
use \Game;
|
|
|
|
class Instead extends Source {
|
|
public $title = "INSTEAD репозиторий";
|
|
protected function insteadfeed($url) {
|
|
$text = $this->get_text($url);
|
|
$this->loadStr($text);
|
|
unset($text);
|
|
$this->dom->filter('.game')->each(function($gameBlock) {
|
|
$date = trim($gameBlock->filter('.b .date b')->text());
|
|
$date = \DateTime::createFromFormat('Y.m.d', $date);
|
|
$date = $date->format('U');
|
|
if ($date < $this->period) return;
|
|
$game = new Game;
|
|
$game->author = str_replace(trim($gameBlock->filter('span.author')->first()->text()), 'Автор: ', '');
|
|
$game->title = trim($gameBlock->filter('h2:first-child a:first-child')->first()->text());
|
|
$game->url = 'http://instead-games.ru/'.trim($gameBlock->filter('h2:first-child a:first-child')->first()->attr('href'));
|
|
$this->output .= $game->print();
|
|
});
|
|
}
|
|
protected function parse() {
|
|
$this->insteadfeed("http://instead-games.ru/");
|
|
if (FORMAT === 'HTML') {
|
|
$this->output .= "<h5>Песочница</h5>\n";
|
|
} elseif (FORMAT === 'MARKDOWN') {
|
|
$this->output .= "##### Песочница\n";
|
|
}
|
|
$this->insteadfeed("http://instead-games.ru/index.php?approved=0");
|
|
}
|
|
public function checkPage($url) {
|
|
return (strpos($url,'http://instead-games.ru/game.php') !== FALSE);
|
|
}
|
|
public function page($url) {
|
|
echo 'Распознана игра INSTEAD.'.PHP_EOL;
|
|
$text = $this->get_text($url);
|
|
$this->loadStr($text);
|
|
unset($text);
|
|
$game = new Game;
|
|
$game->url = $url;
|
|
preg_match('/\s([0-9]{4}\.[01][0-9]\.[0-3][0-9])\s/', $this->dom->filter('#panel')->text(), $matches);
|
|
$date = \DateTime::createFromFormat('Y.m.d', $matches[0]);
|
|
$date = $date->format('U');
|
|
$game->author = str_replace(trim($gameBlock->filter('span.author')->first()->text()), 'Автор: ', '');
|
|
$game->title = trim($gameBlock->filter('h2')->first()->text());
|
|
}
|
|
}
|