Rename calendar class
[infodrom.org/service.infodrom.org] / src / Infodrom / calendar / index.wml
1 #include <infodrom.style>
2
3 <future>
4 <page func="Infodrom Oldenburg" title="Termine">
5
6 <style type="text/css">
7 div#termine {
8     margin-bottom: 10px;
9 }
10 table#calendar tr.row:hover {
11     background: yellow;
12 }
13 table#calendar tr.newkw td {
14     border-top: 1px solid #999;
15 }
16 table#calendar tr.month {
17     background: #a7efff;
18 }
19 table#calendar tr.current {
20     background: orange;
21 }
22 </style>
23
24 <div id="termine">
25 <table id="calendar" width="100%" class="smallfont border" cellspacing="0" summary="">
26 <tr class="head">
27 <th width="5%">KW</th>
28 <th width="20%">Datum</th>
29 <th width="55%">Beschreibung</th>
30 <th width="20%">Location</th>
31 </tr>
32
33 <?php
34   setlocale('LC_TIME', 'de_DE');
35   $now = date('Y-m-d H:i:s');
36   $pivot = date('Y-m-d H:i:s', time()+(7*24*60*60));
37
38   $item = new Calendar();
39   $month = '';
40
41   if (empty($_GET['year'])) {
42     $from = time();
43     $to = false;
44   } else {
45     $from = mktime(0,0,0,1,1,intval($_GET['year']));
46     $to = mktime(0,0,0,1,1,intval($_GET['year'])+1) - 1;
47   }
48   $kw = '';
49   foreach ($item->getItems($from, $to) as $row) {
50     $start = new DateTime($row->dtstart);
51     $newmonth = $start->format('F Y');
52     if ($month != $newmonth) {
53       $month = $newmonth;
54       printf('<tr class="month" month="%s"><td colspan="4">%s</td></tr>',
55              $start->format('Y-m'), $month);
56       $kw = '';
57     }
58
59     $tooltip = '';
60     if (strlen($row->description))
61       $tooltip = sprintf(' title="%s"', htmlspecialchars($row->description));
62
63     $class = 'row';
64     if ($row->dtstart >= $now && $row->dtstart < $pivot)
65       $class .= ' current';
66     if (strlen($kw) && $kw != $row->kw)
67       $class .= ' newkw';
68       
69     printf('<tr id="%d" class="%s"><td>%s</td><td>%s</td><td%s>%s</td><td>%s</td></tr>',
70            $row->dav_id,
71            $class,
72            $kw != $row->kw ? $row->kw : '&nbsp;',
73            Calendar::formatTimespan($row->dtstart, $row->dtend),
74            utf8_decode($tooltip),
75            utf8_decode($row->summary),
76            utf8_decode($row->location));
77     $kw = $row->kw;
78   }
79
80 ?>
81
82 </table>
83 </div>
84
85 </page>
86
87 # Local variables:
88 # mode: text
89 # mode: auto-fill
90 # mode: iso-accents
91 # end: