blob: 892c50a74b5a5a6e095665393a282f93c3dcb0ae (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
<?php
/**
* Part of bdrem
*
* PHP version 5
*
* @category Tools
* @package Bdrem
* @author Christian Weiske <cweiske@cweiske.de>
* @copyright 2014 Christian Weiske
* @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
* @link http://cweiske.de/bdrem.htm
*/
namespace bdrem;
/**
* Renders events in a HTML table.
*
* @category Tools
* @package Bdrem
* @author Christian Weiske <cweiske@cweiske.de>
* @copyright 2014 Christian Weiske
* @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
* @version Release: @package_version@
* @link http://cweiske.de/bdrem.htm
*/
class Renderer_HtmlTable extends Renderer
{
/**
* HTTP content type
* @var string
*/
protected $httpContentType = 'text/html; charset=utf-8';
/**
* Render the events in a HTML table
*
* @param array $arEvents Event objects to render
*
* @return string HTML table
*/
public function render($arEvents)
{
$s = <<<HTM
<table>
<thead>
<tr>
<th colspan="2">Days</th>
<th>Age</th>
<th>Event</th>
<th>Name</th>
<th>Date</th>
<th>Day</th>
</tr>
</thead>
<tbody>
HTM;
foreach ($arEvents as $event) {
$class = 'd' . $event->days;
if ($event->days < 0) {
$class .= ' prev';
} else if ($event->days == 0) {
$class .= ' today';
} else {
$class .= ' next';
}
$s .= sprintf(
'<tr class="' . trim($class) . '">'
. '<td class="icon"></td>'
. '<td class="r">%d</td>'
. '<td class="r">%s</td>'
. '<td>%s</td>'
. '<td>%s</td>'
. '<td>%s</td>'
. '<td>%s</td>'
. "</tr>\n",
$event->days,
$event->age,
htmlspecialchars($event->title),
htmlspecialchars($event->type),
$this->getLocalDate($event->date),
strftime('%a', strtotime($event->localDate))
);
}
$s .= <<<HTM
</tbody>
</table>
HTM;
return $s;
}
}
?>
|