. */ namespace Oreolek; use \Pandoc\Pandoc; class Game { public $url; public $title; public $author; /** * Полное или единственное описание. * * @var string */ public $description; /** * Короткое описание. * * @var string */ public $short_description; /** * Дата выхода игры. * * @var DateTime */ public $date; /** * Path or URL to game cover. * * @var string */ public $image; /** * 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'; public $platform; public $url_online; public $url_download; public $url_discussion; public $url_download_description; public $url_online_description; public $language; /** * Темы на вики. * * @var string[] */ public $themes; /** * Категории на вики. * * @var string[] */ public $categories; public function print() { $converter = new Pandoc(); if (STYLE === 'RUS') { if (FORMAT === 'MARKDOWN') { $output = "* [«".trim($this->title)."»](".trim($this->url).")"; if ($this->author) { $output .= " — *".trim($this->author)."*"; } } if (FORMAT === 'HTML') { $output = '
  • '; if ($this->author) { if (is_array($this->author)) { $output .= "".implode(', ', array_map('trim', $this->author)).""; } else { $output .= "".trim($this->author).""; } $output .= ' — '; } $output .= "«".trim($this->title)."»"; } } if (STYLE === 'ENG') { $output = "* [“".trim($this->title)."”](".trim($this->url).")"; if ($this->author) { $output .= " by *".trim($this->author)."*"; } } $description = trim($this->getDescription()); if ($description !== '') { if (FORMAT === 'MARKDOWN') { $output .= "\n\n > ".$converter->convert($this->getDescription(), 'html', 'markdown_github')."\n"; } if (FORMAT === 'HTML') { $output .= "\n
    ".$description."
    \n"; } if (FORMAT === 'MARKDOWN') { $output .= "\n"; } } if (FORMAT === 'HTML') { $output .= "
  • \n"; } return $output; } /** * 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; } }