generally improved table
[infodrom.org/oldenburg.linux.de] / src / Termine / index.wml
1 #include <LUGO.style>
2 #include "stacheltermine.inc"
3 #include "years.inc"
4
5 <?
6 $datedb = "dates.txt";
7
8 $dates = array();
9 function readdb()
10 {
11   global $datedb;
12   global $dates;
13
14   if (($db = fopen($datedb,'r')) !== false) {
15     $lines = array();
16     while (!feof($db)) {
17       $line = fgets($db, 200);
18
19       if (!preg_match("/^([0-9]{4})-([0-9]{2})-([0-9]{2})\|/", $line))
20         continue;
21
22       $dates[] = $line;
23     }
24   }
25 }
26
27 function display_dates()
28 {
29   global $dates;
30
31   $layout_head = '<div style="padding-top: 10px;"></div>'
32                 .'<table class="dates" width="100%%" border="0" cellpadding="0" cellspacing="0">'
33                 .'<tr bgcolor="#aeaeae"><th align="left" colspan="2"><strong>&nbsp;%s</strong></th>'
34                 .'<td align="left">Ort</td>'
35                 .'<td align="center">Zeit</td>'
36                 .'</tr>';
37   $layout_row = '<tr bgcolor=#%s>'
38                .'<td align=left width=20%%>&nbsp;%d. (%s)</td>'
39                .'<td align=left width=60%%>%s</td>'
40                .'<td align=left width=15%%>%s</td>'
41                .'<td align=right width=5%%>%s&nbsp;</td>'
42                .'</tr>';
43   $layout_foot = '</table>';
44
45   $nowstring = date("Y-m-");
46   $today = mktime(0,0,0, date('m'), date('d'), date('Y'));
47
48   sort($dates);
49   $cmon = false;
50   $color = 'ffffff';
51   foreach ($dates as $line) {
52     if ($line < $nowstring)
53       continue;
54
55     if (preg_match("/([0-9]{4})-([0-9]{2})-([0-9]{2})\|([^\|]*)\|[^\|]*\|([^\|]*)\|([^\|]*)\|(.*)/", $line, $match)) {
56
57       $when = mktime(0,0,0, $match[2], $match[3], $match[1]);
58
59       if ($match[1] !== $thisyear || $match[2] !== $thismonth) {
60         if ($cmon)
61           echo $layout_foot;
62         $thisyear = $match[1];
63         $thismonth = $match[2];
64         printf($layout_head, strftime("%B %Y", $when));
65         $cmon = true;
66       }
67       if ($when == $today)
68         $color = 'ffff00';
69       printf($layout_row, $color, $match[3], strftime("%A", $when), $match[5], $match[6], $match[4]);
70       $color = $color == 'ffffff'?'d7d7d7':'ffffff';
71     }
72   }
73   if ($cmon)
74     echo $layout_foot;
75 }
76
77 setlocale(LC_TIME, "de_DE");
78 readdb();
79 ?>
80
81 <page name=Termine>
82
83 <h3>Veranstaltungen rund um GNU/Linux in der Region Weser-Ems</h3>
84
85 <p>Hier finden Sie Termine von Veranstaltungen, die sich mit Linux,
86 GNU/Linux und/oder Freier Software befassen und in der Region
87 Weser-Ems stattfinden.  Wenn keine Stadt angegeben ist, findet die
88 Veranstaltung in Oldenburg statt.</p>
89
90 <p>Sollte eine Veranstaltung fehlen, kontaktieren Sie bitte joey@infodrom.org.</p>
91
92 <? display_dates() ?>
93
94 <build_tables>
95 <more_years>
96
97 </page>
98
99 # Local variables:
100 # mode: text
101 # mode: auto-fill
102 # mode: iso-accents
103 # end: