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

Annotation of /FigWebServices/frame.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (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 : paczian 1.6
54 :     # check if the user directory exists, else create it
55 : disz 1.5 mkdir USER_DIR, 0777 unless (-e USER_DIR);
56 :    
57 : olson 1.1 # initialize content variables
58 :     my $document_base = "./Html/";
59 : olson 1.2 my $image_base = $document_base;
60 : olson 1.1 my $configuration = "";
61 :    
62 :     my $title = "";
63 :     my $menu = "";
64 :     my $session = "";
65 :     my $logo = "";
66 :     my $content = "";
67 : paczian 1.3 my $action = "";
68 : olson 1.1
69 : paczian 1.3
70 : olson 1.1 # initialize fig object
71 :     my ($fig, $cgi, $user) = FIG_CGI::init(debug_save => 0,
72 :     debug_load => 0,
73 :     print_params => 0);
74 : paczian 1.3
75 : olson 1.1 # initialize params hash
76 : paczian 1.3 my $params = { document_base => $document_base,
77 :     image_base => $image_base,
78 :     cgi => $cgi,
79 :     fig => $fig,
80 :     fig_disk => FIG_DISK,
81 :     fig_temp => FIG_TEMP,
82 :     fig_organisms => FIG_ORGANISMS,
83 :     fig_extbin => FIG_EXTBIN,
84 :     fig_nr => FIG_NR,
85 :     user_directory => USER_DIR
86 :     };
87 : olson 1.1
88 :     # check for logged in user
89 : olson 1.2 $user = "Guest";
90 : olson 1.1 if (defined($cgi->param("user"))) {
91 :     $user = $cgi->param("user");
92 :     }
93 :     $params->{user} = $user;
94 :    
95 : paczian 1.3 # load configuration
96 :     my $preferences = FigWebServices::SeedComponents::Framework::get_preferences($params);
97 :    
98 :     # set preferences params
99 :     my $preferences_params = { preferences => $preferences,
100 :     user => $user,
101 :     user_directory => USER_DIR };
102 :    
103 :     # check for new user
104 :     unless (exists($preferences->{'framework:start_page'})) {
105 :    
106 :     # set default preferences
107 :     $preferences = get_defaultpreferences($params);
108 :     $preferences_params->{preferences} = $preferences;
109 :    
110 :     # write preferences to file
111 :     FigWebServices::SeedComponents::Framework::set_preferences($preferences_params);
112 :     }
113 :    
114 :     # check for change of preferences
115 :     if (defined($cgi->param("set_startpage"))) {
116 :     $preferences->{'framework:start_page'} = $cgi->param("page");
117 :     FigWebServices::SeedComponents::Framework::set_preferences($preferences_params);
118 :     $content .= FigWebServices::SeedComponents::Framework::get_message("You have successfully set your startpage to this page.");
119 :     } elsif (defined($cgi->param("config"))) {
120 :     $preferences->{'framework:menu_layout'} = $cgi->param("layout");
121 :     FigWebServices::SeedComponents::Framework::set_preferences($preferences_params);
122 :     $content .= FigWebServices::SeedComponents::Framework::get_message("You have successfully changed your settings");
123 :     }
124 :    
125 :     # set configuration variable
126 :     $configuration = $preferences->{'framework:menu_layout'};
127 :    
128 :     # set background information for all forms to post
129 :     $params->{background_information} = "<input type='hidden' name='user' value='" . $user . "'>";
130 :    
131 :     # store user preferences
132 :     $params->{user_preferences} = $preferences;
133 :    
134 :     # create configuration button
135 :     my $config_button = qq~<td id='login'><img src="~ . $params->{image_base} . qq~config.gif" onclick="go_configmode();" class="login"></td>~;
136 :    
137 : paczian 1.6 # check for action, otherwise set action to startpage
138 :     if (defined($cgi->param("action"))) {
139 :     $action = $cgi->param("action");
140 :     } else {
141 :    
142 :     # workaround for links to the protein page to pipe through frame.cgi
143 :     if (defined($cgi->param("prot"))) {
144 :     $action = "proteinpage";
145 :     } else {
146 :     $action = $params->{user_preferences}->{'framework:start_page'};
147 :     }
148 :     }
149 :     $params->{action} = $action;
150 :    
151 : paczian 1.3 # disable configuration for user Guest
152 :     if ($user eq "Guest") {
153 :     $config_button = "";
154 :     }
155 : paczian 1.6
156 : olson 1.1 # set session html
157 :     $session = qq~
158 :     <form method='post' action='frame.cgi' name='login_form'>
159 :     <table width=100%>
160 : paczian 1.6 <tr><td colspan=3 style="border-top: 1px solid lightblue;"></td></tr>
161 : olson 1.1 <tr style="vertical-align: bottom;">
162 : paczian 1.6 <td width='40px' height='28px'><b>User:</b></td><td width='100%'><input type='text' name='user' value='~ . $user . qq~' style="width: 100px;">~;
163 :    
164 :     # store current cgi
165 :     my @old_cgi;
166 :     my @names = $cgi->param;
167 :     foreach my $name (@names) {
168 :     unless (($name eq "layout") or ($name eq "config")) {
169 :     push(@old_cgi, { 'preserve_name' => $name, 'preserve_value' => $cgi->param($name) } );
170 :    
171 :     # store current params in login form
172 :     unless ($name eq "user") {
173 :     $session .= "<input type='hidden' name='" . $name . "' value='" . $cgi->param($name) . "'>";
174 :     }
175 :     }
176 :     }
177 :    
178 :     # finish session html
179 :     $session .= qq~</td>~ . $config_button . qq~
180 : olson 1.1 </tr>
181 :     </table>
182 :     </form>
183 :     ~;
184 :    
185 : paczian 1.3 #################
186 :     # Modify this section to add new actions
187 :     #################
188 : olson 1.1
189 :    
190 :     # process current action
191 : paczian 1.3 if ($action eq "welcome") {
192 :     $content .= FigWebServices::SeedComponents::Framework::get_welcome($params);
193 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
194 :     } elsif ($action eq "overview") {
195 :     $content .= FigWebServices::SeedComponents::Framework::get_overview($params);
196 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
197 :     } elsif ($action eq "show_organism") {
198 :     if ($cgi->param("organism_action") eq "statistics") {
199 :     $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~'">~;
200 :     } else {
201 :     $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~'">~;
202 :     }
203 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
204 :     } elsif ($action eq "align_sequences") {
205 :     $content .= FigWebServices::SeedComponents::Framework::get_alignsequences($params);
206 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
207 :     } elsif ($action eq "funcrole_candidates") {
208 :     $content .= FigWebServices::SeedComponents::Framework::get_funcrolecandidates($params);
209 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
210 :     } elsif ($action eq "locate_pegs") {
211 :     $content .= FigWebServices::SeedComponents::Framework::get_locatepegs($params);
212 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
213 :     } elsif ($action eq "export_assignments") {
214 :     $content .= FigWebServices::SeedComponents::Framework::get_exportassignments($params);
215 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
216 :     } elsif ($action eq "process_assignments") {
217 :     $content .= FigWebServices::SeedComponents::Framework::get_processassignments($params);
218 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
219 :     } elsif ($action eq "execute_blast") {
220 :     $content .= FigWebServices::SeedComponents::Basic::get_blastresult($params);
221 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
222 :     } elsif ($action eq "proteinpage") {
223 :     my ($main, $functions) = FigWebServices::SeedComponents::Protein::get_proteinpage($params);
224 :     $content .= $main;
225 :     $menu .= $functions;
226 : olson 1.1 }
227 :    
228 :     # generate common content
229 : paczian 1.3 $title .= FigWebServices::SeedComponents::Framework::get_title($params);
230 :     $logo .= FigWebServices::SeedComponents::Framework::get_logo($params);
231 :     $menu .= FigWebServices::SeedComponents::Framework::get_menu($params);
232 :    
233 : olson 1.1 # create output template
234 :     my $template = HTML::Template->new(filename => TEMPLATE_PATH . 'frame.tmpl');
235 :    
236 :     # insert content into template
237 :     $template->param(document_base => $document_base);
238 :     $template->param(image_base => $image_base);
239 :     $template->param(configuration => $configuration);
240 :     $template->param(title => $title);
241 :     $template->param(menu => $menu);
242 :     $template->param(session => $session);
243 :     $template->param(logo => $logo);
244 :     $template->param(content => $content);
245 : paczian 1.3 $template->param(preserve => \@old_cgi);
246 : olson 1.1
247 :     # output the page
248 :     print header();
249 :     print $template->output();
250 :     }
251 : paczian 1.3
252 :     sub get_defaultpreferences {
253 :     my ($params) = @_;
254 :    
255 :     my $preferences = {};
256 :    
257 :     $preferences->{'framework:start_page'} = "welcome";
258 : paczian 1.6 $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,0;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;similarities_table,group,1,1,1,1,1,1,1,1,1,1,1;";
259 : paczian 1.3 $preferences->{'framework:sort_subsystem'} = "by_phylo";
260 :     $preferences->{'framework:show_clusters_subsystem'} = "1";
261 :    
262 :     return $preferences;
263 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3