--- trunk/WebPac.pm 2003/11/16 16:57:11 149 +++ trunk/WebPac.pm 2003/11/22 22:04:05 164 @@ -28,7 +28,11 @@ my $ON_PAGE =$cfg_global->val('webpac', 'on_page') || 10; my $MIN_WILDCARD =$cfg_global->val('webpac', 'min_wildcard') || 1; my $TEMPLATE =$cfg_global->val('webpac', 'template'); +my $UNAC_FILTER =$cfg_global->val('global', 'unac_filter'); +if ($UNAC_FILTER) { + require $UNAC_FILTER; +} Text::Iconv->raise_error(0); # Conversion errors raise exceptions @@ -95,7 +99,8 @@ my @persist_vars = ( 'rm' ); my @url_params = ( 'rm=results', 'show_full=1', 'last_PAGER_offset='.$q->param('PAGER_offset') || 0 ); - for(my $i = 1; $i <=30; $i++) { + # support parametars "f" and "v" for start + for(my $i = ""; $i <=30; $i++) { return show_index($self, $i) if ($q->param("f".$i."_index")); @@ -106,11 +111,17 @@ push @persist_vars, "v$i"; push @url_params,"f$i=".$q->url_param("f$i"); - push @url_params,"v$i=".$q->url_param("v$i"); + foreach my $v ($q->url_param("v$i")) { + push @url_params,"v$i=$v"; + } + + my $wc="*"; # swish wildcard + $wc="" if ($i eq ""); # don't apply wildcard on field 0 # re-write query from +/- to and/and not my @param_vals = $q->param("v$i"); my @swish_q; + my ($pre,$post,$exact) = ('','',''); while (my $search = shift @param_vals) { my $s; # remove accents @@ -121,26 +132,39 @@ $search =~ s/^\s+//; $search =~ s/\s+$//; + # filed e[nr] is exact match bitmask + # 1 = beginning, 2=end, 3=both + $pre = '"xxbxx ' if ($q->param("e$i") & 1); + $post = ' xxexx"' if ($q->param("e$i") & 2); + # add qotes on other side + if ($q->param("e$i")) { + $pre = '"' if (! $pre); + $post = '"' if (! $post); + $wc = ''; # don't use windcard in exact + $exact = '_exact'; + } + foreach (split(/\s+/,$search)) { if (m/^([+-])(\S+)/) { $s.= ($s) ? "and " : ""; $s.="not " if ($1 eq "-"); - $s.="$2* "; + $s.=$2.$wc." "; } elsif (m/^\s*(and|or|not)\s*$/i) { - $s.="$_ "; + $s.=$_." "; # don't add * to words with less than x chars } elsif (length($_) <= $MIN_WILDCARD) { - $s.="$_ "; + $s.=$_." "; } else { - $s.="$_* "; + $s.=$_.$wc." "; } } $s =~ s/\*+/*/g; + $s = $pre.$s.$post if ($q->param("e$i")); push @swish_q,$s; } # FIXME default operator for multi-value fields is or. There is # no way to change it, except here for now. Is there need? - push @s_arr, $q->param("f$i")."_swish=(".join(" or ",@swish_q).")"; + push @s_arr, $q->param("f$i")."_swish".$exact."=(".join(" or ",@swish_q).")"; } my $tmpl = $self->load_tmpl('results.html', global_vars => 1);