aboutsummaryrefslogtreecommitdiff
path: root/src/bdrem/Renderer.php
blob: 363d413de11ae6923a62a7ba50892096f24dae33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
namespace bdrem;

abstract class Renderer
{
    protected $httpContentType = null;

    public function renderAndOutput($arEvents)
    {
        if (PHP_SAPI != 'cli' && $this->httpContentType !== null) {
            header('Content-type: ' . $this->httpContentType);
        }
        echo $this->render($arEvents);
    }

    public function handleStopOnEmpty()
    {
    }

    abstract public function render($arEvents);

    protected function getLocalDate($dateStr)
    {
        if ($dateStr{0} != '?') {
            return strftime('%x', strtotime($dateStr));
        }

        $dateStr = str_replace('????', '1899', $dateStr);
        return str_replace(
            array('1899', '99'),
            array('????', '??'),
            strftime('%x', strtotime($dateStr))
        );
    }
}
?>