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

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

revision 704 by dpavlin, Sat Apr 30 15:48:40 2005 UTC revision 790 by dpavlin, Sun Jan 22 18:46:24 2012 UTC
# Line 63  sub suff2file($$$$) { Line 63  sub suff2file($$$$) {
63    
64          return $tpl if (! $base_path);          return $tpl if (! $base_path);
65    
66            #warn "base_path: $base_path, p: $p, path: $path, tpl: $tpl\n";
67    
68            $p =~ s#/[^/]*$##;
69    
70          # strip everything to and including base path, leaving only          # strip everything to and including base path, leaving only
71          # additional (virtual) path          # additional (virtual) path
72          if ($base_path eq "/") {          if ($base_path eq "/") {
# Line 247  sub show_results_list { Line 251  sub show_results_list {
251          my $full = $q->param('full');          my $full = $q->param('full');
252    
253          my @persist_vars = ( 'rm', 'persist_search' );          my @persist_vars = ( 'rm', 'persist_search' );
254          my @url_params = ( 'rm=results', 'show_full=1', 'last_PAGER_offset='.($q->param('PAGER_offset') || 0) );          my $url_params = {
255                    'rm' => 'results',
256                    'show_full' => 1,
257                    'last_PAGER_offset' => ($q->param('PAGER_offset') || 0),
258            };
259    
260          my @persist_search_vars;          my @persist_search_vars;
261          my @url_params_persist;          my $url_params_persist = {};
262          if ($q->param("persist_search")) {          if ($q->param("persist_search")) {
263                  @persist_search_vars = split(/\s*,\s*/, $q->param("persist_search"));                  @persist_search_vars = split(/\s*,\s*/, $q->param("persist_search"));
264                  push @url_params_persist, "persist_search=".$q->url_param("persist_search");                  $url_params_persist->{'persist_search'} = $q->url_param("persist_search");
265                  push @url_params,"persist_search=".$q->url_param("persist_search");                  $url_params->{'persist_search'} = $q->url_param("persist_search");
266          }          }
267    
268          # support parametars "f" and "v" for start          # support parametars "f" and "v" for start
# Line 275  sub show_results_list { Line 283  sub show_results_list {
283    
284                  # create url parametars (and persistent ones)                  # create url parametars (and persistent ones)
285    
286                  push @url_params,"f$i=".$q->url_param("f$i");                  $url_params->{"f$i"} = $q->url_param("f$i");
287                  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);
288    
289                    my @v;
290    
291                  foreach my $v ($q->url_param("v$i")) {                  foreach my $v ($q->url_param("v$i")) {
292                          # escape quotes so that phrase search work                          # escape quotes so that phrase search work
293                          $v =~ s/"/%22/g;                          $v =~ s/"/%22/g;
294                          push @url_params,"v$i=$v";                          push @v, $v;
                         push @url_params_persist,"v$i=$v" if ($persist);  
295                  }                  }
296                    $url_params->{"v$i"} = \@v;
297                    $url_params_persist->{"v$i"} = \@v if ($persist);
298    
299                  if ($q->param("e$i")) {                  if ($q->param("e$i")) {
300                          push @url_params,"e$i=".$q->url_param("e$i");                          $url_params->{"e$i"} = $q->url_param("e$i");
301  #                       push @url_params_persist,"e$i=".$q->url_param("e$i");  #                       $url_params_persist->{"e$i"} = $q->url_param("e$i");
302                  }                  }
303    
304                  my $wc="*";     # swish wildcard                  my $wc="*";     # swish wildcard
# Line 389  sub show_results_list { Line 400  sub show_results_list {
400          if ($filter) {          if ($filter) {
401                  $sw_q .= " and (swishdocpath=\"$filter\")" unless (@path_arr);                  $sw_q .= " and (swishdocpath=\"$filter\")" unless (@path_arr);
402                  push @persist_vars, "filter";                  push @persist_vars, "filter";
403                  push @url_params, "filter=$filter";                  $url_params->{'filter'} = $filter;
404                  push @url_params_persist, "filter=$filter";                  $url_params_persist->{'filter'} = $filter;
405          }          }
406    
407          my $swish_msg = ' ';          my $swish_msg = ' ';
# Line 410  sub show_results_list { Line 421  sub show_results_list {
421          my $hits = $results->Hits;          my $hits = $results->Hits;
422    
423          $tmpl->param('hits',$hits);          $tmpl->param('hits',$hits);
424            $tmpl->param('hits_gt_2',$hits > 2);
425          my $search_msg = $sw_q;          my $search_msg = $sw_q;
426          $search_msg .= '<em>'.$swish_msg.'</em>' if ($swish_msg);          $search_msg .= '<em>'.$swish_msg.'</em>' if ($swish_msg);
427          $tmpl->param('search', $search_msg);          $tmpl->param('search', $search_msg);
# Line 418  sub show_results_list { Line 430  sub show_results_list {
430          $tmpl->param('last_PAGER_offset',$q->param("last_PAGER_offset") || 0);          $tmpl->param('last_PAGER_offset',$q->param("last_PAGER_offset") || 0);
431    
432          # URL parametars for search results          # URL parametars for search results
433          $tmpl->param('url_params',"?".join("&",@url_params));          sub cook_url_params {
434          $tmpl->param('url_params_paths',"?".join("&",@url_params).'&'.join("&",map { my $t = $_; $t =~ s/\#/%23/g; "path=$t"; } @path_arr));                  my $hash = shift || return;
435                    return join("&", map {
436                            my $var = $_;
437                            if (ref($hash->{$var}) eq 'ARRAY') {
438                                    join('&',
439                                            map { $var.'='.$_ } @{$hash->{$var}}
440                                    );
441                            } else {
442                                    $var."=".$hash->{$var};
443                            }
444                    } keys %{$hash});
445            }
446    
447            $tmpl->param('url_params',"?".cook_url_params($url_params));
448            $tmpl->param('url_params_paths',"?".cook_url_params($url_params).'&'.join("&",map { my $t = $_; $t =~ s/\#/%23/g; "path=$t"; } @path_arr));
449    
450    
451    
# Line 456  sub show_results_list { Line 482  sub show_results_list {
482                          rank => $result->Property('swishrank')                          rank => $result->Property('swishrank')
483                  };                  };
484    
485                  $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'));
486                    $r->{html} = back2html($from_utf8->convert($result->Property('html')), $filter ? 'filter='.$filter : '') if ($q->param('show_full'));
487    
488                  push @pager_data_list, $r;                  push @pager_data_list, $r;
489          }          }

Legend:
Removed from v.704  
changed lines
  Added in v.790

  ViewVC Help
Powered by ViewVC 1.1.26