Added config and HTML formatting
This commit is contained in:
parent
21a645340d
commit
76885ca119
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
/config.ini
|
||||
/vendor
|
27
Game.php
27
Game.php
|
@ -9,9 +9,17 @@ class Game {
|
|||
public function print() {
|
||||
$converter = new HtmlConverter();
|
||||
if (STYLE === 'RUS') {
|
||||
$output = "* [«".trim($this->title)."»](".trim($this->url).")";
|
||||
if ($this->author) {
|
||||
$output .= " — *".trim($this->author)."*";
|
||||
if (FORMAT === 'MARKDOWN') {
|
||||
$output = "* [«".trim($this->title)."»](".trim($this->url).")";
|
||||
if ($this->author) {
|
||||
$output .= " — *".trim($this->author)."*";
|
||||
}
|
||||
}
|
||||
if (FORMAT === 'HTML') {
|
||||
$output = "<li><a rel='nofollow' target='_blank' href='".trim($this->url)."'>«".trim($this->title)."»</a>";
|
||||
if ($this->author) {
|
||||
$output .= " — <em>".trim($this->author)."</em>";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (STYLE === 'ENG') {
|
||||
|
@ -21,10 +29,19 @@ class Game {
|
|||
}
|
||||
}
|
||||
if ($this->description) {
|
||||
$output .= "\n\n > ".$converter->convert($this->description)."\n";
|
||||
} else {
|
||||
if (FORMAT === 'MARKDOWN') {
|
||||
$output .= "\n\n > ".$converter->convert($this->description)."\n";
|
||||
}
|
||||
if (FORMAT === 'HTML') {
|
||||
$output .= "\n<blockquote>".$converter->convert($this->description)."</blockquote>\n";
|
||||
}
|
||||
}
|
||||
if (FORMAT === 'MARKDOWN') {
|
||||
$output .= "\n";
|
||||
}
|
||||
if (FORMAT === 'HTML') {
|
||||
$output .= "</li>\n";
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
|
14
Source.php
14
Source.php
|
@ -19,13 +19,23 @@ abstract class Source {
|
|||
* @param whether to return or print the text
|
||||
*/
|
||||
protected function startSection($return = false) {
|
||||
$text = "\n#### ".$this->title."\n";
|
||||
if (FORMAT === 'MARKDOWN') {
|
||||
$text = "\n#### ".$this->title."\n";
|
||||
}
|
||||
if (FORMAT === 'HTML') {
|
||||
$text = "\n<spoiler title='".$this->title."'><h4>".$this->title."</h4>\n<ul>";
|
||||
}
|
||||
if ($return) {
|
||||
return $text;
|
||||
}
|
||||
$this->output .= $text;
|
||||
}
|
||||
protected function endSection() {}
|
||||
protected function endSection() {
|
||||
if (FORMAT === 'HTML') {
|
||||
$text = "</ul></spoiler>\n";
|
||||
}
|
||||
$this->output .= $text;
|
||||
}
|
||||
abstract protected function parse();
|
||||
public function print() {
|
||||
$this->startSection();
|
||||
|
|
2
config.ini.example
Normal file
2
config.ini.example
Normal file
|
@ -0,0 +1,2 @@
|
|||
STYLE = "RUS"
|
||||
FORMAT = "HTML"
|
|
@ -2,7 +2,9 @@
|
|||
require "vendor/autoload.php";
|
||||
require "Game.php";
|
||||
require "Source.php";
|
||||
define("STYLE", "ENG");
|
||||
$config = parse_ini_file("./config.ini");
|
||||
define('STYLE',$config['STYLE']);
|
||||
define('FORMAT',$config['FORMAT']);
|
||||
$loader = new \Aura\Autoload\Loader;
|
||||
$loader->register();
|
||||
$loader->addPrefix('Source', 'Source_en');
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
require "vendor/autoload.php";
|
||||
require "Game.php";
|
||||
require "Source.php";
|
||||
define("STYLE", "RUS");
|
||||
$config = parse_ini_file("./config.ini");
|
||||
define('STYLE',$config['STYLE']);
|
||||
define('FORMAT',$config['FORMAT']);
|
||||
$loader = new \Aura\Autoload\Loader;
|
||||
$loader->register();
|
||||
$loader->addPrefix('Source', 'Source');
|
||||
|
|
Reference in a new issue