+ #
+ # check if XML file exists
+ #
+ unless (-e $mainfile) {
+ print ${$template->scrap(
+ $assign->{'error'},
+ {
+ $assign->{'errorText'} => "Es existieren keine Nachrichten für diesen Monat."
+ }
+ )};
+ return;
+ }
+
+ #
+ # try locking and read/parse threads
+ #
+ my ($threads, $locked);
+ unless ($locked = lock_file($mainfile) and $threads = get_all_threads($mainfile, KILL_DELETED)) {
+ print ${$template->scrap(
+ $assign->{'error'},
+ {
+ $assign->{'errorText'} => "Fehler beim Locking."
+ }
+ )};
+ return;
+ }
+ unlock_file($mainfile);
+
+ my $tmplparam = {
+ $assign->{'year'} => $param->{'year'},
+ $assign->{'month'} => $param->{'month'},
+ $assign->{'monthName'} => month($param->{'month'})
+ };
+
+ #
+ # monthDocStart
+ #
+ print ${$template->scrap(
+ $assign->{'monthDocStart'},
+ $tmplparam
+ )};
+
+ #
+ # thread overview
+ #
+ for (sort keys %$threads) {
+ print ${$template->scrap(
+ $assign->{'monthThreadEntry'},
+ {
+ $assign->{'threadID'} => $_,
+ $assign->{'threadCategory'} => $threads->{$_}->[0]->{'cat'},
+ $assign->{'threadTitle'} => $threads->{$_}->[0]->{'subject'},
+ $assign->{'threadTime'} => short_hr_time($threads->{$_}->[0]->{'time'}),
+ $assign->{'threadDate'} => very_short_hr_time($threads->{$_}->[0]->{'time'}),
+ $assign->{'year'} => $param->{'year'},
+ $assign->{'month'} => $param->{'month'}
+ }
+ )};
+ }
+
+ #
+ # monthDocEnd
+ #
+ print ${$template->scrap(
+ $assign->{'monthDocEnd'},
+ $tmplparam
+ )};
+