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

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

revision 697 by dpavlin, Sun Mar 13 02:03:30 2005 UTC revision 731 by dpavlin, Thu Apr 13 19:47:32 2006 UTC
# Line 247  sub show_results_list { Line 247  sub show_results_list {
247          my $full = $q->param('full');          my $full = $q->param('full');
248    
249          my @persist_vars = ( 'rm', 'persist_search' );          my @persist_vars = ( 'rm', 'persist_search' );
250          my @url_params = ( 'rm=results', 'show_full=1', 'last_PAGER_offset='.($q->param('PAGER_offset') || 0) );          my $url_params = {
251                    'rm' => 'results',
252                    'show_full' => 1,
253                    'last_PAGER_offset' => ($q->param('PAGER_offset') || 0),
254            };
255    
256          my @persist_search_vars;          my @persist_search_vars;
257          my @url_params_persist;          my $url_params_persist = {};
258          if ($q->param("persist_search")) {          if ($q->param("persist_search")) {
259                  @persist_search_vars = split(/\s*,\s*/, $q->param("persist_search"));                  @persist_search_vars = split(/\s*,\s*/, $q->param("persist_search"));
260                  push @url_params_persist, "persist_search=".$q->url_param("persist_search");                  $url_params_persist->{'persist_search'} = $q->url_param("persist_search");
261                  push @url_params,"persist_search=".$q->url_param("persist_search");                  $url_params->{'persist_search'} = $q->url_param("persist_search");
262          }          }
263    
264          # support parametars "f" and "v" for start          # support parametars "f" and "v" for start
# Line 275  sub show_results_list { Line 279  sub show_results_list {
279    
280                  # create url parametars (and persistent ones)                  # create url parametars (and persistent ones)
281    
282                  push @url_params,"f$i=".$q->url_param("f$i");                  $url_params->{"f$i"} = $q->url_param("f$i");
283                  push @url_params_persist,"f$i=".$q->url_param("f$i") if ($persist);                  $url_params_persist->{"f$i"} = $q->url_param("f$i") if ($persist);
284    
285                    my @v;
286    
287                  foreach my $v ($q->url_param("v$i")) {                  foreach my $v ($q->url_param("v$i")) {
288                          # escape quotes so that phrase search work                          # escape quotes so that phrase search work
289                          $v =~ s/"/%22/g;                          $v =~ s/"/%22/g;
290                          push @url_params,"v$i=$v";                          push @v, $v;
                         push @url_params_persist,"v$i=$v" if ($persist);  
291                  }                  }
292                    $url_params->{"v$i"} = \@v;
293                    $url_params_persist->{"v$i"} = \@v if ($persist);
294    
295                  if ($q->param("e$i")) {                  if ($q->param("e$i")) {
296                          push @url_params,"e$i=".$q->url_param("e$i");                          $url_params->{"e$i"} = $q->url_param("e$i");
297  #                       push @url_params_persist,"e$i=".$q->url_param("e$i");  #                       $url_params_persist->{"e$i"} = $q->url_param("e$i");
298                  }                  }
299    
300                  my $wc="*";     # swish wildcard                  my $wc="*";     # swish wildcard
# Line 337  sub show_results_list { Line 344  sub show_results_list {
344                                  }                                  }
345                          }                          }
346                          $s =~ s/\*+/*/g;                          $s =~ s/\*+/*/g;
347                            $s =~ s/[()]//g;        # () are used in query language
348                          $s = $pre.$s.$post if ($q->param("e$i"));                          $s = $pre.$s.$post if ($q->param("e$i"));
349                          push @swish_q,$s;                          push @swish_q,$s;
350                  }                  }
# Line 347  sub show_results_list { Line 355  sub show_results_list {
355    
356          my $tmpl = $self->load_tmpl(url_ex($q,'results.html'), global_vars => 1, die_on_bad_params => 0);          my $tmpl = $self->load_tmpl(url_ex($q,'results.html'), global_vars => 1, die_on_bad_params => 0);
357    
         $tmpl->param('url_params',"?".join("&",@url_params));  
   
