--- trunk/WebPac.pm 2003/09/04 13:47:36 126 +++ trunk/WebPac.pm 2003/11/16 16:57:11 149 @@ -12,7 +12,7 @@ use Text::Unaccent; use lib '..'; -use index_DBI; +use index_DBI_cache; use back2html; @@ -27,6 +27,7 @@ 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 @@ -49,6 +50,19 @@ $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",); + 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; @@ -60,8 +74,8 @@ 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 { @@ -166,6 +180,9 @@ $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); } @@ -214,7 +231,7 @@ my $html = $pager->output; - return $html; + return in_template($html); } sub show_index { @@ -235,7 +252,7 @@ $cfg_global->val('global', 'dbi_passwd') || '' ); - my $total = $index->check($field); + my $total = $index->count($field,$limit); if (! $total) { my $tmpl = $self->load_tmpl('no_index.html'); $tmpl->param('field',$field); @@ -258,7 +275,7 @@ get_data_callback => sub { my ($offset, $rows) = @_; - my @result = $index->fetch($field,'item',$limit, $offset, $rows); + my @result = $index->fetch($field,$limit, $offset, $rows); return \@result; }, rows => $total, @@ -272,7 +289,7 @@ template => $tmpl, ); - return $pager->output; + return in_template($pager->output); } 1;