upload fieldbook from manage phenotyping
[sgn.git] / cgi-bin / search / image_search.pl
bloba22295aa80ac59feee54877d1147d956fef55586
1 ######################################################################
3 # Search the image database and display the results.
5 ######################################################################
7 use strict;
9 use CXGN::Searches::Images;
10 use CXGN::Page;
11 use CXGN::Page::FormattingHelpers qw/blue_section_html
12 info_section_html
13 page_title_html
14 columnar_table_html
16 use CXGN::Search::CannedForms;
17 #################################################
19 # Start a new SGN page.
20 my $page=CXGN::Page->new("SGN image search results","Jessica");
21 $page->header();
23 print page_title_html('Image search results');
25 #create the search and query objects
26 my $search = CXGN::Searches::Images->new;
27 my $query = $search->new_query;
28 $search->page_size(30); #set 30 images per page
30 #get the parameters
31 my %params = $page->get_all_encoded_arguments;
33 $query->from_request(\%params);
35 if(%params) {
36 my $result = $search->do_search($query);
37 my @results;
39 while(my $r = $result->next_result) {
40 my $image_id = $r->[0];
42 my $image_description = $r->[2];
43 if( length($image_description) < 1 ) {
44 $image_description = "---";
47 my $image_filename = $r->[3];
48 my $submitter_id = $r->[4];
50 my $submitter_first = $r->[5];
51 if( length($submitter_first) < 1 ) {
52 $submitter_first = "---";
55 my $submitter_last = $r->[6];
56 if( length($submitter_last) < 1 ) {
57 $submitter_last = "---";
60 # Put all submitter data in one variable
61 my $submitter_string = "";
63 unless ( $submitter_first eq "---" ) {
64 $submitter_string .= $submitter_first;
65 $submitter_string .= " ";
68 unless ( $submitter_last eq "---" ) {
69 $submitter_string .= $submitter_last;
72 # Image id, image filename, and submitter id can't be null, but everything else can be.
74 push @results, [$image_description, '<a href="/image/index.pl?image_id='.$r->[0].'">'.$image_filename.'</a>', '<a href="/solpeople/personal-info.pl?sp_person_id='.$r->[4].'">'.$submitter_string.'</a>'];
77 #build the HTML to output
78 my $pagination_html = $search->pagination_buttons_html( $query, $result );
81 my $results_html = <<EOH;
82 <div id="searchresults">
83 EOH
85 $results_html .= columnar_table_html(headings => ['Image Description',
86 'Image Filename',
87 'Submitter (ID) Name'],
88 data => \@results,
91 $results_html .= <<EOH;
92 </div>
93 $pagination_html
94 EOH
97 if (@results) {
98 print blue_section_html('Image search results', ,sprintf('<span class="paginate_summary">%s matches </span>', $result->total_results,$result->time),$results_html);
99 }else {
100 print '<h4>No matches found</h4>';
103 print info_section_html(title => 'Search again',
104 contents =>CXGN::Search::CannedForms::image_search_form($page,$query)
111 $page->footer();
113 #############