Archived
1
0
Fork 0
This repository has been archived on 2020-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
news-script/Source/Source.php

34 lines
812 B
PHP
Raw Normal View History

2017-01-23 09:00:42 +02:00
<?php
2017-01-23 09:15:26 +02:00
namespace Source;
use \PHPHtmlParser\Dom;
use \Game;
2017-01-23 09:00:42 +02:00
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 = '';
}
protected function startSection() {
$this->output .= "#### ".$this->title."\n";
return "#### ".$this->title."\n";
}
protected function endSection() {}
abstract protected function parse();
public function print() {
$this->startSection();
$this->parse();
$this->endSection();
if ($this->output === $this->startSection()) // nothing to print
return;
echo $this->markdown->parse($this->output);
}
}