add POD to SGN::Exception
[sgn.git] / mason / phenome / print_images.mas
bloba30d0f552a77ec66bd21f86c6c1d252bc5deb26d
3 <%doc>
5 =head1 NAME
7 /phenome/print_images.mas - a component for printing images associated with your favorite objects (locus, accession etc.)
9 =head1 DESCRIPTION
12 Requires the following javascript classes:
13 <& /util/import_javascript.mas, classes => ["jquery", "thickbox", "CXGN.Page.FormattingHelpers"] &>
15 Parameters:
17 =over 2
19 =item images
21 arrayref of image ids 
23 =item dbh
25 dstabase handle (for instantiating new SGN::Image objects)
27 =back
29 =head1 AUTHOR
31 Naama Menda <nm249@cornell.edu>
33 =cut 
35 </%doc>
37 <%args>
39 $images
40 $dbh
42 </%args>
44 <%perl>
46 use CXGN::Page::FormattingHelpers qw / html_optional_show /;
47 use SGN::Image;
49 my $image_html     = "";
50 my $m_image_html   = "";
51 my $count;
52 my @more_is;
54 if (@$images) {    # don't display anything for empty list of images
55   $image_html .= qq|<table cellpadding="5">|;
56   foreach my $image_id (@$images) {
57             $count++;
58             my $image = SGN::Image->new($dbh, $image_id);
59             my $image_name        = $image->get_name();
60             my $image_description = $image->get_description();
61             my $image_img  = $image->get_image_url("medium");
62             my $small_image = $image->get_image_url("thumbnail");
63             my $image_page  = "/image/index.pl?image_id=$image_id";
65             my $thickbox =
66 qq|<a href="$image_img"  title="<a href=$image_page>Go to image page ($image_name)</a>" class="thickbox" rel="gallery-figures"><img src="$small_image" alt="$image_description" /></a> |;
67             my $fhtml =
68               qq|<tr><td width=120>|
69                 . $thickbox
70                   . $image_name
71                     . "</td><td>"
72                       . $image_description
73                         . "</td></tr>";
74             if ( $count < 3 ) { $image_html .= $fhtml; }
75             else {
76               push @more_is, $fhtml;
77             }    #more than 3 figures- show these in a hidden div
78           }
79   $image_html .= "</table>";  #close the table tag or the first 3 figures
81 $m_image_html .=
82   "<table cellpadding=5>";  #open table tag for the hidden figures #4 and on
83 my $more = scalar(@more_is);
84 foreach (@more_is) { $m_image_html .= $_; }
86 $m_image_html .= "</table>";    #close tabletag for the hidden figures
88 if (@more_is) {    #html_optional_show if there are more than 3 figures
89   $image_html .= html_optional_show(
90                                     "Images",
91                                     "<b>See $more more images...</b>",
92                                     qq| $m_image_html |,
93                                     0, #< do not show by default
94                                     'abstract_optional_show', #< don't use the default button-like style
95                                    );
98 </%perl>
101 <% $image_html %>