[Bio] / FigWebServices / frame.cgi Repository:
ViewVC logotype

Annotation of /FigWebServices/frame.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (view) (download)

1 : olson 1.1 ##################################################
2 :     # includes
3 :     ##################################################
4 :     use warnings;
5 :     use strict;
6 :    
7 :     use CGI qw(:standard);
8 :     use HTML::Template;
9 : paczian 1.3 use Data::Dumper;
10 : olson 1.1
11 :     use FIG;
12 :     use FIG_Config;
13 :     use FIG_CGI;
14 : paczian 1.3 use UserData;
15 : olson 1.1
16 : olson 1.2 use FigWebServices::SeedComponents;
17 : olson 1.1
18 :     ##################################################
19 :     # handle exceptions
20 :     ##################################################
21 :    
22 :     eval {
23 :     &main();
24 :     };
25 :    
26 :     if($@) {
27 :     print header(),start_html();
28 : paczian 1.3 print STDERR "EXCEPTION: $@\n";
29 :     print "EXCEPTION: $@\n",end_html();
30 : olson 1.1 }
31 :    
32 :     1;
33 :    
34 :     ##################################################
35 :     # main subroutine
36 :     ##################################################
37 :    
38 :     sub main {
39 :    
40 : paczian 1.3 # set environment variables
41 :     if (! $ENV{"BLASTMAT"}) { $ENV{"BLASTMAT"} = "$FIG_Config::blastmat" }
42 :    
43 : olson 1.1 # constant variables
44 : olson 1.2 use constant DOCUMENT_ROOT => "$FIG_Config::fig/CGI/Html/";
45 : olson 1.1 use constant TEMPLATE_PATH => DOCUMENT_ROOT;
46 : paczian 1.3 use constant USER_DIR => "$FIG_Config::global/Users/";
47 :     use constant FIG_DISK => "$FIG_Config::fig_disk/";
48 :     use constant FIG_TEMP => "$FIG_Config::temp/";
49 :     use constant FIG_ORGANISMS => "$FIG_Config::organisms/";
50 :     use constant FIG_EXTBIN => "$FIG_Config::ext_bin/";
51 :     use constant FIG_NR => "$FIG_Config::global/nr";
52 : olson 1.1
53 :     # initialize content variables
54 :     my $document_base = "./Html/";
55 : olson 1.2 my $image_base = $document_base;
56 : olson 1.1 my $configuration = "";
57 :    
58 :     my $title = "";
59 :     my $menu = "";
60 :     my $session = "";
61 :     my $logo = "";
62 :     my $content = "";
63 : paczian 1.3 my $action = "";
64 : olson 1.1
65 : paczian 1.3
66 : olson 1.1 # initialize fig object
67 :     my ($fig, $cgi, $user) = FIG_CGI::init(debug_save => 0,
68 :     debug_load => 0,
69 :     print_params => 0);
70 : paczian 1.3
71 : olson 1.1 # initialize params hash
72 : paczian 1.3 my $params = { document_base => $document_base,
73 :     image_base => $image_base,
74 :     cgi => $cgi,
75 :     fig => $fig,
76 :     fig_disk => FIG_DISK,
77 :     fig_temp => FIG_TEMP,
78 :     fig_organisms => FIG_ORGANISMS,
79 :     fig_extbin => FIG_EXTBIN,
80 :     fig_nr => FIG_NR,
81 :     user_directory => USER_DIR
82 :     };
83 : olson 1.1
84 :     # check for logged in user
85 : olson 1.2 $user = "Guest";
86 : olson 1.1 if (defined($cgi->param("user"))) {
87 :     $user = $cgi->param("user");
88 :     }
89 :     $params->{user} = $user;
90 :    
91 : paczian 1.3 # load configuration
92 :     my $preferences = FigWebServices::SeedComponents::Framework::get_preferences($params);
93 :    
94 :     # set preferences params
95 :     my $preferences_params = { preferences => $preferences,
96 :     user => $user,
97 :     user_directory => USER_DIR };
98 :    
99 :     # check for new user
100 :     unless (exists($preferences->{'framework:start_page'})) {
101 :    
102 :     # set default preferences
103 :     $preferences = get_defaultpreferences($params);
104 :     $preferences_params->{preferences} = $preferences;
105 :    
106 :     # write preferences to file
107 :     FigWebServices::SeedComponents::Framework::set_preferences($preferences_params);
108 :     }
109 :    
110 :     # check for change of preferences
111 :     if (defined($cgi->param("set_startpage"))) {
112 :     $preferences->{'framework:start_page'} = $cgi->param("page");
113 :     FigWebServices::SeedComponents::Framework::set_preferences($preferences_params);
114 :     $content .= FigWebServices::SeedComponents::Framework::get_message("You have successfully set your startpage to this page.");
115 :     } elsif (defined($cgi->param("config"))) {
116 :     $preferences->{'framework:menu_layout'} = $cgi->param("layout");
117 :     FigWebServices::SeedComponents::Framework::set_preferences($preferences_params);
118 :     $content .= FigWebServices::SeedComponents::Framework::get_message("You have successfully changed your settings");
119 :     }
120 :    
121 :     # set configuration variable
122 :     $configuration = $preferences->{'framework:menu_layout'};
123 :    
124 :     # set background information for all forms to post
125 :     $params->{background_information} = "<input type='hidden' name='user' value='" . $user . "'>";
126 :    
127 :     # store user preferences
128 :     $params->{user_preferences} = $preferences;
129 :    
130 :     # create configuration button
131 :     my $config_button = qq~<td id='login'><img src="~ . $params->{image_base} . qq~config.gif" onclick="go_configmode();" class="login"></td>~;
132 :    
133 :     # disable configuration for user Guest
134 :     if ($user eq "Guest") {
135 :     $config_button = "";
136 :     }
137 :    
138 : olson 1.1 # set session html
139 :     $session = qq~
140 :     <form method='post' action='frame.cgi' name='login_form'>
141 :     <table width=100%>
142 :     <tr><td colspan=3 style="border-top: 1px solid #000088;"></td></tr>
143 :     <tr style="vertical-align: bottom;">
144 : paczian 1.3 <td width='40px' height='28px'><b>User:</b></td><td width='100%'><input type='text' name='user' value='~ . $user . qq~' style="width: 100px;"></td>~ . $config_button . qq~
145 : olson 1.1 </tr>
146 :     </table>
147 :     </form>
148 :     ~;
149 :    
150 : paczian 1.3 # check for action, otherwise set action to startpage
151 :     if (defined($cgi->param("action"))) {
152 :     $action = $cgi->param("action");
153 :     } else {
154 :    
155 :     # workaround for links to the protein page to pipe through frame.cgi
156 :     if (defined($cgi->param("prot"))) {
157 :     $action = "proteinpage";
158 :     } else {
159 :     $action = $params->{user_preferences}->{'framework:start_page'};
160 :     }
161 : olson 1.2 }
162 : paczian 1.3 $params->{action} = $action;
163 : olson 1.2
164 : paczian 1.3 #################
165 :     # Modify this section to add new actions
166 :     #################
167 : olson 1.1
168 :    
169 :     # process current action
170 : paczian 1.3 if ($action eq "welcome") {
171 :     $content .= FigWebServices::SeedComponents::Framework::get_welcome($params);
172 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
173 :     } elsif ($action eq "overview") {
174 :     $content .= FigWebServices::SeedComponents::Framework::get_overview($params);
175 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
176 :     } elsif ($action eq "show_organism") {
177 :     if ($cgi->param("organism_action") eq "statistics") {
178 :     $content .= qq~<img src="~ . $params->{image_base} . qq~clear.gif" onload="window.top.location='genome_statistics.cgi?genome=~ . $cgi->param("genome") . qq~&user=~ . $user . qq~'">~;
179 :     } else {
180 :     $content .= qq~<img src="~ . $params->{image_base} . qq~clear.gif" onload="window.top.location='genome_statistics.cgi?genome=~ . $cgi->param("genome") . qq~&request=show_subsystems&user=~ . $user . qq~'">~;
181 :     }
182 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
183 :     } elsif ($action eq "align_sequences") {
184 :     $content .= FigWebServices::SeedComponents::Framework::get_alignsequences($params);
185 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
186 :     } elsif ($action eq "funcrole_candidates") {
187 :     $content .= FigWebServices::SeedComponents::Framework::get_funcrolecandidates($params);
188 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
189 :     } elsif ($action eq "locate_pegs") {
190 :     $content .= FigWebServices::SeedComponents::Framework::get_locatepegs($params);
191 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
192 :     } elsif ($action eq "export_assignments") {
193 :     $content .= FigWebServices::SeedComponents::Framework::get_exportassignments($params);
194 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
195 :     } elsif ($action eq "process_assignments") {
196 :     $content .= FigWebServices::SeedComponents::Framework::get_processassignments($params);
197 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
198 :     } elsif ($action eq "execute_blast") {
199 :     $content .= FigWebServices::SeedComponents::Basic::get_blastresult($params);
200 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
201 :     } elsif ($action eq "proteinpage") {
202 :     my ($main, $functions) = FigWebServices::SeedComponents::Protein::get_proteinpage($params);
203 :     $content .= $main;
204 :     $menu .= $functions;
205 : olson 1.1 }
206 :    
207 :     # generate common content
208 : paczian 1.3 $title .= FigWebServices::SeedComponents::Framework::get_title($params);
209 :     $logo .= FigWebServices::SeedComponents::Framework::get_logo($params);
210 :     $menu .= FigWebServices::SeedComponents::Framework::get_menu($params);
211 : olson 1.1
212 : paczian 1.3 # store current cgi
213 :     my @old_cgi;
214 :     my @names = $cgi->param;
215 :     foreach my $name (@names) {
216 :     unless (($name eq "layout") or ($name eq "config")) {
217 :     push(@old_cgi, { 'preserve_name' => $name, 'preserve_value' => $cgi->param($name) } );
218 :     }
219 :     }
220 :    
221 : olson 1.1 # create output template
222 :     my $template = HTML::Template->new(filename => TEMPLATE_PATH . 'frame.tmpl');
223 :    
224 :     # insert content into template
225 :     $template->param(document_base => $document_base);
226 :     $template->param(image_base => $image_base);
227 :     $template->param(configuration => $configuration);
228 :     $template->param(title => $title);
229 :     $template->param(menu => $menu);
230 :     $template->param(session => $session);
231 :     $template->param(logo => $logo);
232 :     $template->param(content => $content);
233 : paczian 1.3 $template->param(preserve => \@old_cgi);
234 : olson 1.1
235 :     # output the page
236 :     print header();
237 :     print $template->output();
238 :     }
239 : paczian 1.3
240 :     sub get_defaultpreferences {
241 :     my ($params) = @_;
242 :    
243 :     my $preferences = {};
244 :    
245 :     $preferences->{'framework:start_page'} = "welcome";
246 : paczian 1.4 $preferences->{'framework:menu_layout'} = "extlinks,element,1,1,blue;intlinks,element,1,1,blue;services,element,1,1,blue;neighborhood,group,1,0,0,1,0,0,1,1,0,0,0,1,1;contig_context,section,0;identicalproteins,section,0;compare_region,section,1;subsystems_connections,section,0;relatedlinks,section,0;proteinfamilies,section,0;identicalproteins_table,group,1,1,1,1,1;proteinfamilies_table,group,1,1,1;subsystems_connections_table,group,1,1,1;relatedlinks_table,group,1,1,1,1,1;";
247 : paczian 1.3 $preferences->{'framework:sort_subsystem'} = "by_phylo";
248 :     $preferences->{'framework:show_clusters_subsystem'} = "1";
249 :    
250 :     return $preferences;
251 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3