added sol100 and chado cvterm pages to validate_all.t
[sgn.git] / lib / CXGN / Page / Simple.pm
blob23ce817b028c994906f900042c2708c88e37693b
2 =head1 NAME
4 CXGN::Page::Simple - a simple page object with fewer dependencies, useful for "standalone" projects
6 =head1 DESCRIPTION
8 This module is similar to CXGN::Page, but does not inherit from CXGN::Scrap, and has fewer dependencies. It is intended for use in "standalone" applications that use the SGN codebase but do not implement all the bells and whistles of the SGN system.
10 =head1 AUTHOR(S)
12 Lukas Mueller <lam87@cornell.edu>
14 =head1 FUNCTIONS
16 This module implements the following functions (a subset of the CXGN::Page functions that are essential for simple web programming):
18 =cut
21 use strict;
23 package CXGN::Page::Simple;
25 use Apache2::Request;
26 use Carp;
27 use base qw/CXGN::Scrap/;
29 =head2 constructor new()
31 Args: none
32 Ret: a CXGN::Page::Simple object
34 =cut
36 sub new {
37 my $class = shift;
38 my $self = bless {}, $class;
39 $self->{request} ||= Apache2::RequestUtil->request;
40 $self->{apache_request} ||= Apache2::Request->instance($self->{request});
41 return $self;
44 =head2 function get_encoded_arguments()
46 Args: a list of parameter names
47 Ret: a list of corresponding values from Apache Request object,
48 encoded in HTML encoding
50 =cut
52 sub get_encoded_arguments {
53 my($self,@items)=@_;
54 return map {HTML::Entities::encode_entities($_,"<>&'\"")} $self->get_arguments(@items);
55 #encoding does not appear to work for foreign characters with umlauts, etc. so we're using this restricted version of the command
58 =head2 get_arguments
60 Gets arguments which are being sent in via GET or POST (doesn\'t matter which). DOES NOT encode the HTML entities in those arguments, so be careful because it IS possible for clients to submit evil HTML, javascript, etc.
62 #Example
63 my($fasta_file)=$scrap->get_arguments("fasta_file");
65 =cut
67 # only use this method if you need unfiltered arguments with weird characters
68 # in them, like passwords and fasta file data. be aware that the user\'s agent
69 # (browser) could be capable of sending ALMOST ANYTHING to you as parameters.
70 # --john
71 sub get_arguments {
72 my($self,@items)=@_;
73 my $apr = $self->{apache_request};
74 return map {
75 my @p = $apr->param($_);
76 if(@p > 1) {
77 carp "WARNING: multiple parameters returned for argument '$_'";
78 \@p
79 } elsif(@p == 1) {
80 $p[0]
81 } else {
84 } @items;
88 =head2 function header()
90 Args: An optional header string
91 Ret: Nothing
92 Side Effects: prints a header to STDOUT
94 =cut
96 sub header {
97 my $self = shift;
98 my $header_string = shift;
100 print <<END_HTML;
102 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
103 <html>
104 <head>
105 <title>
106 $header_string
107 </title>
108 <link rel="stylesheet" href="/documents/inc/sgn.css" type="text/css" />
109 </head>
110 <body>
111 <center>
112 <a name=\"top\"></a>
114 <table summary="" width="800" cellpadding="0" cellspacing="0" border="0">
115 <tr>
116 <td width="35"><a href="/"><img src="/documents/img/sgn_logo_icon.png" border="0" width="30" height="30" /></a></td>
117 <td style="color: gray; font-size:12px; font-weight: bold; vertical-align: middle">$header_string</td></tr>
118 </table>
119 <table summary="" width="800" cellpadding="0" cellspacing="0" border="0">
120 <tr><td>
121 <hr>
123 END_HTML
127 =head2 function footer()
129 Args: none
130 Ret: nothing
131 Side Effects: prints a footer to STDOUT
133 =cut
135 sub footer {
136 print <<END_HEREDOC;
137 </td></tr>
138 <tr><td><hr></td></tr>
139 <tr><td><font color="gray" size="1">Copyright &copy; 2003-2007 <a href="http://sgn.cornell.edu/" class="footer" >Sol Genomics Network</a> and <a class="footer" href="http://www.cornell.edu/">Cornell University</a>.<br />Development of this software was supported by the <a class="footer" href="http://www.nsf.gov/">U.S. National Science Foundation</a>.</td></tr>
140 </table>
141 </center>
142 </body>
143 </html>
144 END_HEREDOC
148 return 1;