From f91793544f0d5c7f978e5cf6214d9882d7c4db7c Mon Sep 17 00:00:00 2001 From: ndparker <> Date: Fri, 27 Jul 2001 15:28:09 +0000 Subject: [PATCH 1/1] improved the behavior of get_all_threads and create_forum_xml_string --- selfforum-cgi/shared/Posting/_lib.pm | 32 +++++++++++++++------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/selfforum-cgi/shared/Posting/_lib.pm b/selfforum-cgi/shared/Posting/_lib.pm index ca29f30..83439c5 100644 --- a/selfforum-cgi/shared/Posting/_lib.pm +++ b/selfforum-cgi/shared/Posting/_lib.pm @@ -18,7 +18,7 @@ use vars qw( use Encode::Plain; $Encode::Plain::utf8 = 1; -use Time::German ':overwrite_internal_localtime'; +use Time::German qw(localtime); use XML::DOM; ################################################################################ @@ -40,6 +40,8 @@ use constant SORT_DESCENT => 1; use constant KEEP_DELETED => 1; use constant KILL_DELETED => 0; +use constant FORUM_DTD => 'http://selfforum.sourceforge.net/dtd/forum.dtd'; + use base qw(Exporter); @EXPORT_OK = qw( get_message_header @@ -135,7 +137,7 @@ sub create_message ($$) { # create a XML::DOM::Document object of a thread containing one posting # # Params: hash reference -# (dtd, thread, msg, body, ip, name, email, home, +# (thread, msg, body, ip, name, email, home, # image, category, subject, time) # # Return: XML::DOM::Document object @@ -156,7 +158,7 @@ sub create_new_thread ($) { # set doctype # - my $dtd = $xml -> createDocumentType ('Forum' => $par -> {dtd}); + my $dtd = $xml -> createDocumentType ('Forum' => FORUM_DTD); $xml -> setDoctype ($dtd); # create root element 'Forum' @@ -469,13 +471,13 @@ sub get_all_threads ($$;$) { close(FILE) or return; if (wantarray) { - ($dtd) = $xml =~ //; + $dtd = FORUM_DTD; ($last_thread) = map {/(\d+)/} $xml =~ /]*>/; ($last_message) = map {/(\d+)/} $xml =~ /]*>/; } my $reg_msg = qr~(?: - |]*>\s* + |]*>\s*
[^<]*(?:<(?!Name>)[^<]*)* ([^<]+)[^<]*(?:<(?!Category>)[^<]*)* ([^<]*)\s* @@ -495,7 +497,7 @@ sub get_all_threads ($$;$) { push @stack,$cmno if (defined $cmno); push @msg, { mid => $1, - unid => $2, + unid => (defined $2) ? $2 : '', deleted => $3 || 0, archive => $4 || 0, name => $5, @@ -511,11 +513,11 @@ sub get_all_threads ($$;$) { if (defined $cmno) { push @{$msg[$cmno] -> {kids}} => $#msg; - push @{$msg[$cmno] -> {unids}} => $2; + push @{$msg[$cmno] -> {unids}} => (defined $2) ? $2 : '#'; } else { - push @unids => $2; + push @unids => (defined $2) ? $2 : ''; } $msg[$_] -> {answers}++ for (@stack); @@ -531,7 +533,7 @@ sub get_all_threads ($$;$) { { push @msg, { mid => $1, - unid => $2, + unid => (defined $2) ? $2 : '', deleted => $3 || 0, archive => $4 || 0, name => $5, @@ -547,12 +549,12 @@ sub get_all_threads ($$;$) { if (defined $cmno) { push @{$msg[$cmno] -> {kids}} => $#msg; - push @{$msg[$cmno] -> {unids}} => $2; + push @{$msg[$cmno] -> {unids}} => (defined $2) ? $2 : ''; $msg[$cmno] -> {answers}++; } else { - push @unids => $2; + push @unids => (defined $2) ? $2 : ''; } $msg[$_] -> {answers}++ for (@stack); @@ -592,9 +594,9 @@ sub create_forum_xml_string ($$) { my ($level, $thread, $msg); my $xml = - ''."\n" - . ' {dtd}.'">'."\n" - . ''; + ''."\n" + . ''."\n" + . ''; for $thread (sort {$b <=> $a} keys %$threads) { $xml .= ''; @@ -606,7 +608,7 @@ sub create_forum_xml_string ($$) { $level = $msg -> {level}; $xml .= ' {unid}) ?' unid="'.$msg -> {unid}.'"':'') . (($msg -> {deleted})?' invisible="1"':'') . (($msg -> {archive})?' archive="1"':'') . '>' -- 2.34.1