/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 130 - (show annotations)
Thu Nov 24 12:18:00 2005 UTC (18 years, 5 months ago) by dpavlin
File size: 1412 byte(s)
 r9097@llin:  dpavlin | 2005-11-24 13:19:42 +0100
 combination of phrases from form with AND operator, show attributes in results

1 package Webpacus::Controller::Results;
2
3 use strict;
4 use warnings;
5 use base qw/Catalyst::Controller/;
6
7 =head1 NAME
8
9 Webpacus::Controller::Results - Display results from WebPAC
10
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 my $webpac = $c->comp('Model::WebPAC');
31 my $params = $c->req->params;
32 my $log = $c->log;
33
34 use Data::Dumper;
35 $log->debug("results got params: " . Dumper( $params ) );
36
37 my @attr;
38 my @words;
39
40 foreach my $f (keys %{ $params }) {
41
42 next if ($f =~ m/^_/o);
43
44 my $v = $params->{$f} || next;
45
46 push @words, $v;
47
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 }
56
57 my $q = join(' AND ', @words);
58
59 $c->stash->{html_results} = sub {
60 my $res = $webpac->search( $q, $params->{'_template'}, \@attr );
61 # $log->debug("controller got " . ( $#{$res} + 1 ) . " results for '$q' " . Dumper( $res ));
62 return $res;
63 };
64
65 $c->stash->{phrase} = $q;
66 $c->stash->{attr} = \@attr;
67
68 $c->stash->{template} = 'results.tt';
69 }
70
71 =back
72
73
74 =head1 AUTHOR
75
76 Dobrica Pavlinusic,,,
77
78 =head1 LICENSE
79
80 This library is free software, you can redistribute it and/or modify
81 it under the same terms as Perl itself.
82
83 =cut
84
85 1;

  ViewVC Help
Powered by ViewVC 1.1.26