--- branches/tehnika/WebPac.pm 2005/04/30 15:48:40 704 +++ branches/tehnika/WebPac.pm 2005/09/11 18:45:50 710 @@ -247,14 +247,18 @@ my $full = $q->param('full'); my @persist_vars = ( 'rm', 'persist_search' ); - my @url_params = ( 'rm=results', 'show_full=1', 'last_PAGER_offset='.($q->param('PAGER_offset') || 0) ); + my $url_params = { + 'rm' => 'results', + 'show_full' => 1, + 'last_PAGER_offset' => ($q->param('PAGER_offset') || 0), + }; my @persist_search_vars; - my @url_params_persist; + my $url_params_persist = {}; if ($q->param("persist_search")) { @persist_search_vars = split(/\s*,\s*/, $q->param("persist_search")); - push @url_params_persist, "persist_search=".$q->url_param("persist_search"); - push @url_params,"persist_search=".$q->url_param("persist_search"); + $url_params_persist->{'persist_search'} = $q->url_param("persist_search"); + $url_params->{'persist_search'} = $q->url_param("persist_search"); } # support parametars "f" and "v" for start @@ -275,19 +279,19 @@ # create url parametars (and persistent ones) - push @url_params,"f$i=".$q->url_param("f$i"); - push @url_params_persist,"f$i=".$q->url_param("f$i") if ($persist); + $url_params->{"f$i"} = $q->url_param("f$i"); + $url_params_persist->{"f$i"} = $q->url_param("f$i") if ($persist); foreach my $v ($q->url_param("v$i")) { # escape quotes so that phrase search work $v =~ s/"/%22/g; - push @url_params,"v$i=$v"; - push @url_params_persist,"v$i=$v" if ($persist); + $url_params->{"v$i"} = $v; + $url_params_persist->{"v$i"} = $v if ($persist); } if ($q->param("e$i")) { - push @url_params,"e$i=".$q->url_param("e$i"); -# push @url_params_persist,"e$i=".$q->url_param("e$i"); + $url_params->{"e$i"} = $q->url_param("e$i"); +# $url_params_persist->{"e$i"} = $q->url_param("e$i"); } my $wc="*"; # swish wildcard @@ -389,8 +393,8 @@ if ($filter) { $sw_q .= " and (swishdocpath=\"$filter\")" unless (@path_arr); push @persist_vars, "filter"; - push @url_params, "filter=$filter"; - push @url_params_persist, "filter=$filter"; + $url_params->{'filter'} = $filter; + $url_params_persist->{'filter'} = $filter; } my $swish_msg = ' '; @@ -418,8 +422,13 @@ $tmpl->param('last_PAGER_offset',$q->param("last_PAGER_offset") || 0); # URL parametars for search results - $tmpl->param('url_params',"?".join("&",@url_params)); - $tmpl->param('url_params_paths',"?".join("&",@url_params).'&'.join("&",map { my $t = $_; $t =~ s/\#/%23/g; "path=$t"; } @path_arr)); + sub cook_url_params { + my $hash = shift || return; + return join("&", map { $_."=".$hash->{$_} } keys %{$hash}); + } + + $tmpl->param('url_params',"?".cook_url_params($url_params)); + $tmpl->param('url_params_paths',"?".cook_url_params($url_params).'&'.join("&",map { my $t = $_; $t =~ s/\#/%23/g; "path=$t"; } @path_arr)); @@ -456,7 +465,8 @@ rank => $result->Property('swishrank') }; - $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')); + $r->{html} = back2html($from_utf8->convert($result->Property('html')), $filter ? 'filter='.$filter : '') if ($q->param('show_full')); push @pager_data_list, $r; }