358          sub esc_html {          sub esc_html {
359                  my $html = shift;                  my $html = shift;
360                  $html =~ s/</&lt;/g;                  $html =~ s/</&lt;/g;
# Line 367  sub show_results_list { Line 373  sub show_results_list {
373                  $sort = $sortby;                  $sort = $sortby;
374                  push @persist_vars, "sortby";                  push @persist_vars, "sortby";
375          }          }
376          $tmpl->param('url_params_paths',"?".join("&",@url_params).'&'.join("&",map { my $t = $_; $t =~ s/\#/%23/g; "path=$t"; } @path_arr));          # used to filter entries in index and swish
377            my $filter = $q->param("filter");
378    
379          # construct swish query          # construct swish query
380          my $sw_q = join(" and ",@s_arr);          my $sw_q = join(" and ",@s_arr);
381          if (@path_arr && $q->param('show_full')) {          if (@path_arr && $q->param('show_full')) {
382                  $sw_q .= "and (swishdocpath=\"";                  $sw_q .= " and (swishdocpath=\"";
383                  $sw_q .= join("\" or swishdocpath=\"",@path_arr);                  $sw_q .= join("\" or swishdocpath=\"",@path_arr);
384                  $sw_q .= "\")";                  $sw_q .= "\")";
385                  $tmpl->param('full',1); # show full records                  $tmpl->param('full',1); # show full records
386    #       } elsif (@path_arr && $#path_arr == 0) {
387    #               # I will assume that it's a filter since there isn't show_full
388    #               $filter = shift @path_arr;
389          } elsif ($q->param('show_full')) {          } elsif ($q->param('show_full')) {
390                  # just show full path, no path defined                  # just show full path, no path defined
391                  $tmpl->param('full',1);                  $tmpl->param('full',1);
# Line 383  sub show_results_list { Line 393  sub show_results_list {
393                  $tmpl->param('full',0);                  $tmpl->param('full',0);
394          }          }
395    
396            if ($filter) {
397                    $sw_q .= " and (swishdocpath=\"$filter\")" unless (@path_arr);
398                    push @persist_vars, "filter";
399                    $url_params->{'filter'} = $filter;
400                    $url_params_persist->{'filter'} = $filter;
401            }
402    
403          my $swish_msg = ' ';          my $swish_msg = ' ';
404    
405          # create new swish instance          # create new swish instance
# Line 407  sub show_results_list { Line 424  sub show_results_list {
424          $tmpl->param('PAGER_offset',$q->param("PAGER_offset") || 0);          $tmpl->param('PAGER_offset',$q->param("PAGER_offset") || 0);
425          $tmpl->param('last_PAGER_offset',$q->param("last_PAGER_offset") || 0);          $tmpl->param('last_PAGER_offset',$q->param("last_PAGER_offset") || 0);
426    
427            # URL parametars for search results
428            sub cook_url_params {
429                    my $hash = shift || return;
430                    return join("&", map {
431                            my $var = $_;
432                            if (ref($hash->{$var}) eq 'ARRAY') {
433                                    join('&',
434                                            map { $var.'='.$_ } @{$hash->{$var}}
435                                    );
436                            } else {
437                                    $var."=".$hash->{$var};
438                            }
439                    } keys %{$hash});
440            }
441    
442            $tmpl->param('url_params',"?".cook_url_params($url_params));
443            $tmpl->param('url_params_paths',"?".cook_url_params($url_params).'&'.join("&",map { my $t = $_; $t =~ s/\#/%23/g; "path=$t"; } @path_arr));
444    
445    
446    
447          #          #
448          # build pager          # build pager
449          #          #
# Line 440  sub show_results_list { Line 477  sub show_results_list {
477                          rank => $result->Property('swishrank')                          rank => $result->Property('swishrank')
478                  };                  };
479    
480                  $r->{html} = back2html($from_utf8->convert($result->Property('html')), join("&",@url_params_persist)) if ($q->param('show_full'));                  #$r->{html} = back2html($from_utf8->convert($result->Property('html')), cook_url_params($url_params_persist)) if ($q->param('show_full'));
481                    $r->{html} = back2html($from_utf8->convert($result->Property('html')), $filter ? 'filter='.$filter : '') if ($q->param('show_full'));
482    
483                  push @pager_data_list, $r;                  push @pager_data_list, $r;
484          }          }

Legend:
Removed from v.697  
changed lines
  Added in v.731

  ViewVC Help
Powered by ViewVC 1.1.26