/[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 139 - (hide 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 dpavlin 83 package Webpacus::Controller::Results;
2    
3     use strict;
4     use warnings;
5 dpavlin 97 use base qw/Catalyst::Controller/;
6 dpavlin 133 use Data::Dumper;
7 dpavlin 83
8     =head1 NAME
9    
10 dpavlin 97 Webpacus::Controller::Results - Display results from WebPAC
11 dpavlin 83
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 dpavlin 93 my $webpac = $c->comp('Model::WebPAC');
32     my $params = $c->req->params;
33     my $log = $c->log;
34 dpavlin 83
35 dpavlin 99 $log->debug("results got params: " . Dumper( $params ) );
36 dpavlin 93
37 dpavlin 94 my @attr;
38 dpavlin 130 my @words;
39 dpavlin 133 # default operator to join fields/words
40     my $operator = 'AND';
41 dpavlin 94
42     foreach my $f (keys %{ $params }) {
43 dpavlin 98
44 dpavlin 94 next if ($f =~ m/^_/o);
45 dpavlin 98
46     my $v = $params->{$f} || next;
47    
48 dpavlin 133 if (my $op = $params->{ '_' . $f}) {
49     push @words, join(" $op ", split(/\s+/, $v) );
50     } else {
51     push @words, $v;
52     }
53 dpavlin 118
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 dpavlin 94 }
62    
63 dpavlin 133 my $q = join(" $operator ", @words);
64 dpavlin 129
65 dpavlin 139 my $template = $params->{'_template'};
66     $log->debug("using template $template");
67    
68 dpavlin 100 $c->stash->{html_results} = sub {
69 dpavlin 139 my $res = $webpac->search( $q, $template, \@attr );
70 dpavlin 101 # $log->debug("controller got " . ( $#{$res} + 1 ) . " results for '$q' " . Dumper( $res ));
71 dpavlin 94 return $res;
72 dpavlin 93 };
73    
74 dpavlin 129 $c->stash->{phrase} = $q;
75 dpavlin 130 $c->stash->{attr} = \@attr;
76 dpavlin 129
77 dpavlin 83 $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