Implemented persistent filter which can be used in index or search to
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 30 Apr 2005 15:46:03 +0000 (15:46 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 30 Apr 2005 15:46:03 +0000 (15:46 +0000)
specify database name to limit search to. Filter searches are presistant.

git-svn-id: file:///home/dpavlin/private/svn/webpac/trunk@698 13eb9ef6-21d5-0310-b721-a9d68796d827

WebPac.pm

index 680cc5b..535084c 100644 (file)
--- a/WebPac.pm
+++ b/WebPac.pm
@@ -337,6 +337,7 @@ sub show_results_list {
                                }
                        }
                        $s =~ s/\*+/*/g;
+                       $s =~ s/[()]//g;        # () are used in query language
                        $s = $pre.$s.$post if ($q->param("e$i"));
                        push @swish_q,$s;
                }
@@ -347,8 +348,6 @@ sub show_results_list {
 
        my $tmpl = $self->load_tmpl(url_ex($q,'results.html'), global_vars => 1, die_on_bad_params => 0);
 
-       $tmpl->param('url_params',"?".join("&",@url_params));
-
        sub esc_html {
                my $html = shift;
                $html =~ s/</&lt;/g;
@@ -367,15 +366,19 @@ sub show_results_list {
                $sort = $sortby;
                push @persist_vars, "sortby";
        }
-       $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
+       my $filter = $q->param("filter");
 
        # construct swish query
        my $sw_q = join(" and ",@s_arr);
        if (@path_arr && $q->param('show_full')) {
-               $sw_q .= "and (swishdocpath=\"";
+               $sw_q .= " and (swishdocpath=\"";
                $sw_q .= join("\" or swishdocpath=\"",@path_arr);
                $sw_q .= "\")";
                $tmpl->param('full',1); # show full records
+#      } elsif (@path_arr && $#path_arr == 0) {
+#              # I will assume that it's a filter since there isn't show_full
+#              $filter = shift @path_arr;
        } elsif ($q->param('show_full')) {
                # just show full path, no path defined
                $tmpl->param('full',1);
@@ -383,6 +386,13 @@ sub show_results_list {
                $tmpl->param('full',0);
        }
 
+       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";
+       }
+
        my $swish_msg = ' ';
 
        # create new swish instance
@@ -407,6 +417,12 @@ sub show_results_list {
        $tmpl->param('PAGER_offset',$q->param("PAGER_offset") || 0);
        $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));
+
+
+
        #
        # build pager
        #