14 |
use Text::Unaccent; |
use Text::Unaccent; |
15 |
use Date::Parse; |
use Date::Parse; |
16 |
use POSIX qw(strftime); |
use POSIX qw(strftime); |
17 |
|
use MIME::Base64; |
18 |
|
|
19 |
#use MWS_plucene; |
#use MWS_plucene; |
20 |
use MWS_swish; |
use MWS_swish; |
206 |
sub search { |
sub search { |
207 |
my $self = shift; |
my $self = shift; |
208 |
|
|
209 |
my $s = shift || carp "search called without argument!"; |
carp "search called without argument!" if (! @_); |
210 |
|
|
211 |
$self->reset_counters; |
$self->reset_counters; |
212 |
|
|
213 |
print STDERR "search_index($s)\n" if ($debug == 2); |
print STDERR "search(",join(" ",@_),")\n" if ($debug == 2); |
214 |
my @index_ids = $self->search_index($s); |
my @index_ids = $self->search_index(@_); |
215 |
|
|
216 |
$self->{'index_ids'} = \@index_ids; |
$self->{'index_ids'} = \@index_ids; |
217 |
|
|
232 |
|
|
233 |
my $tmp = shift || return; |
my $tmp = shift || return; |
234 |
|
|
235 |
sub decode($$) { |
sub decode($$$) { |
236 |
my ($cp,$qp) = @_; |
my ($cp,$enc,$qp) = @_; |
237 |
print STDERR "decode($cp,$qp) -> " if ($debug == 2); |
|
238 |
$qp =~ s/=([a-f0-9][a-f0-9])/chr(hex($1))/ieg; |
print STDERR "decode($cp,$qp) -> " if ($debug == 2); |
239 |
$qp =~ s/_/ /g; |
|
240 |
print STDERR "$qp -> " if ($debug == 2); |
if (uc($enc) eq "Q") { |
241 |
|
$qp =~ s/=([a-f0-9][a-f0-9])/chr(hex($1))/ieg; |
242 |
|
$qp =~ s/_/ /g; |
243 |
|
} elsif (uc($enc) eq "B") { |
244 |
|
$qp = decode_base64($qp); |
245 |
|
} else { |
246 |
|
croak "unsupported encoding '$enc' in decode_qp\n"; |
247 |
|
return $qp; |
248 |
|
} |
249 |
|
|
250 |
|
print STDERR "$qp -> " if ($debug == 2); |
251 |
|
|
252 |
my $iconv = Text::Iconv->new($cp,'ISO-8859-2'); |
my $iconv = Text::Iconv->new($cp,'ISO-8859-2'); |
253 |
return $iconv->convert($qp) || ''; |
return $iconv->convert($qp) || ''; |
254 |
} |
} |
255 |
|
|
256 |
$tmp =~ s/=\?([^\?]+)\?Q\?(.+?)\?=/decode($1,$2)/ge; |
$tmp =~ s/=\?([^\?]+)\?([QB])\?(.+?)\?=/decode($1,$2,$3)/ige; |
257 |
$tmp =~ s/^\s*["']+(.*?)["']+\s*$/$1/g; |
$tmp =~ s/^\s*["']+(.*?)["']+\s*$/$1/g; |
258 |
#print STDERR "$tmp\n" if ($debug == 2); |
#print STDERR "$tmp\n" if ($debug == 2); |
259 |
return $tmp; |
return $tmp; |
332 |
my $wrap = $self->{wrap_margin}; |
my $wrap = $self->{wrap_margin}; |
333 |
if ($wrap && $body && $body =~ m/^.{$wrap}..*$/m) { |
if ($wrap && $body && $body =~ m/^.{$wrap}..*$/m) { |
334 |
$body =~ s/[\r\n]/\n/gs; |
$body =~ s/[\r\n]/\n/gs; |
335 |
$body = autoformat($body, {right=>$wrap}); |
$body = autoformat($body, {right=>$wrap, all=>1}); |
336 |
$body .="\n[reformated using autoformat, margin at $wrap]" if ($debug == 2); |
$body .="\n[reformated using autoformat, margin at $wrap]" if ($debug == 2); |
337 |
} |
} |
338 |
|
|