/[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 13 by dpavlin, Sun Feb 16 22:41:37 2003 UTC revision 47 by dpavlin, Sun Mar 23 01:17:49 2003 UTC
# Line 6  use strict; Line 6  use strict;
6  use HTML::Pager;  use HTML::Pager;
7  use HTML::FillInForm;  use HTML::FillInForm;
8  use SWISH;  use SWISH;
9  use Unicode::MapUTF8 qw(to_utf8 from_utf8 utf8_supported_charset);  use Text::Iconv;
10  use DBI;  use DBI;
11    
12  use lib '..';  use lib '..';
# Line 22  my $INDEX = '/data/webpac/index/isis.ind Line 22  my $INDEX = '/data/webpac/index/isis.ind
22  my $MAX_HITS = 500;  my $MAX_HITS = 500;
23  my $ON_PAGE = 10;  my $ON_PAGE = 10;
24    
25    Text::Iconv->raise_error(0);     # Conversion errors raise exceptions
26    
27    my $from_utf8 = Text::Iconv->new('UTF8', $CHARSET);
28    
29  sub setup {  sub setup {
30          my $self = shift;          my $self = shift;
# Line 64  sub show_results_list { Line 67  sub show_results_list {
67    
68          my @s_arr;      # all queries are located here          my @s_arr;      # all queries are located here
69    
70            my @path_arr = $q->param('path');
71            my $full = $q->param('full');
72    
73          for(my $i = 1; $i <=10; $i++) {          for(my $i = 1; $i <=10; $i++) {
74    
75                  return show_index($self, $i) if ($q->param("f".$i."_index"));                  return show_index($self, $i) if ($q->param("f".$i."_index"));
# Line 88  sub show_results_list { Line 94  sub show_results_list {
94                                  $s.="$_* ";                                  $s.="$_* ";
95                          }                          }
96                  }                  }
97                    $s =~ s/\*+/*/g;
98    
99                  push @s_arr,$q->param("f$i")."_swish=($s)";                  push @s_arr,$q->param("f$i")."_swish=($s)";
100          }          }
# Line 105  sub show_results_list { Line 112  sub show_results_list {
112                          push @swish_results, {                          push @swish_results, {
113                                  nr => ($#swish_results + 2),                                  nr => ($#swish_results + 2),
114                                  path => $hit->swishdocpath,                                  path => $hit->swishdocpath,
115                                  headline => from_utf8({ -string => $hit->headline, -charset => $CHARSET }),                                  headline => $from_utf8->convert($hit->headline),
116                                  html => back2html(from_utf8({ -string => $hit->html, -charset => $CHARSET })),                                  html => back2html($from_utf8->convert($hit->html)),
117                                  rank => $hit->swishrank };                                  rank => $hit->swishrank };
118    
119                  },                  },
120                  #startnum => 0,                  #startnum => 0,
121                  maxhits => $MAX_HITS,                  maxhits => $MAX_HITS
122          );          );
123    
124          die $SWISH::errstr unless $sh;          die $SWISH::errstr unless $sh;
125    
126          my $hits = $sh->query(join(" and ",@s_arr)) || 0;       # FIX: and/or          # construct swish query
127            my $sw_q = join(" and ",@s_arr);
128            if (@path_arr) {
129                    $sw_q .= "and (swishdocpath=\"";
130                    $sw_q .= join("\" or swishdocpath=\"",@path_arr);
131                    $sw_q .= "\")";
132                    $tmpl->param('full',1); # show full records
133            }
134    
135            my $hits = $sh->query($sw_q);
136    
137          $tmpl->param('hits',$hits);          $tmpl->param('hits',$hits);
138          $tmpl->param('search',join(" and ",@s_arr));          $tmpl->param('search',$sw_q);
139    
140          # create a Pager object          # create a Pager object
141          my $pager = HTML::Pager->new(          my $pager = HTML::Pager->new(
# Line 188  sub show_index { Line 204  sub show_index {
204          $tmpl->param('limit',$limit);          $tmpl->param('limit',$limit);
205          $tmpl->param('total',$total);          $tmpl->param('total',$total);
206    
207    # FIX: I should set offset and leave out limit from fetch!!
208    #       if (! $q->param("PAGER_offset") {
209    #               $q->param("Pager_offet)
210    #       }
211    
212          my $pager = HTML::Pager->new(          my $pager = HTML::Pager->new(
213                  query => $q,                  query => $q,
214                  get_data_callback => sub {                  get_data_callback => sub {

Legend:
Removed from v.13  
changed lines
  Added in v.47

  ViewVC Help
Powered by ViewVC 1.1.26