/[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 139 - (show annotations)
Thu Nov 24 22:29:50 2005 UTC (18 years, 5 months ago) by dpavlin
File size: 1666 byte(s)
 r9113@llin:  dpavlin | 2005-11-24 23:30:49 +0100
 add webpacus_version TT variable for footer, correct path to css, more debug

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

  ViewVC Help
Powered by ViewVC 1.1.26