/[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 14 by dpavlin, Sat Feb 22 13:22:09 2003 UTC revision 53 by dpavlin, Sun Jun 1 18:49:49 2003 UTC
# Line 8  use HTML::FillInForm; Line 8  use HTML::FillInForm;
8  use SWISH;  use SWISH;
9  use Text::Iconv;  use Text::Iconv;
10  use DBI;  use DBI;
11    use Config::IniFiles;
12    
13  use lib '..';  use lib '..';
14  use index_DBI;  use index_DBI;
15  use back2html;  use back2html;
16    
17  # configuration options  # configuration options
18  # FIX: they really should go in configuration file!  # FIXME they really should go in configuration file!
19  my $TEMPLATE_PATH = '/data/webpac/template_html';  my $TEMPLATE_PATH = '/data/webpac/template_html';
20  my $CHARSET = 'ISO-8859-2';  my $CHARSET = 'ISO-8859-2';
21  my $SWISH = '/usr/bin/swish-e';  my $SWISH = '/usr/bin/swish-e';
# Line 22  my $INDEX = '/data/webpac/index/isis.ind Line 23  my $INDEX = '/data/webpac/index/isis.ind
23  my $MAX_HITS = 500;  my $MAX_HITS = 500;
24  my $ON_PAGE = 10;  my $ON_PAGE = 10;
25    
26  Text::Iconv->raise_error(1);     # Conversion errors raise exceptions  Text::Iconv->raise_error(0);     # Conversion errors raise exceptions
27    
28  my $from_utf8 = Text::Iconv->new('UTF8', $CHARSET);  my $from_utf8 = Text::Iconv->new('UTF8', $CHARSET);
29    
30    # read global.conf configuration
31    my $cfg_global = new Config::IniFiles( -file => '../global.conf' ) || die "can't open 'global.conf'";
32    
33    
34  sub setup {  sub setup {
35          my $self = shift;          my $self = shift;
36          $self->tmpl_path($TEMPLATE_PATH);          $self->tmpl_path($TEMPLATE_PATH);
# Line 67  sub show_results_list { Line 72  sub show_results_list {
72    
73          my @s_arr;      # all queries are located here          my @s_arr;      # all queries are located here
74    
75            my @path_arr = $q->param('path');
76            my $full = $q->param('full');
77    
78          for(my $i = 1; $i <=10; $i++) {          for(my $i = 1; $i <=10; $i++) {
79    
80                  return show_index($self, $i) if ($q->param("f".$i."_index"));                  return show_index($self, $i) if ($q->param("f".$i."_index"));
# Line 87  sub show_results_list { Line 95  sub show_results_list {
95                                  $s.= ($s) ? "and " : "";                                  $s.= ($s) ? "and " : "";
96                                  $s.="not " if ($1 eq "-");                                  $s.="not " if ($1 eq "-");
97                                  $s.="$2* ";                                  $s.="$2* ";
98                            } elsif (m/(and|or|not)/i) {
99                                    $s.="$_ ";
100                          } else {                          } else {
101                                  $s.="$_* ";                                  $s.="$_* ";
102                          }                          }
103                  }                  }
104                    $s =~ s/\*+/*/g;
105    
106                  push @s_arr,$q->param("f$i")."_swish=($s)";                  push @s_arr,$q->param("f$i")."_swish=($s)";
107          }          }
# Line 114  sub show_results_list { Line 125  sub show_results_list {
125    
126                  },                  },
127                  #startnum => 0,                  #startnum => 0,
128                  maxhits => $MAX_HITS,                  maxhits => $MAX_HITS
129          );          );
130    
131          die $SWISH::errstr unless $sh;          die $SWISH::errstr unless $sh;
132    
133          my $hits = $sh->query(join(" and ",@s_arr)) || 0;       # FIX: and/or          # construct swish query
134            my $sw_q = join(" and ",@s_arr);
135            if (@path_arr) {
136                    $sw_q .= "and (swishdocpath=\"";
137                    $sw_q .= join("\" or swishdocpath=\"",@path_arr);
138                    $sw_q .= "\")";
139                    $tmpl->param('full',1); # show full records
140            }
141    
142            my $hits = $sh->query($sw_q);
143    
144          $tmpl->param('hits',$hits);          $tmpl->param('hits',$hits);
145          $tmpl->param('search',join(" and ",@s_arr));          $tmpl->param('search',$sw_q);
146    
147            $tmpl->param('PAGER_offset',$q->param("PAGER_offset") || 0);
148            $tmpl->param('last_PAGER_offset',$q->param("last_PAGER_offset") || 0);
149    
150          # create a Pager object          # create a Pager object
151          my $pager = HTML::Pager->new(          my $pager = HTML::Pager->new(
# Line 176  sub show_index { Line 199  sub show_index {
199    
200          my $html;          my $html;
201    
202          my $index = new index_DBI();          my $index = new index_DBI(
203                    $cfg_global->val('global', 'dbi_dbd'),
204                    $cfg_global->val('global', 'dbi_dsn'),
205                    $cfg_global->val('global', 'dbi_user'),
206                    $cfg_global->val('global', 'dbi_passwd') || ''
207            );
208    
209          my $total = $index->check($field);          my $total = $index->check($field);
210          if (! $total) {          if (! $total) {
# Line 191  sub show_index { Line 219  sub show_index {
219          $tmpl->param('limit',$limit);          $tmpl->param('limit',$limit);
220          $tmpl->param('total',$total);          $tmpl->param('total',$total);
221    
222    # FIXME I should set offset and leave out limit from fetch!!
223    #       if (! $q->param("PAGER_offset") {
224    #               $q->param("Pager_offet)
225    #       }
226    
227          my $pager = HTML::Pager->new(          my $pager = HTML::Pager->new(
228                  query => $q,                  query => $q,
229                  get_data_callback => sub {                  get_data_callback => sub {

Legend:
Removed from v.14  
changed lines
  Added in v.53

  ViewVC Help
Powered by ViewVC 1.1.26