6 |
use HTML::Pager; |
use HTML::Pager; |
7 |
use HTML::FillInForm; |
use HTML::FillInForm; |
8 |
use SWISH; |
use SWISH; |
9 |
use Unicode::String qw(utf8 utf16); |
use Unicode::MapUTF8 qw(to_utf8 from_utf8 utf8_supported_charset); |
10 |
require Unicode::Map8; |
use DBI; |
11 |
|
|
12 |
# configuration options |
# configuration options |
13 |
# FIX: they really should go in configuration file! |
# FIX: they really should go in configuration file! |
14 |
my $TEMPLATE_PATH = '/data/webpac/template_html'; |
my $TEMPLATE_PATH = '/data/webpac/template_html'; |
15 |
my $CHARSET = 'ISO-8859-2'; |
my $CHARSET = 'ISO-8859-2'; |
16 |
my $SWISH = '/data/swish/swish-e'; |
my $SWISH = '/usr/local/bin/swish-e'; |
17 |
my $INDEX = '/data/webpac/index/isis.index'; |
my $INDEX = '/data/webpac/index/isis.index'; |
18 |
my $MAX_HITS = 500; |
my $MAX_HITS = 500; |
19 |
my $ON_PAGE = 10; |
my $ON_PAGE = 10; |
25 |
$self->run_modes( |
$self->run_modes( |
26 |
'search' => 'show_search_form', |
'search' => 'show_search_form', |
27 |
'results' => 'show_results_list', |
'results' => 'show_results_list', |
28 |
# 'user' => 'show_user_detail' |
# 'user' => 'show_user_detail', |
29 |
|
'index' => 'show_index', |
30 |
); |
); |
31 |
$self->start_mode('search'); |
$self->start_mode('search'); |
32 |
$self->mode_param('rm'); |
$self->mode_param('rm'); |
57 |
my @swish_results; # results from swish |
my @swish_results; # results from swish |
58 |
|
|
59 |
# load template for this page |
# load template for this page |
|
my $tmpl = $self->load_tmpl('results.html'); |
|
60 |
|
|
61 |
my @s_arr; # all queries are located here |
my @s_arr; # all queries are located here |
62 |
|
|
63 |
for(my $i = 1; $i <=10; $i++) { |
for(my $i = 1; $i <=10; $i++) { |
64 |
|
|
65 |
last if (! $q->param("f$i")); |
return show_index($self, $i) if ($q->param("f".$i."_index")); |
66 |
|
next if (! $q->param("f$i")); |
67 |
next if (! $q->param("v$i")); |
next if (! $q->param("v$i")); |
68 |
|
|
69 |
# re-write query from +/- to and/and not |
# re-write query from +/- to and/and not |
85 |
} |
} |
86 |
} |
} |
87 |
|
|
88 |
push @s_arr,$q->param("f$i")."=($s)"; |
push @s_arr,$q->param("f$i")."_swish=($s)"; |
89 |
} |
} |
90 |
|
|
91 |
my $l2_map = Unicode::Map8->new($CHARSET) || die; |
my $tmpl = $self->load_tmpl('results.html'); |
|
my $us = Unicode::String->new(); |
|
92 |
|
|
93 |
# call swish |
# call swish |
94 |
my $sh = SWISH->connect('Fork', |
my $sh = SWISH->connect('Fork', |
98 |
results => sub { |
results => sub { |
99 |
my ($sh,$hit) = @_; |
my ($sh,$hit) = @_; |
100 |
|
|
|
$us->utf8($hit->swishtitle); |
|
|
|
|
101 |
push @swish_results, { |
push @swish_results, { |
102 |
nr => ($#swish_results + 2), |
nr => ($#swish_results + 2), |
103 |
path => $hit->swishdocpath, |
path => $hit->swishdocpath, |
104 |
title => $l2_map->to8($us->utf16), |
title => to_utf8({ -string => $hit->swishtitle, -charset => $CHARSET }), |
105 |
rank => $hit->swishrank }; |
rank => $hit->swishrank }; |
106 |
|
|
107 |
# my @fields = $hit->field_names; |
# my @fields = $hit->field_names; |
159 |
return $html; |
return $html; |
160 |
} |
} |
161 |
|
|
162 |
|
sub show_index { |
163 |
|
my $self = shift; |
164 |
|
my $i = shift; # field number |
165 |
|
|
166 |
|
my $q = $self->query(); |
167 |
|
|
168 |
|
my $html; |
169 |
|
|
170 |
|
$html .= "show index of ".$q->param("f$i")." for ".$q->param("v$i"); |
171 |
|
|
172 |
|
|
173 |
|
return $html; |
174 |
|
} |
175 |
|
|
176 |
1; |
1; |