/[webpac2]/Webpacus/lib/Webpacus/Controller/Search.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 /Webpacus/lib/Webpacus/Controller/Search.pm

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

revision 161 by dpavlin, Sat Nov 26 16:37:04 2005 UTC revision 270 by dpavlin, Sat Dec 17 00:37:12 2005 UTC
# Line 32  Catalyst Controller for search fields Hy Line 32  Catalyst Controller for search fields Hy
32    
33  sub default : Private {  sub default : Private {
34      my ( $self, $c ) = @_;      my ( $self, $c ) = @_;
35    
36        $c->log->debug("default search got param: ".Dumper($c->req->params));
37    
38      $c->stash->{template} = 'search.tt';      $c->stash->{template} = 'search.tt';
39  }  }
40    
# Line 55  sub suggest : Regex('^search/suggest/*([ Line 58  sub suggest : Regex('^search/suggest/*([
58          my $webpac = $c->comp('Model::WebPAC');          my $webpac = $c->comp('Model::WebPAC');
59    
60          my $q = $c->req->params->{$what} ||          my $q = $c->req->params->{$what} ||
61                  $c->req->params->{all} || $c->res->output("no results");                  $c->req->params->{all} || $c->response->body("no results");
62    
63    
64          $log->info("search for '$q' in $what\n");          $log->info("search for '$q' in $what\n");
# Line 84  sub suggest : Regex('^search/suggest/*([ Line 87  sub suggest : Regex('^search/suggest/*([
87    
88          $log->debug( ($#suggestions + 1) . " unique hits returned");          $log->debug( ($#suggestions + 1) . " unique hits returned");
89    
90          $c->res->body( $c->prototype->auto_complete_result( \@suggestions ) );          $c->response->body( $c->prototype->auto_complete_result( \@suggestions ) );
91  }  }
92    
93    
 # specify all Hyper Estraier operators which should stop this module  
 # from splitting search query and joining it with default operator  
 my $hest_op_regex = qr/(:?\[(:?BW|EW|RX)\]|AND|OR|ANDNOT)/;  
   
94  =item results  =item results
95    
96  Method which uses C<Model::WebPAC> and returns results for search query  Returns results for search query
97    
98  =cut  =cut
99    
100  sub results : Local {  sub results : Local {
101          my ( $self, $c ) = @_;          my ( $self, $c ) = @_;
102    
         my $webpac = $c->comp('Model::WebPAC');  
103          my $params = $c->req->params;          my $params = $c->req->params;
104    
105            # oh, client didn't have ability to setup AJAX, fallback to
106            # page refresh
107            if (! $params->{'_ajax'}) {
108                    $params->{_ajax} = 1;
109                    $c->stash->{results} = $c->subreq('/search/results/ajax', {}, $params);
110            $c->stash->{template} = 'search.tt';
111            } else {
112                    $c->forward('/search/results/ajax');
113            }
114    }
115    
116    
117    =item results_ajax
118    
119    Private method which uses C<Model::WebPAC> and returns results for search
120    query It generatets just I<inner> HTML for results div, so it has C<_ajax>
121    in name.
122    
123    =cut
124    
125    # specify all Hyper Estraier operators which should stop this module
126    # from splitting search query and joining it with default operator
127    my $hest_op_regex = qr/(:?\[(:?BW|EW|RX)\]|AND|OR|ANDNOT)/o;
128    
129    sub results_ajax : Path( 'results/ajax' ) {
130            my ( $self, $c ) = @_;
131    
132            my $params = $c->req->params;
133            my $webpac = $c->comp('Model::WebPAC');
134          my $log = $c->log;          my $log = $c->log;
135    
136          $log->debug("results got params: " . Dumper( $params ) );          $log->debug("results got params: " . Dumper( $params ) );
137    
138          if ($params->{_page} < 1) {          if (! $params->{_page} || $params->{_page} < 1) {
139                  $params->{_page} = 1;                  $params->{_page} = 1;
140                  $log->warn("fixed _page parametar to 1");                  $log->warn("fixed _page parametar to 1");
141          }          }
# Line 175  sub results : Local { Line 203  sub results : Local {
203          $c->stash->{hits_on_page} = $hits_on_page;          $c->stash->{hits_on_page} = $hits_on_page;
204    
205          $c->stash->{template} = 'results.tt';          $c->stash->{template} = 'results.tt';
206    
207  }  }
208    
209  =back  =item record
210    
211    forwarded to C</editor/record>
212    
213    =cut
214    
215    sub record : Local {
216            my ( $self, $c ) = @_;
217    
218            $c->forward( '/editor/record' );
219    }
220    
221    =back
222    
223  =head1 AUTHOR  =head1 AUTHOR
224    

Legend:
Removed from v.161  
changed lines
  Added in v.270

  ViewVC Help
Powered by ViewVC 1.1.26