Update phing build script to use composer installation only
[bdrem.git] / src / bdrem / Renderer / HtmlTable.php
1 <?php
2 /**
3  * Part of bdrem
4  *
5  * PHP version 5
6  *
7  * @category  Tools
8  * @package   Bdrem
9  * @author    Christian Weiske <cweiske@cweiske.de>
10  * @copyright 2014 Christian Weiske
11  * @license   http://www.gnu.org/licenses/agpl.html GNU AGPL v3
12  * @link      http://cweiske.de/bdrem.htm
13  */
14 namespace bdrem;
15
16 /**
17  * Renders events in a HTML table.
18  *
19  * @category  Tools
20  * @package   Bdrem
21  * @author    Christian Weiske <cweiske@cweiske.de>
22  * @copyright 2014 Christian Weiske
23  * @license   http://www.gnu.org/licenses/agpl.html GNU AGPL v3
24  * @version   Release: @package_version@
25  * @link      http://cweiske.de/bdrem.htm
26  */
27 class Renderer_HtmlTable extends Renderer
28 {
29     /**
30      * HTTP content type
31      * @var string
32      */
33     protected $httpContentType = 'text/html; charset=utf-8';
34
35     /**
36      * Render the events in a HTML table
37      *
38      * @param array $arEvents Event objects to render
39      *
40      * @return string HTML table
41      */
42     public function render($arEvents)
43     {
44         $s = <<<HTM
45 <table>
46  <thead>
47   <tr>
48    <th colspan="2">Days</th>
49    <th>Age</th>
50    <th>Event</th>
51    <th>Name</th>
52    <th>Date</th>
53    <th>Day</th>
54   </tr>
55  </thead>
56  <tbody>
57
58 HTM;
59         foreach ($arEvents as $event) {
60             $class = 'd' . $event->days;
61             if ($event->days < 0) {
62                 $class .= ' prev';
63             } else if ($event->days == 0) {
64                 $class .= ' today';
65             } else {
66                 $class .= ' next';
67             }
68             $s .= sprintf(
69                 '<tr class="h-event ' . trim($class) . '">'
70                 . '<td class="icon"></td>'
71                 . '<td class="r">%d</td>'
72                 . '<td class="r">%s</td>'
73                 . '<td class="p-name">%s</td>'
74                 . '<td class="p-summary p-category">%s</td>'
75                 . '<td class="dt-start">'
76                 . '<time class="value" datetime="%s">%s</time>'
77                 . '</td>'
78                 . '<td>%s</td>'
79                 . "</tr>\n",
80                 $event->days,
81                 $event->age,
82                 htmlspecialchars($event->title),
83                 htmlspecialchars($event->type),
84                 $event->date,
85                 $this->getLocalDate($event->date),
86                 strftime('%a', strtotime($event->localDate))
87             );
88         }
89         $s .= <<<HTM
90  </tbody>
91 </table>
92
93 HTM;
94         return $s;
95     }
96 }
97 ?>