Merge pull request #3426 from solgenomics/fix_plot_trials
[sgn.git] / cgi-bin / search / gem_experiment_search.pl
blob5019f2d7e02e9af71331b2f9be9b9b0be986f7e0
1 ######################################################################
3 # Search the expression database and display the results.
5 # Adapted to the search framework by Aureliano Bombarely, 18/01/10
7 ######################################################################
9 use strict;
11 use CXGN::Page;
12 use CXGN::Page::FormattingHelpers qw/blue_section_html info_section_html page_title_html columnar_table_html/;
13 use CXGN::Search::CannedForms;
14 use CXGN::Searches::GemExperiment;
16 my $page=CXGN::Page->new("Expression search results by experiment", "Aure");
17 $page->header();
19 print page_title_html('Expression search results by experiment');
21 #create the search and query objects
22 my $search = CXGN::Searches::GemExperiment->new();
23 my $query = $search->new_query();
24 $search->page_size(20); #results shown per page
26 #get the parameters
27 my %params = $page->get_all_encoded_arguments();
28 my @keys = keys %params;
29 my @values = values %params;
32 $query->from_request(\%params);
34 if(%params)
36 my $result = $search->do_search($query); #execute the search
37 my @results;
39 while(my $r = $result->next_result())
41 #fields in result objs appear in the order in which they're registered with has_parameter() in the query class
42 push @results, ["<a href=\"/gem/experimental_design.pl?id=" . $r->[2] . "\">" . $r->[3] . "</a>",
43 "<a href=\"/gem/experiment.pl?id=" . $r->[0] . "\">" . $r->[1] . "</a>" ];
46 #build the HTML to output
47 my $pagination_html = $search->pagination_buttons_html($query, $result);
49 my $results_html = <<EOH;
50 <div id="searchresults">
51 EOH
53 $results_html .= columnar_table_html(headings => ['Experimental Design', 'Experiment'],
54 data => \@results, __alt_freq => 2);
56 $results_html .= <<EOH;
57 </div>
58 $pagination_html
59 EOH
61 if(@results)
63 print blue_section_html('Results', , sprintf('<span class="paginate_summary">%s matches </span>', $result->total_results(), $result->time), $results_html);
65 else
67 print '<span class=""><h4>No matches found</h4></span>';
69 print info_section_html(title => 'Search again', contents =>CXGN::Search::CannedForms::expr_experiment_search_form($page, $query));
72 $page->footer();