30 lines
780 B
PHP
30 lines
780 B
PHP
|
<?php
|
||
|
use PHPHtmlParser\Dom;
|
||
|
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);
|
||
|
}
|
||
|
}
|