summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-02-10 09:45:50 +0000
committerfukachan <fukachan>2001-02-10 09:45:50 +0000
commitf863483d4596ff05e5e1c9caea187b6e6c9cbace (patch)
tree039c05a9f3fe5beb9d18537c8d100983679bd1c3
parentfd2ce1421fa17ceeef8ecdff0c4ed93186c1088a (diff)
downloadfml8-f863483d4596ff05e5e1c9caea187b6e6c9cbace.tar.gz
fml8-f863483d4596ff05e5e1c9caea187b6e6c9cbace.tar.bz2
fml8-f863483d4596ff05e5e1c9caea187b6e6c9cbace.zip
clean up to use FML::Header
-rw-r--r--fml/lib/FML/Ticket/Model/toymodel.pm82
1 files changed, 54 insertions, 28 deletions
diff --git a/fml/lib/FML/Ticket/Model/toymodel.pm b/fml/lib/FML/Ticket/Model/toymodel.pm
index 494428ed..7c6b6474 100644
--- a/fml/lib/FML/Ticket/Model/toymodel.pm
+++ b/fml/lib/FML/Ticket/Model/toymodel.pm
@@ -603,48 +603,74 @@ sub _print_article_summary
sub _article_summary
{
my ($self, $file) = @_;
- my $buf = '';
- my $line = 5;
- my $padding = ' > ';
+ my (@header) = ();
+ my $buf = '';
+ my $line = 5;
+ my $padding = ' > ';
use FileHandle;
my $fh = new FileHandle $file;
if (defined $fh) {
- use Jcode;
-
+ ARTICLE:
while (<$fh>) {
- if (1 ../^$/) {
- if (/^(Subject:.*)=\?ISO\S+B\?(\S+)=\?=/) {
- my ($x, $y) = ($1, $2);
- $y = decode_base64($y);
- $buf .= $padding;
- $buf .= $x. Jcode::convert(\$y, 'euc')."\n";
- $buf .= $padding."\n";
- }
- elsif (/^(Subject:.*)/) {
- $buf .= $padding. $_;
- $buf .= $padding."\n";
- }
- next;
- }
-
# nuke useless lines
- next if /^\s*$/;
- next if /^\>/;
- next if /^\-/;
+ next ARTICLE if /^\>/;
+ next ARTICLE if /^\-/;
- # pick up effetive the first $line lines
- if ($line--> 0) {
- $buf .= $padding. $_;
+ if (1 ../^$/) {
+ push(@header, $_);
}
else {
- last;
+ next ARTICLE if /^\s*$/;
+
+ # pick up effetive the first $line lines
+ if ($line--> 0) {
+ $buf .= $padding. $_;
+ }
+ else {
+ last ARTICLE;
+ }
}
}
+ close($fh);
}
- $buf;
+ use FML::Header;
+ my $h = new FML::Header \@header;
+ my $header_info = _header_summary({
+ header => $h,
+ padding => $padding,
+ });
+
+ return $header_info . $buf;
+}
+
+
+sub _header_summary
+{
+ my ($args) = @_;
+ my $from = $args->{ header }->get('from');
+ my $subject = $args->{ header }->get('subject');
+ my $padding = $args->{ padding };
+
+ use Jcode;
+
+ if ($subject =~ /=\?ISO\-2022\-JP\S+B\?(\S+)=\?=/) {
+ my $y = decode_base64($1);
+ $subject = Jcode::convert(\$y, 'euc')."\n";
+ }
+ if ($from =~ /=\?ISO\-2022\-JP\S+B\?(\S+)=\?=/) {
+ my $y = decode_base64($1);
+ $from = Jcode::convert(\$y, 'euc')."\n";
+ }
+
+ $from =~ s/\n/ /g;
+ $subject =~ s/\n/ /g;
+
+ return
+ $padding. " From: ". $from ."\n".
+ $padding. "Subject: ". $subject ."\n";
}