Archived
1
0
Fork 0

Added config and HTML formatting

This commit is contained in:
Alexander Yakovlev 2017-07-13 14:49:49 +07:00
parent 21a645340d
commit 76885ca119
6 changed files with 44 additions and 9 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/config.ini
/vendor

View file

@ -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;
}
}

View file

@ -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
View file

@ -0,0 +1,2 @@
STYLE = "RUS"
FORMAT = "HTML"

View file

@ -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');

View file

@ -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');