update readme
[bdrem.git] / src / bdrem / Renderer.php
1 <?php
2 namespace bdrem;
3
4 abstract class Renderer
5 {
6     protected $httpContentType = null;
7
8     public function renderAndOutput($arEvents)
9     {
10         if (PHP_SAPI != 'cli' && $this->httpContentType !== null) {
11             header('Content-type: ' . $this->httpContentType);
12         }
13         echo $this->render($arEvents);
14     }
15
16     public function handleStopOnEmpty()
17     {
18     }
19
20     abstract public function render($arEvents);
21
22     protected function getLocalDate($dateStr)
23     {
24         if ($dateStr{0} != '?') {
25             return strftime('%x', strtotime($dateStr));
26         }
27
28         $dateStr = str_replace('????', '1899', $dateStr);
29         return str_replace(
30             array('1899', '99'),
31             array('????', '??'),
32             strftime('%x', strtotime($dateStr))
33         );
34     }
35 }
36 ?>