2017-01-23 09:00:42 +02:00
|
|
|
<?php
|
2018-05-13 10:02:22 +03:00
|
|
|
/*
|
|
|
|
A set of utilities for tracking text-based game releases
|
|
|
|
Copyright (C) 2017-2018 Alexander Yakovlev
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2018-04-01 20:14:48 +03:00
|
|
|
use \Pandoc\Pandoc;
|
|
|
|
|
2017-01-23 09:00:42 +02:00
|
|
|
class Game {
|
|
|
|
public $url;
|
|
|
|
public $title;
|
|
|
|
public $author;
|
2019-04-18 16:28:59 +03:00
|
|
|
/**
|
|
|
|
* Полное или единственное описание.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2017-01-23 09:00:42 +02:00
|
|
|
public $description;
|
2019-04-18 16:28:59 +03:00
|
|
|
/**
|
|
|
|
* Короткое описание.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $short_description;
|
2018-03-24 21:01:30 +02:00
|
|
|
/**
|
|
|
|
* Дата выхода игры.
|
|
|
|
*
|
|
|
|
* @var DateTime
|
|
|
|
*/
|
2017-01-23 09:00:42 +02:00
|
|
|
public $date;
|
2018-12-10 14:40:43 +02:00
|
|
|
/**
|
|
|
|
* Path or URL to game cover.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2018-03-22 09:39:02 +02:00
|
|
|
public $image;
|
2018-12-10 14:40:43 +02:00
|
|
|
/**
|
|
|
|
* Binary image data, game cover.
|
|
|
|
* Most likely product of `file_get_contents`
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $image_data;
|
|
|
|
/**
|
|
|
|
* Cover data extension (jpg, png)
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $image_extension = 'jpg';
|
2018-03-23 20:00:43 +02:00
|
|
|
public $platform;
|
|
|
|
public $url_online;
|
|
|
|
public $url_download;
|
|
|
|
public $url_discussion;
|
|
|
|
public $url_download_description;
|
2018-04-11 16:54:37 +03:00
|
|
|
public $url_online_description;
|
2018-03-28 17:43:01 +03:00
|
|
|
public $language;
|
2018-12-10 14:40:43 +02:00
|
|
|
/**
|
|
|
|
* Темы на вики.
|
|
|
|
*
|
|
|
|
* @var string[]
|
|
|
|
*/
|
|
|
|
public $themes;
|
|
|
|
/**
|
|
|
|
* Категории на вики.
|
|
|
|
*
|
|
|
|
* @var string[]
|
|
|
|
*/
|
2018-03-28 17:43:01 +03:00
|
|
|
public $categories;
|
2017-01-23 09:00:42 +02:00
|
|
|
public function print() {
|
2018-04-01 20:14:48 +03:00
|
|
|
$converter = new Pandoc();
|
2017-02-21 07:27:41 +02:00
|
|
|
if (STYLE === 'RUS') {
|
2017-07-13 10:49:49 +03:00
|
|
|
if (FORMAT === 'MARKDOWN') {
|
|
|
|
$output = "* [«".trim($this->title)."»](".trim($this->url).")";
|
|
|
|
if ($this->author) {
|
|
|
|
$output .= " — *".trim($this->author)."*";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (FORMAT === 'HTML') {
|
2018-06-01 10:53:29 +03:00
|
|
|
$output = '<li>';
|
2017-07-13 10:49:49 +03:00
|
|
|
if ($this->author) {
|
2018-04-11 14:11:03 +03:00
|
|
|
if (is_array($this->author)) {
|
2018-06-01 10:53:29 +03:00
|
|
|
$output .= "<em>".implode(', ', array_map('trim', $this->author))."</em>";
|
2018-04-11 14:11:03 +03:00
|
|
|
} else {
|
2018-06-01 10:53:29 +03:00
|
|
|
$output .= "<em>".trim($this->author)."</em>";
|
2018-04-11 14:11:03 +03:00
|
|
|
}
|
2018-06-01 10:53:29 +03:00
|
|
|
$output .= ' — ';
|
2017-07-13 10:49:49 +03:00
|
|
|
}
|
2018-06-01 10:53:29 +03:00
|
|
|
$output .= "<a rel='nofollow' target='_blank' href='".trim($this->url)."'>«".trim($this->title)."»</a>";
|
2017-02-21 07:27:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (STYLE === 'ENG') {
|
|
|
|
$output = "* [“".trim($this->title)."”](".trim($this->url).")";
|
|
|
|
if ($this->author) {
|
|
|
|
$output .= " by *".trim($this->author)."*";
|
|
|
|
}
|
2017-04-27 10:27:25 +03:00
|
|
|
}
|
2019-04-26 12:30:31 +03:00
|
|
|
$description = $this->getDescription();
|
|
|
|
if ($description !== '') {
|
|
|
|
if (FORMAT === 'MARKDOWN') {
|
|
|
|
$output .= "\n\n > ".$converter->convert($this->getDescription(), 'html', 'markdown_github')."\n";
|
|
|
|
}
|
|
|
|
if (FORMAT === 'HTML') {
|
|
|
|
$output .= "\n<blockquote>".$this->getDescription()."</blockquote>\n";
|
|
|
|
}
|
|
|
|
if (FORMAT === 'MARKDOWN') {
|
|
|
|
$output .= "\n";
|
|
|
|
}
|
2017-01-23 09:00:42 +02:00
|
|
|
}
|
2017-07-13 10:49:49 +03:00
|
|
|
if (FORMAT === 'HTML') {
|
|
|
|
$output .= "</li>\n";
|
|
|
|
}
|
2017-01-23 09:00:42 +02:00
|
|
|
return $output;
|
|
|
|
}
|
2019-04-18 16:28:59 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Serialization for array_unique function.
|
|
|
|
*/
|
|
|
|
public function __toString() {
|
|
|
|
if (!empty($this->url)) {
|
|
|
|
return $this->url;
|
|
|
|
} else {
|
|
|
|
return $this->title;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription() {
|
|
|
|
if ($this->short_description) {
|
|
|
|
return $this->short_description;
|
|
|
|
}
|
|
|
|
return $this->description;
|
|
|
|
}
|
2017-01-23 09:00:42 +02:00
|
|
|
}
|