41 lines
953 B
PHP
41 lines
953 B
PHP
<?php
|
|
namespace Source;
|
|
|
|
use \PHPHtmlParser\Dom;
|
|
use \Game;
|
|
|
|
abstract class Source {
|
|
public $title;
|
|
protected $dom;
|
|
protected $period;
|
|
protected $markdown;
|
|
protected $output;
|
|
public function __construct() {
|
|
$this->dom = new Dom;
|
|
$this->period = strtotime("1 week ago");
|
|
$this->markdown = new \cebe\markdown\Markdown();
|
|
$this->output = '';
|
|
}
|
|
/**
|
|
* Function to start the section.
|
|
* @param whether to return or print the text
|
|
*/
|
|
protected function startSection($return = false) {
|
|
$text = "#### ".$this->title."\n";
|
|
if ($return) {
|
|
return $text;
|
|
}
|
|
$this->output .= $text;
|
|
}
|
|
protected function endSection() {}
|
|
abstract protected function parse();
|
|
public function print() {
|
|
$this->startSection();
|
|
$this->parse();
|
|
$this->endSection();
|
|
if ($this->output === $this->startSection(true)) // nothing to print
|
|
return;
|
|
echo $this->markdown->parse($this->output);
|
|
}
|
|
}
|