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

Annotation of /Webpacus/lib/Webpacus/Controller/Results.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 129 - (hide annotations)
Thu Nov 24 12:17:55 2005 UTC (18 years, 5 months ago) by dpavlin
File size: 1422 byte(s)
 r9096@llin:  dpavlin | 2005-11-24 13:02:12 +0100
 strip spaces and transfer search 'phrase' to template

1 dpavlin 83 package Webpacus::Controller::Results;
2    
3     use strict;
4     use warnings;
5 dpavlin 97 use base qw/Catalyst::Controller/;
6 dpavlin 83
7     =head1 NAME
8    
9 dpavlin 97 Webpacus::Controller::Results - Display results from WebPAC
10 dpavlin 83
11     =head1 SYNOPSIS
12    
13     See L<Webpacus>
14    
15     =head1 DESCRIPTION
16    
17     Catalyst Controller.
18    
19     =head1 METHODS
20    
21     =over 4
22    
23     =item default
24    
25     =cut
26    
27     sub default : Private {
28     my ( $self, $c ) = @_;
29    
30 dpavlin 93 my $webpac = $c->comp('Model::WebPAC');
31     my $params = $c->req->params;
32     my $log = $c->log;
33 dpavlin 83
34 dpavlin 93 use Data::Dumper;
35 dpavlin 99 $log->debug("results got params: " . Dumper( $params ) );
36 dpavlin 93
37 dpavlin 94 my $q;
38     my @attr;
39    
40     foreach my $f (keys %{ $params }) {
41 dpavlin 98
42 dpavlin 94 next if ($f =~ m/^_/o);
43 dpavlin 98
44     my $v = $params->{$f} || next;
45    
46     $q .= "$v ";
47 dpavlin 118
48     next if ($f eq 'all'); # don't add_attr for magic field all
49    
50     if ($v !~ /\s/) {
51     push @attr, "$f ISTRINC $v";
52     } else {
53     map { push @attr, "$f ISTRINC $_"; } split(/\s+/, $v);
54     }
55 dpavlin 94 }
56    
57 dpavlin 129 # strip spaces from beginning and end
58     $q =~ s/^\s+//;
59     $q =~ s/\s+$//;
60    
61 dpavlin 100 $c->stash->{html_results} = sub {
62 dpavlin 118 my $res = $webpac->search( $q, $params->{'_template'}, \@attr );
63 dpavlin 101 # $log->debug("controller got " . ( $#{$res} + 1 ) . " results for '$q' " . Dumper( $res ));
64 dpavlin 94 return $res;
65 dpavlin 93 };
66    
67 dpavlin 129 $c->stash->{phrase} = $q;
68    
69 dpavlin 83 $c->stash->{template} = 'results.tt';
70     }
71    
72     =back
73    
74    
75     =head1 AUTHOR
76    
77     Dobrica Pavlinusic,,,
78    
79     =head1 LICENSE
80    
81     This library is free software, you can redistribute it and/or modify
82     it under the same terms as Perl itself.
83    
84     =cut
85    
86     1;

  ViewVC Help
Powered by ViewVC 1.1.26