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

41 lines
953 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 = '';
}
/**
* 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;
2017-01-23 09:00:42 +02:00
}
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
2017-01-23 09:00:42 +02:00
return;
echo $this->markdown->parse($this->output);
}
}