/[webpac]/branches/hidra/WebPac.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /branches/hidra/WebPac.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 72 by dpavlin, Sat Jul 5 21:35:44 2003 UTC revision 73 by dpavlin, Sat Jul 5 22:31:46 2003 UTC
# Line 9  use SWISH; Line 9  use SWISH;
9  use Text::Iconv;  use Text::Iconv;
10  use DBI;  use DBI;
11  use Config::IniFiles;  use Config::IniFiles;
12    use Text::Unaccent;
13    
14  use lib '..';  use lib '..';
15  use index_DBI;  use index_DBI;
# Line 82  sub show_results_list { Line 83  sub show_results_list {
83                  next if (! $q->param("f$i"));                  next if (! $q->param("f$i"));
84    
85                  # re-write query from +/- to and/and not                  # re-write query from +/- to and/and not
86                  my $s;                  my @param_vals = $q->param("v$i");
87                  my $search = $q->param("v$i");                  my @swish_q;
88                  while ($search =~ s/\s*("[^"]+")\s*/ /) {                  while (my $search = shift @param_vals) {
89                          $s .= "$1 ";                          my $s;
90                  }                          # remove accents
91                  $search =~ s/^\s+//;                          $search = unac_string($CHARSET,$search);
92                  $search =~ s/\s+$//;                          while ($search =~ s/\s*("[^"]+")\s*/ /) {
93                                    $s .= "$1 ";
94                            }
95                            $search =~ s/^\s+//;
96                            $search =~ s/\s+$//;
97    
98                  foreach (split(/\s+/,$search)) {                          foreach (split(/\s+/,$search)) {
99                          if (m/^([+-])(\S+)/) {                                  if (m/^([+-])(\S+)/) {
100                                  $s.= ($s) ? "and " : "";                                          $s.= ($s) ? "and " : "";
101                                  $s.="not " if ($1 eq "-");                                          $s.="not " if ($1 eq "-");
102                                  $s.="$2* ";                                          $s.="$2* ";
103                          } elsif (m/(and|or|not)/i) {                                  } elsif (m/(and|or|not)/i) {
104                                  $s.="$_ ";                                          $s.="$_ ";
105                          } else {                                  } else {
106                                  $s.="$_* ";                                          $s.="$_* ";
107                                    }
108                          }                          }
109                            $s =~ s/\*+/*/g;
110                            push @swish_q,$s;
111                  }                  }
112                  $s =~ s/\*+/*/g;                  # FIXME default operator for multi-value fields is or. There is
113                    # no way to change it, except here for now. Is there need?
114                  push @s_arr,$q->param("f$i")."_swish=($s)";                  push @s_arr, $q->param("f$i")."_swish=(".join(" or ",@swish_q).")";
115          }          }
116    
117          my $tmpl = $self->load_tmpl('results.html');          my $tmpl = $self->load_tmpl('results.html');
# Line 129  sub show_results_list { Line 137  sub show_results_list {
137          );          );
138    
139          die $SWISH::errstr unless $sh;          die $SWISH::errstr unless $sh;
   
140          # construct swish query          # construct swish query
141          my $sw_q = join(" and ",@s_arr);          my $sw_q = join(" and ",@s_arr);
142          if (@path_arr) {          if (@path_arr) {
# Line 144  sub show_results_list { Line 151  sub show_results_list {
151          $tmpl->param('hits',$hits);          $tmpl->param('hits',$hits);
152          $tmpl->param('search',$sw_q);          $tmpl->param('search',$sw_q);
153    
154          $tmpl->param('PAGER_offset',$q->param("PAGER_offset") || 0);          $tmpl->param('PAGER_offset',$q->param("PAGER_offset") || 1);
155          $tmpl->param('last_PAGER_offset',$q->param("last_PAGER_offset") || 0);          $tmpl->param('last_PAGER_offset',$q->param("last_PAGER_offset") || 1);
156    
157          # create a Pager object          # create a Pager object
158          my $pager = HTML::Pager->new(          my $pager = HTML::Pager->new(

Legend:
Removed from v.72  
changed lines
  Added in v.73

  ViewVC Help
Powered by ViewVC 1.1.26