1 use CatalystX
::GlobalContext
qw( $c );
2 ######################################################################
4 # Search the people database and display the results.
6 # Adapted from locus_search.pl by Evan Herbst, 1 / 3 / 07
8 ######################################################################
13 use CXGN::Page::FormattingHelpers
14 qw/blue_section_html info_section_html page_title_html columnar_table_html/;
15 use CXGN::Search::CannedForms;
16 use CXGN::Searches::People;
18 #################################################
20 # Start a new SGN page.
21 my $page = CXGN::Page->new( "SGN directory search results", "Evan" );
24 print page_title_html('Directory search results');
26 #create the search and query objects
27 my $search = CXGN::Searches::People->new();
28 my $query = $search->new_query();
29 $search->page_size(20); #results shown per page
32 my %params = CGI->new->Vars
33 or $c->throw( message => 'No query parameters provided', is_error => 0 );
34 $query->from_request( \%params );
36 my $search_again_html = info_section_html(
37 title => 'Search again',
38 contents => CXGN::Search::CannedForms::people_search_form( $page, $query )
42 #_add_to_param( $query, $_, '&t NOT LIKE ? AND &t IS NOT NULL', '%contact-info.pl%')
43 # for 'last_name', 'first_name';
45 my $result = $search->do_search($query); #execute the search
47 while ( my $r = $result->next_result() ) {
48 #fields in result objs appear in the order in which they're registered with has_parameter() in the query class
51 qq|<a href="/solpeople/personal-info.pl?sp_person_id=$r->[7]&action=view">$r->[1], $r->[0]</a>|,
58 #build the HTML to output
59 my $pagination_html = $search->pagination_buttons_html( $query, $result );
61 my $results_html = <<EOH;
62 <div id="searchresults">
65 $results_html .= columnar_table_html
(
66 headings
=> [ 'Name', 'E-mail', 'Organization', 'Country' ],
71 $results_html .= <<EOH;
77 print info_section_html
(
81 '<span class="paginate_summary">%s matches </span>',
82 $result->total_results()
88 print '<h4>No matches found</h4>';
91 print $search_again_html;
95 #### helper subs ######
97 # set additional criteria to not return people that have not set their
98 # first name or last name
100 my ($query,$param,$cond,@bind) = @_;
101 my $curr = $query->param_val($param) || ['true'];
102 my $curr_exp = shift @
$curr;
103 $curr_exp = "&t $curr_exp" unless $curr_exp =~ /(&t|^true$)/;
104 $query->param_set($param => ["$curr_exp AND $cond",@
$curr,@bind]);