428f819277870477d9339a5af3f12cb73f31ea0a
[bdrem.git] / src / bdrem / Renderer / Html.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  * HTML page renderer. Renders a full HTML page.
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_Html extends Renderer
28 {
29     /**
30      * HTTP content type
31      * @var string
32      */
33     protected $httpContentType = 'application/xhtml+xml; charset=utf-8';
34
35     /**
36      * Send out HTTP headers when nothing shall be outputted.
37      *
38      * @return void
39      */
40     public function handleStopOnEmpty()
41     {
42         header('HTTP/1.0 204 No Content');
43     }
44
45     /**
46      * Generate a HTML page with the given events.
47      *
48      * @param array $arEvents Events to display on the HTML page
49      *
50      * @return string HTML code
51      *
52      * @see Renderer_HtmlTable
53      */
54     public function render($arEvents)
55     {
56         $tr = new Renderer_HtmlTable();
57         $table = $tr->render($arEvents);
58         $s = <<<HTM
59 <?xml version="1.0" encoding="utf-8"?>
60 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
61  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
62 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
63  <head>
64   <title>bdrem</title>
65   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
66   <style type="text/css">
67 table {
68     border: 1px solid black;
69     border-collapse: collapse;
70     margin-left: auto;
71     margin-right: auto;
72 }
73 td, th {
74     border: 1px solid grey;
75     border-left: 0px;
76     border-right: 0px;
77     padding: 0.1ex 1ex;
78 }
79
80 tr.prev td {
81     background-color: #C4DDF4;
82 }
83 tr.today td {
84     background-color: #FEDCBA;
85 }
86 tr.next td {
87     background-color: #DEFABC;
88 }
89 tr:hover td {
90     background-color: white;
91 }
92
93 .r {
94     text-align: right;
95 }
96
97 tr td.icon {
98     background-color: white;
99 }
100 tr.prev td.icon {
101     color: #00A;
102 }
103 tr.today td.icon {
104     color: black;
105     background-color: #FEDCBA;
106 }
107 tr.next td.icon {
108     color: #080;
109 }
110
111 tr.d-3 td.icon:before {
112     content: "\342\227\224"
113 }
114 tr.d-2 td.icon:before {
115     content: "\342\227\221"
116 }
117 tr.d-1 td.icon:before {
118     content: "\342\227\225"
119 }
120 tr.d0 td.icon:before {
121     content: "\342\230\205"
122 }
123 tr.d1 td.icon:before {
124     content: "\342\227\225"
125 }
126 tr.d2 td.icon:before {
127     content: "\342\227\221"
128 }
129 tr.d3 td.icon:before {
130     content: "\342\227\224"
131 }
132   </style>
133  </head>
134  <body>
135 $table
136  </body>
137 </html>
138 HTM;
139         return $s;
140     }
141 }
142 ?>