check if image has already been stored in database. closes #677
[sgn.git] / cgi-bin / search / library_search.pl
blob72a012fb3236b20f35d4c89d58eb1c73053623aa
1 ######################################################################
3 # Search the library database and display the results.
5 # Adapted to the search framework by Evan Herbst, 1 / 14 / 07
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::Library;
16 my $page=CXGN::Page->new("EST library search results", "Evan");
17 $page->header();
19 print page_title_html('Library search results');
21 #create the search and query objects
22 my $search = CXGN::Searches::Library->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 $query->from_request(\%params);
30 if(%params)
32 my $result = $search->do_search($query); #execute the search
33 my @results;
34 while(my $r = $result->next_result())
36 #fields in result objs appear in the order in which they're registered with has_parameter() in the query class
37 push @results, ["<a href=\"/content/library_info.pl?library=" . $r->[2] . "\">" . $r->[2] . "</a>", "<i>" . $r->[8] . "</i>", $r->[7], $r->[3]];
40 #build the HTML to output
41 my $pagination_html = $search->pagination_buttons_html($query, $result);
43 my $results_html = <<EOH;
44 <div id="searchresults">
45 EOH
47 $results_html .= columnar_table_html(headings => ['Name', 'Organism', 'Tissue', 'Development Stage'],
48 data => \@results, __alt_freq => 2);
50 $results_html .= <<EOH;
51 </div>
52 $pagination_html
53 EOH
55 if(@results)
57 print blue_section_html('Results', , sprintf('<span class="paginate_summary">%s matches </span>', $result->total_results(), $result->time), $results_html);
59 else
61 print '<span class=""><h4>No matches found</h4></span>';
63 print info_section_html(title => 'Search again', contents =>CXGN::Search::CannedForms::library_search_form($page, $query));
66 $page->footer();