:
use Time::Local;
@month = ('dummy','Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember');
@day = ('Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag');
# Monat - Jahr
$layout_month = '
\
\
%s %d | \
Ort | \
Zeit | \
';
# bgcol Tag (Tag) - Text - Ort - Zeit
$layout_row = '\
\
%d. (%s) | \
%s | \
%s | \
%s | \
';
$layout_foot = '\
';
@layout_color = ('ffffff','eff0f1');
:>
<:
my @y;
my $max = (localtime(time))[5]+1900;
foreach my $year (2000..$max) {
next unless -f $year . '.wml';
push (@y, sprintf ("%s",
$year, $year >= 2008?"php":"html", $year))
if ($year ne "");
}
printf "Vergangene Termine in %s
\n", join (", ", @y);
:>
<:
$mon = 0;
$year = (split (/-/, (split (/\|/, (sort (@termine))[0]))[0]))[0];
$descr = "";
$day = 0;
$color = $layout_color[1];
foreach $termin (sort (@termine)) {
@termin = split (/\|/, $termin);
@date = split (/-/, $termin[0]);
if ($mon ne "$date[0]-$date[1]") {
if ($mon != 0) {
print $layout_foot;
$descr = "";
$day = 0;
$color = $layout_color[1];
print "
" if ($year != $date[0]);
$year = $date[0];
}
printf $layout_month, $month[$date[1]], $date[0];
$mon = "$date[0]-$date[1]";
}
if ($termin[2] ne $descr || $date[2] != $day+1) {
$color = $color eq $layout_color[0]?$layout_color[1]:$layout_color[0];
$descr = $termin[2];
}
$day = $date[2];
if ($termin[4]) {
$text = sprintf ("%s", $termin[4], $termin[2]);
} else {
$text = $termin[2];
}
$wday = (localtime(timelocal(0,0,0,$date[2],$date[1]-1, $date[0])))[6];
printf $layout_row, $color, $date[2], $day[$wday], $text, $termin[3], $termin[1];
}
print $layout_foot;
:>
function readdb($datedb)
{
$dates = array();
if (($db = fopen($datedb,'r')) !== false) {
$lines = array();
while (!feof($db)) {
$line = fgets($db, 200);
if (!preg_match("/^([0-9]{4})-([0-9]{2})-([0-9]{2})\|/", $line))
continue;
$dates[] = $line;
}
}
return $dates;
}
function display_dates($past=false)
{
global $dates;
$layout_head = ''
.''
.' %s | '
.'Ort | '
.'Zeit | '
.'
';
$layout_row = ''
.' %d. (%s) | '
.'%s | '
.'%s | '
.'%s | '
.'
';
$layout_foot = '
';
$nowstring = date("Y-m-d");
$today = mktime(0,0,0, date('m'), date('d'), date('Y'));
sort($dates);
$cmon = false;
foreach ($dates as $line) {
if (($past == false && $line < $nowstring) ||
($past == true && $line > $nowstring))
continue;
if (preg_match("/([0-9]{4})-([0-9]{2})-([0-9]{2})\|([^\|]*)\|[^\|]*\|([^\|]*)\|([^\|]*)\|(.*)/", $line, $match)) {
$when = mktime(0,0,0, $match[2], $match[3], $match[1]);
if ($match[1] !== $thisyear || $match[2] !== $thismonth) {
if ($cmon)
echo $layout_foot;
$thisyear = $match[1];
$thismonth = $match[2];
printf($layout_head, strftime("%B %Y", $when));
$cmon = true;
}
if (strlen($match[7]))
$title = '' . $match[5] . '';
else
$title = $match[5];
if ($when == $today)
$class = 'today';
else
$class = ($class == 'row0'?'row1':'row0');
printf($layout_row, $class, $match[3], strftime("%A", $when), $title, $match[6], $match[4]);
}
}
if ($cmon)
echo $layout_foot;
}
?>
# Local variables:
# mode: indented-text
# mode: auto-fill
# end: