my $MAX_HITS = $cfg_global->val('webpac', 'max_hits') || 0;
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');
Text::Iconv->raise_error(0); # Conversion errors raise exceptions
$self->header_props(-charset=>$CHARSET);
}
+sub in_template {
+ my $html = shift || "This page is left unintentionally blank";
+ return $html if (! defined($TEMPLATE));
+ if (open(T, $TEMPLATE)) {
+ my $template_html = join("\n",<T>);
+ close(T);
+ $template_html =~ s/##webpac##/$html/gsi;
+ return $template_html;
+ } else {
+ return "Can't read template '$TEMPLATE'";
+ }
+}
+
sub show_search_form {
my $self = shift;
my $fif = new HTML::FillInForm;
- return $fif->fill(scalarref => \$html, fobject => $q,
- target => 'search');
+ return in_template($fif->fill(scalarref => \$html, fobject => $q,
+ target => 'search'));
}
sub show_results_list {
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"));
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");
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.="$_ ";
# don't add * to words with less than x chars
} elsif (length($_) <= $MIN_WILDCARD) {
$s.="$_ ";
} else {
- $s.="$_* ";
+ $s.="$_$wc ";
}
}
$s =~ s/\*+/*/g;
$sw_q .= join("\" or swishdocpath=\"",@path_arr);
$sw_q .= "\")";
$tmpl->param('full',1); # show full records
+ } elsif ($q->param('show_full')) {
+ # just show full path, no path defined
+ $tmpl->param('full',1);
} else {
$tmpl->param('full',0);
}
my $html = $pager->output;
- return $html;
+ return in_template($html);
}
sub show_index {
template => $tmpl,
);
- return $pager->output;
+ return in_template($pager->output);
}
1;