--- trunk/WebPac.pm 2003/11/17 21:18:37 158 +++ trunk/WebPac.pm 2003/11/29 19:11:23 190 @@ -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 @@ -105,11 +109,13 @@ push @persist_vars, "f$i"; push @persist_vars, "v$i"; + push @persist_vars, "e$i" if ($q->param("e$i")); push @url_params,"f$i=".$q->url_param("f$i"); foreach my $v ($q->url_param("v$i")) { push @url_params,"v$i=$v"; } + push @url_params,"e$i=".$q->url_param("e$i"); my $wc="*"; # swish wildcard $wc="" if ($i eq ""); # don't apply wildcard on field 0 @@ -117,6 +123,7 @@ # 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 @@ -127,26 +134,41 @@ $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); + # what about wildcards? + $wc = ''; + $wc = '*' if ($q->param("e$i") & 4); + $exact = '_exact'; + } + foreach (split(/\s+/,$search)) { if (m/^([+-])(\S+)/) { $s.= ($s) ? "and " : ""; $s.="not " if ($1 eq "-"); - $s.="$2$wc "; + $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.="$_$wc "; + $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);