/[webpac]/trunk/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 /trunk/WebPac.pm

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

revision 636 by dpavlin, Tue Jan 18 17:07:14 2005 UTC revision 659 by dpavlin, Tue Feb 15 21:48:16 2005 UTC
# Line 12  use Text::Unaccent; Line 12  use Text::Unaccent;
12  use Data::Pageset;  use Data::Pageset;
13    
14  use lib '..';  use lib '..';
15  use index_DBI_cache;  use index_DBI_filter;
16  use back2html;  use back2html;
17    
18    
# Line 148  sub make_pager($$$) { Line 148  sub make_pager($$$) {
148    
149    
150          foreach my $p (@{$pager->pages_in_set()}) {          foreach my $p (@{$pager->pages_in_set()}) {
151                  next if ($p < 0);                  next if ($p <= 0);
152                  if($p == $pager->current_page()) {                  if($p == $pager->current_page()) {
153                          $pager_jump .= "<b>$p</b> ";                          $pager_jump .= "<b>$p</b> ";
154                  } else {                  } else {
# Line 270  sub show_results_list { Line 270  sub show_results_list {
270    
271                  if ($q->param("e$i")) {                  if ($q->param("e$i")) {
272                          push @url_params,"e$i=".$q->url_param("e$i");                          push @url_params,"e$i=".$q->url_param("e$i");
273                          push @url_params_persist,"e$i=".$q->url_param("e$i");  #                       push @url_params_persist,"e$i=".$q->url_param("e$i");
274                  }                  }
275    
276                  my $wc="*";     # swish wildcard                  my $wc="*";     # swish wildcard
# Line 344  sub show_results_list { Line 344  sub show_results_list {
344                  $sort = 'headline';                  $sort = 'headline';
345                  push @persist_vars, "sort";                  push @persist_vars, "sort";
346          }          }
347            if ($q->param("sortby")) {
348                    $sort = $q->param("sortby");
349                    push @persist_vars, "sort";
350            }
351    
352          # construct swish query          # construct swish query
353          my $sw_q = join(" and ",@s_arr);          my $sw_q = join(" and ",@s_arr);
# Line 359  sub show_results_list { Line 363  sub show_results_list {
363                  $tmpl->param('full',0);                  $tmpl->param('full',0);
364          }          }
365    
366            my $swish_msg = ' ';
367    
368          # create new swish instance          # create new swish instance
369          my $swish = SWISH::API->new($INDEX);          my $swish = SWISH::API->new($INDEX);
370          $swish->AbortLastError if $swish->Error;          $swish_msg .= $swish->ErrorString." ".$swish->LastErrorMsg if $swish->Error;
371    
372          # execute query and get number of results from SWISH-E          # execute query and get number of results from SWISH-E
373          my $search = $swish->New_Search_Object;          my $search = $swish->New_Search_Object;
374    
375          $search->SetSort($sort);          $search->SetSort($sort);
376    print "sort: $sort\n";
377    
378          my $results = $search->Execute($sw_q);          my $results = $search->Execute($sw_q);
379          $swish->AbortLastError if $swish->Error;          $swish_msg .= $swish->ErrorString." ".$swish->LastErrorMsg if $swish->Error;
380    
381          my $hits = $results->Hits;          my $hits = $results->Hits;
382    
383          $tmpl->param('hits',$hits);          $tmpl->param('hits',$hits);
384          $tmpl->param('search',$sw_q);          my $search_msg = $sw_q;
385            $search_msg .= '<em>'.$swish_msg.'</em>' if ($swish_msg);
386            $tmpl->param('search', $search_msg);
387    
388          $tmpl->param('PAGER_offset',$q->param("PAGER_offset") || 0);          $tmpl->param('PAGER_offset',$q->param("PAGER_offset") || 0);
389          $tmpl->param('last_PAGER_offset',$q->param("last_PAGER_offset") || 0);          $tmpl->param('last_PAGER_offset',$q->param("last_PAGER_offset") || 0);
# Line 438  sub show_index { Line 447  sub show_index {
447          my $field = $q->param("f$i");          my $field = $q->param("f$i");
448          my $limit = $q->param("v$i");          my $limit = $q->param("v$i");
449    
450            my $filter = $q->param("filter");
451    
452          my $html;          my $html;
453    
454          my $index = new index_DBI(          my $index = new index_DBI(
# Line 447  sub show_index { Line 458  sub show_index {
458                  $cfg_global->val('global', 'dbi_passwd') || ''                  $cfg_global->val('global', 'dbi_passwd') || ''
459          );          );
460    
461          my $total = $index->count($field,$limit);          my $total = $index->count($field,$limit,$filter);
462    
463          if (! $total) {          if (! defined($total)) {
464                  my $tmpl = $self->load_tmpl(url_ex($q,'no_index.html'));                  my $tmpl = $self->load_tmpl(url_ex($q,'no_index.html'));
465                  $tmpl->param('field',$field);                  $tmpl->param('field',$field);
466                  $html = $tmpl->output;                  $html = $tmpl->output;
# Line 482  sub show_index { Line 493  sub show_index {
493          make_pager($q, $tmpl, $pager);          make_pager($q, $tmpl, $pager);
494          make_pager_vars($q, $tmpl, @persist_vars);          make_pager_vars($q, $tmpl, @persist_vars);
495    
496          my @pager_data_list = $index->fetch($field,$limit, $pager->first - 1, $pager->entries_on_this_page);          my @pager_data_list = $index->fetch($field,$limit, $pager->first - 1, $pager->entries_on_this_page, $filter);
497          $tmpl->param('PAGER_DATA_LIST', \@pager_data_list);          $tmpl->param('PAGER_DATA_LIST', \@pager_data_list);
498    
499          return in_template($q,$tmpl->output);          return in_template($q,$tmpl->output);

Legend:
Removed from v.636  
changed lines
  Added in v.659

  ViewVC Help
Powered by ViewVC 1.1.26