# File: shared/Posting/_lib.pm #
# #
# Authors: André Malo <nd@o3media.de>, 2001-03-03 #
-# Frank Schoenmann <fs@tower.de>, 2001-03-13 #
+# Frank Schoenmann <fs@tower.de>, 2001-06-02 #
# #
# Description: Message access interface, time format routines #
# #
my $header = $xml -> createElement ('Header');
my $author = $xml -> createElement ('Author');
+ $header -> appendChild ($author);
my @may = (
['name' => 'Name' => $author],
my $date = $xml -> createElement ('Date');
$date -> setAttribute ('longSec'=> $par -> {time});
- $header -> appendChild ($author);
$header -> appendChild ($date);
$message -> appendChild ($header);
my $xml = eval {
local $SIG{__DIE__}; # CGI::Carp works unreliable ;-(
- new XML::DOM::Parser (KeepCDATA => 1) -> parsefile ($file);
+ new XML::DOM::Parser(KeepCDATA => 1)->parsefile ($file);
};
return if ($@);
# Params: $smsg Reference of array of references of hashs
# Return: -none-
#
-sub delete_messages ($)
-{
+sub delete_messages ($) {
my $smsg = shift;
-
my ($z, $oldlevel, @path) = (0,0,0);
- for (@$smsg)
- {
- if ($_ -> {'deleted'})
- {
- my $n = $_ -> {'answers'} + 1;
- $smsg -> [$_] -> {'answers'} -= $n for (@path);
- splice @$smsg,$z,$n;
+ while ($z <= $#{$smsg}) {
+
+ if ($smsg -> [$z] -> {level} > $oldlevel) {
+ push @path => $z;
+ $oldlevel = $smsg -> [$z] -> {level};
+ }
+ elsif ($smsg -> [$z] -> {level} < $oldlevel) {
+ splice @path, $smsg -> [$z] -> {level};
+ push @path => $z;
+ $oldlevel = $smsg -> [$z] -> {'level'};
+ }
+ else {
+ $path[-1] = $z;
}
- else
- {
- if ($_ -> {'level'} > $oldlevel)
- {
- push @path,$z;
- $oldlevel = $_ -> {'level'};
- }
- elsif ($_ -> {'level'} < $oldlevel)
- {
- splice @path,$_ -> {'level'} - $oldlevel;
- $oldlevel = $_ -> {'level'};
- }
- else
- {
- $path[-1] = $z;
- }
+ if ($smsg -> [$z] -> {deleted}) {
+ my $n = $smsg -> [$z] -> {answers} + 1;
+ $smsg -> [$_] -> {answers} -= $n for (@path);
+ splice @$smsg, $z, $n;
+ }
+ else {
$z++;
}
}
my ($last_thread, $last_message, $dtd, @unids, %threads);
local (*FILE, $/);
- open FILE, $file or return undef;
+ open FILE,"< $file" or return;
my $xml = join '', <FILE>;
- close(FILE) or return undef;
+ close(FILE) or return;
if (wantarray)
{
if (defined($10))
{
push @stack,$cmno if (defined $cmno);
- push @msg, {mid => $1,
- unid => $2,
- deleted => $3,
- archive => $4,
- name => $5,
- cat => $6,
- subject => $7,
- time => $8,
- level => $level++,
- unids => [],
- kids => [],
- answers => 0};
+ push @msg, {
+ mid => $1,
+ unid => $2,
+ deleted => $3 || 0,
+ archive => $4 || 0,
+ name => $5,
+ cat => $6,
+ subject => $7,
+ time => $8,
+ level => $level++,
+ unids => [],
+ kids => [],
+ answers => 0
+ };
if (defined $cmno)
{
}
elsif (defined ($9))
{
- push @msg, {mid => $1,
- unid => $2,
- deleted => $3,
- archive => $4,
- name => $5,
- cat => $6,
- subject => $7,
- time => $8,
- level => $level,
- unids => [],
- kids => [],
- answers => 0};
+ push @msg, {
+ mid => $1,
+ unid => $2,
+ deleted => $3 || 0,
+ archive => $4 || 0,
+ name => $5,
+ cat => $6,
+ subject => $7,
+ time => $8,
+ level => $level,
+ unids => [],
+ kids => [],
+ answers => 0
+ };
if (defined $cmno)
{
###########################
sub hr_time ($) {
- my @month = (qw(Januar Februar), "M\303\244rz", qw(April Mail Juni Juli August September Oktober November Dezember));
+ my @month = (qw(Januar Februar), "M\303\244rz", qw(April Mai Juni Juli August September Oktober November Dezember));
# ^^^^^^^^ - UTF8 #
my (undef, $min, $hour, $day, $mon, $year) = localtime ($_[0]);
}
sub long_hr_time ($) {
- my @month = (qw(Januar Februar), "M\303\244rz", qw(April Mail Juni Juli August September Oktober November Dezember));
+ my @month = (qw(Januar Februar), "M\303\244rz", qw(April Mai Juni Juli August September Oktober November Dezember));
# ^^^^^^^^ - UTF8 #
my @wday = qw(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag);
sprintf ('%s, %02d. %s %04d, %02d:%02d:%02d Uhr', $wday[$wday], $day, $month[$mon], $year+1900, $hour, $min, $sek);
}
+sub month($) {
+ my @month = (qw(Januar Februar), "M\303\244rz", qw(April Mai Juni Juli August September Oktober November Dezember));
+ # ^^^^^^^^ - UTF8 #
+
+ return $month[$_[0]];
+}
+
# ====================================================
# Modulinitialisierung
# ====================================================
# making require happy
-1;
\ No newline at end of file
+1;