/[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 382 by dpavlin, Sun Jan 22 02:52:24 2006 UTC revision 440 by dpavlin, Sun Apr 30 23:20:12 2006 UTC
# Line 4  use strict; Line 4  use strict;
4  use warnings;  use warnings;
5  use base 'Catalyst::Controller';  use base 'Catalyst::Controller';
6    
 use Data::Dumper;  
   
7  use lib '/data/webpac2/lib';  use lib '/data/webpac2/lib';
8  use WebPAC::Search::Estraier 0.03;  use WebPAC::Search::Estraier 0.03;
9    use Data::SpreadPagination;
10    
11    
12  =head1 NAME  =head1 NAME
# Line 33  Catalyst Controller for search fields Hy Line 32  Catalyst Controller for search fields Hy
32  sub default : Private {  sub default : Private {
33      my ( $self, $c ) = @_;      my ( $self, $c ) = @_;
34    
35      $c->log->debug("default search got param: ".Dumper($c->req->params));          $c->log->dumper($c->req->params, 'params');
36    
37      $c->stash->{template} = 'search.tt';      $c->stash->{template} = 'search.tt';
38  }  }
# Line 64  sub suggest : Local { Line 63  sub suggest : Local {
63          my $log = $c->log;          my $log = $c->log;
64    
65          my $webpac = $c->comp('Model::WebPAC');          my $webpac = $c->comp('Model::WebPAC');
66            #$c->log->dumper( $c->stash, 'stash' );
67            $webpac->setup_site( $c->stash->{site} );
68    
69          my $q = $c->req->params->{ $search || 'all' } || $c->response->body("no results");          my $q = $c->req->params->{ $search || 'all' } || $c->response->body("no results");
70    
# Line 134  sub results_ajax : Path( 'results/ajax' Line 135  sub results_ajax : Path( 'results/ajax'
135    
136          my $params = $c->req->params;          my $params = $c->req->params;
137          my $webpac = $c->comp('Model::WebPAC');          my $webpac = $c->comp('Model::WebPAC');
138            $webpac->setup_site( $c->stash->{site} );
139          my $log = $c->log;          my $log = $c->log;
140    
141          $log->debug("results got params: " . Dumper( $params ) );          $log->dumper($params, 'params');
142    
143          if (! $params->{_page} || $params->{_page} < 1) {          if (! $params->{_page} || $params->{_page} < 1) {
144                  $params->{_page} = 1;                  $params->{_page} = 1;
# Line 188  sub results_ajax : Path( 'results/ajax' Line 190  sub results_ajax : Path( 'results/ajax'
190    
191          $log->debug("using template $template to produce $hits_on_page results");          $log->debug("using template $template to produce $hits_on_page results");
192    
193          $c->stash->{html_results} = sub {          $c->stash->{html_results} = $webpac->search(
                 my $res = $webpac->search(  
194                          phrase => $q,                          phrase => $q,
195                          template => $template,                          template => $template,
196                          add_attr => $c->{stash}->{attr},                          add_attr => $c->{stash}->{attr},
197                          get_attr => [ '@uri' ],                          get_attr => [ '@uri' ],
198                          max => $hits_on_page,                          max => $hits_on_page,
199                          page => $params->{'_page'},                          page => $params->{'_page'},
200                  );          );
201  #               $log->debug("controller got " . ( $#{$res} + 1 ) . " results for '$q' " . Dumper( $res ));  
202                  return $res;          $c->stash->{hints} = $webpac->hints;
         };  
203    
204          $c->stash->{phrase} = $q;          $c->stash->{phrase} = $q;
205          $c->stash->{page} = $params->{'_page'};          $c->stash->{page} = $params->{_page};
206          $c->stash->{hits_on_page} = $hits_on_page;          $c->stash->{hits_on_page} = $hits_on_page;
207    
208            # create pager
209            $c->stash->{pager} = new Data::SpreadPagination({
210                    totalEntries => $webpac->hints->{hit},
211                    entriesPerPage => $hits_on_page,
212                    currentPage => $params->{_page},
213                    maxPages => $c->config->{pager}->{max_pages} || 10,
214            });
215    
216          $c->stash->{template} = 'results.tt';          $c->stash->{template} = 'results.tt';
217    
218  }  }
# Line 246  forwarded to C</editor/record> Line 254  forwarded to C</editor/record>
254  sub record : Local {  sub record : Local {
255          my ( $self, $c ) = @_;          my ( $self, $c ) = @_;
256    
257          $c->forward( '/editor/record' );          $c->detach( '/editor/record' );
258  }  }
259    
260  =back  =back

Legend:
Removed from v.382  
changed lines
  Added in v.440

  ViewVC Help
Powered by ViewVC 1.1.26