modified autogenerated name method
[sgn.git] / cgi-bin / search / image_search.pl
blobe250c3dfb0e545d3ebdf12ffe260011e99f30d06
1 ######################################################################
2 # #### DEPRECATED CGIBIN CODE ########################################
4 # Search the image database and display the results.
6 ######################################################################
8 use strict;
10 use CXGN::Searches::Images;
11 use CXGN::Page;
12 use CXGN::Page::FormattingHelpers qw/blue_section_html
13 info_section_html
14 page_title_html
15 columnar_table_html
17 use CXGN::Search::CannedForms;
18 #################################################
20 # Start a new SGN page.
21 my $page=CXGN::Page->new("SGN image search results","Jessica");
22 $page->header();
24 print page_title_html('Image search results');
26 #create the search and query objects
27 my $search = CXGN::Searches::Images->new;
28 my $query = $search->new_query;
29 $search->page_size(30); #set 30 images per page
31 #get the parameters
32 my %params = $page->get_all_encoded_arguments;
34 $query->from_request(\%params);
36 if(%params) {
37 my $result = $search->do_search($query);
38 my @results;
40 while(my $r = $result->next_result) {
41 my $image_id = $r->[0];
43 my $image_description = $r->[2];
44 if( length($image_description) < 1 ) {
45 $image_description = "---";
48 my $image_filename = $r->[3];
49 my $submitter_id = $r->[4];
51 my $submitter_first = $r->[5];
52 if( length($submitter_first) < 1 ) {
53 $submitter_first = "---";
56 my $submitter_last = $r->[6];
57 if( length($submitter_last) < 1 ) {
58 $submitter_last = "---";
61 # Put all submitter data in one variable
62 my $submitter_string = "";
64 unless ( $submitter_first eq "---" ) {
65 $submitter_string .= $submitter_first;
66 $submitter_string .= " ";
69 unless ( $submitter_last eq "---" ) {
70 $submitter_string .= $submitter_last;
73 # Image id, image filename, and submitter id can't be null, but everything else can be.
75 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>'];
78 #build the HTML to output
79 my $pagination_html = $search->pagination_buttons_html( $query, $result );
82 my $results_html = <<EOH;
83 <div id="searchresults">
84 EOH
86 $results_html .= columnar_table_html(headings => ['Image Description',
87 'Image Filename',
88 'Submitter (ID) Name'],
89 data => \@results,
92 $results_html .= <<EOH;
93 </div>
94 $pagination_html
95 EOH
98 if (@results) {
99 print blue_section_html('Image search results', ,sprintf('<span class="paginate_summary">%s matches </span>', $result->total_results,$result->time),$results_html);
100 }else {
101 print '<h4>No matches found</h4>';
104 print info_section_html(title => 'Search again',
105 contents =>CXGN::Search::CannedForms::image_search_form($page,$query)
112 $page->footer();
114 #############