[Bio] / SubsystemEditor / WebPage / ShowSubsystem.pm Repository:
ViewVC logotype

Annotation of /SubsystemEditor/WebPage/ShowSubsystem.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.33 - (view) (download) (as text)

1 : bartels 1.1 package SubsystemEditor::WebPage::ShowSubsystem;
2 :    
3 :     use strict;
4 :     use warnings;
5 :     use URI::Escape;
6 :     use HTML;
7 :     use Data::Dumper;
8 :    
9 :     use FIG;
10 :    
11 :     use base qw( WebPage );
12 :    
13 :     1;
14 :    
15 : bartels 1.2 ##############################################################
16 :     # Method for registering components etc. for the application #
17 :     ##############################################################
18 : bartels 1.1 sub init {
19 :     my ( $self ) = @_;
20 :    
21 : bartels 1.2 $self->application->register_component( 'Table', 'sstable' );
22 : bartels 1.12 $self->application->register_component( 'Table', 'VarDescTable' );
23 : bartels 1.2 }
24 :    
25 :     #################################
26 :     # File where Javascript resides #
27 :     #################################
28 :     sub require_javascript {
29 :    
30 :     return [ './Html/showfunctionalroles.js' ];
31 :    
32 : bartels 1.1 }
33 :    
34 :     ##############################################
35 :     # Website content is returned by this method #
36 :     ##############################################
37 :     sub output {
38 :     my ( $self ) = @_;
39 : bartels 1.2
40 : bartels 1.25 my $fig = $self->application->data_handle( 'FIG' );
41 : bartels 1.1 my $cgi = $self->application->cgi;
42 :    
43 : bartels 1.2 # subsystem name and 'nice name' #
44 : bartels 1.1 my $name = $cgi->param( 'subsystem' );
45 : bartels 1.27 $name = uri_unescape( $name );
46 :     $name =~ s/&#39/'/g;
47 : bartels 1.1 my $ssname = $name;
48 :     $ssname =~ s/\_/ /g;
49 :    
50 : bartels 1.2 # look if someone is logged in and can write the subsystem #
51 :     my $can_alter = 0;
52 :     my $user = $self->application->session->user;
53 : bartels 1.4
54 : paczian 1.22 my $dbmaster = $self->application->dbmaster;
55 :     my $ppoapplication = $self->application->backend;
56 : bartels 1.4
57 :     # get a seeduser #
58 :     my $seeduser = '';
59 :     if ( defined( $user ) && ref( $user ) ) {
60 :     my $preferences = $dbmaster->Preferences->get_objects( { user => $user,
61 :     name => 'SeedUser',
62 :     application => $ppoapplication } );
63 :     if ( defined( $preferences->[0] ) ) {
64 :     $seeduser = $preferences->[0]->value();
65 :     }
66 :     }
67 :    
68 : bartels 1.6 if ( $user ) {
69 :     if ( $user->has_right( $self->application, 'edit', 'subsystem', $name ) ) {
70 :     $can_alter = 1;
71 :     $fig->set_user( $seeduser );
72 :     }
73 :     else {
74 :     # we might have the problem that the user has not yet got the right for editing the
75 :     # subsystem due to that it was created in the old seed or what do I know where.
76 :     my $curatorOfSS = $fig->subsystem_curator( $name );
77 : bartels 1.7 my $su = lc( $seeduser );
78 :     my $cu = lc( $curatorOfSS );
79 :     if ( $su eq $cu ) {
80 : bartels 1.6 # now set the rights...
81 :     my $right = $dbmaster->Rights->create( { name => 'edit',
82 :     scope => $user->get_user_scope,
83 :     data_type => 'subsystem',
84 :     data_id => $name,
85 :     granted => 1,
86 :     delegated => 0 } );
87 :     if ( $right ) {
88 :     $can_alter = 1;
89 :     $fig->set_user( $seeduser );
90 :     }
91 :     }
92 :     }
93 : bartels 1.2 }
94 : bartels 1.6
95 : bartels 1.1 ######################
96 :     # Construct the menu #
97 :     ######################
98 :    
99 :     my $menu = $self->application->menu();
100 :    
101 : bartels 1.15 my $esc_name = uri_escape($name);
102 :    
103 : bartels 1.1 # Build nice tab menu here
104 : bartels 1.15 $menu->add_category( 'Subsystem Info', "SubsysEditor.cgi?page=ShowSubsystem&subsystem=$esc_name" );
105 :     $menu->add_category( 'Functional Roles', "SubsysEditor.cgi?page=ShowFunctionalRoles&subsystem=$esc_name" );
106 : bartels 1.21 $menu->add_category( 'Subsets', "SubsysEditor.cgi?page=ShowSubsets&subsystem=$esc_name" );
107 : bartels 1.15 $menu->add_category( 'Diagram', "SubsysEditor.cgi?page=ShowDiagram&subsystem=$esc_name" );
108 :     $menu->add_category( 'Illustrations', "SubsysEditor.cgi?page=ShowIllustrations&subsystem=$esc_name" );
109 :     $menu->add_category( 'Spreadsheet', "SubsysEditor.cgi?page=ShowSpreadsheet&subsystem=$esc_name" );
110 :     $menu->add_category( 'Show Check', "SubsysEditor.cgi?page=ShowCheck&subsystem=$esc_name" );
111 :     $menu->add_category( 'Show Connections', "SubsysEditor.cgi?page=ShowTree&subsystem=$esc_name" );
112 : bartels 1.1
113 :    
114 :     ##############################
115 :     # Construct the page content #
116 :     ##############################
117 :    
118 : bartels 1.2 my $content = qq~
119 :     <STYLE>
120 :     .hideme {
121 :     display: none;
122 :     }
123 :     .showme {
124 :     display: all;
125 :     }
126 :     </STYLE>
127 :     ~;
128 :    
129 :     $content .= "<H2>Subsystem Info</H2>";
130 :     my $subsystem = new Subsystem( $name, $fig, 0 );
131 :    
132 :     if ( defined( $cgi->param( 'SUBMIT' ) ) ) {
133 :    
134 :     # set description and notes
135 :     my $descrp = $cgi->param( 'SSDESC' );
136 :     chomp $descrp;
137 :     $descrp .= "\n";
138 :     $subsystem->set_description( $descrp );
139 :     my $notes = $cgi->param( 'SSNOTES' );
140 :     chomp $notes;
141 :     $notes .= "\n";
142 :     $subsystem->set_notes( $notes );
143 :    
144 :     my $class1 = '';
145 :     my $class2 = '';
146 :    
147 :     if ( defined( $cgi->param( 'Classification' ) ) ) {
148 :     if ( $cgi->param( 'Classification' ) eq 'User-defined' ) {
149 :     if ( defined( $cgi->param( "SUBSYSH1TF" ) ) ) {
150 :     $class1 = $cgi->param( "SUBSYSH1TF" );
151 :     }
152 :     }
153 :     else {
154 :     if ( defined( $cgi->param( "SUBSYSH1" ) ) ) {
155 :     $class1 = $cgi->param( "SUBSYSH1" );
156 :     }
157 :     }
158 :     }
159 :    
160 :     if ( defined( $cgi->param( 'Classification' ) ) ) {
161 :     if ( $cgi->param( 'Classification' ) eq 'User-defined' ) {
162 :     if ( defined( $cgi->param( "SUBSYSH2TF" ) ) ) {
163 :     $class2 = $cgi->param( "SUBSYSH2TF" );
164 :     }
165 :     }
166 :     else {
167 :     if ( defined( $cgi->param( "SUBSYSH2" ) ) ) {
168 :     $class2 = $cgi->param( "SUBSYSH2" );
169 :     }
170 :     }
171 :     }
172 :     $subsystem->set_classification( [ $class1, $class2 ] );
173 :    
174 : bartels 1.10 my $litstoset = $cgi->param( 'SUBSYSLIT' );
175 : bartels 1.23 $litstoset =~ s/ //g;
176 :     my @lits = split( ',', $litstoset );
177 : bartels 1.10 setLiteratures( $fig, $name, \@lits );
178 :    
179 : bartels 1.13 my $wlstoset = $cgi->param( 'SUBSYSWL' );
180 :     if ( defined( $wlstoset ) && $wlstoset =~ /.+\s+.+/ ) {
181 :     my @wls = split( '\n', $wlstoset );
182 :     setWeblinks( $fig, $name, \@wls );
183 :     }
184 :    
185 : bartels 1.2 # here we really edit the files in the subsystem directory #
186 :     $subsystem->incr_version();
187 :     $subsystem->db_sync();
188 :     $subsystem->write_subsystem();
189 :     }
190 : bartels 1.25 elsif ( defined( $cgi->param( 'GrantRightButton' ) ) ) {
191 :     if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) ) {
192 : paczian 1.31 my ($newAnno, $readable_name) = split(/\|/, $cgi->param( 'ANNOBOX' ));
193 : paczian 1.29 my $thisScopes = $dbmaster->Scope->get_objects( { _id => $newAnno } );
194 :     if ( defined( $thisScopes->[0]) ) {
195 : bartels 1.27
196 : bartels 1.25 my $rights = $dbmaster->Rights->get_objects( { name => 'edit',
197 :     data_type => 'subsystem',
198 :     data_id => $name,
199 : paczian 1.29 scope => $thisScopes->[0] } );
200 : bartels 1.25 if ( defined( $rights->[0] ) ) {
201 : paczian 1.29 $self->application->add_message( 'warning', "$readable_name already has the right to edit this subsystem." );
202 : bartels 1.25 }
203 :     else {
204 :     my $right = $dbmaster->Rights->create( { granted => 1,
205 :     delegated => 1,
206 :     name => 'edit',
207 :     data_type => 'subsystem',
208 :     data_id => $name,
209 : paczian 1.29 scope => $thisScopes->[0] } );
210 : bartels 1.25 if ( $right ) {
211 : paczian 1.29 $self->application->add_message( 'info', "$readable_name can now edit this subsystem" );
212 : bartels 1.25 }
213 :     else {
214 : paczian 1.29 $self->application->add_message( 'warning', "Could not create right to edit the subsystem for $readable_name" );
215 : bartels 1.25 }
216 :     }
217 :     }
218 :     }
219 :     else {
220 :     $self->application->add_message( 'warning', "You do not have the right to share the subsystem." );
221 :     }
222 :     }
223 :     elsif ( defined( $cgi->param( 'RevokeRightButton' ) ) ) {
224 :     if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) ) {
225 : paczian 1.31 my ($newAnno, $readable_name) = split(/\|/, $cgi->param( 'ALANNOBOX' ));
226 : paczian 1.29 my $thisScopes = $dbmaster->Scope->get_objects( { _id => $newAnno } );
227 : bartels 1.25 my $rights = $dbmaster->Rights->get_objects( { name => 'edit',
228 :     data_type => 'subsystem',
229 :     data_id => $name,
230 : paczian 1.29 scope => $thisScopes->[0] } );
231 : bartels 1.25
232 :     my $thisRight = $rights->[0];
233 : paczian 1.33 if ( defined( $thisRight ) && $thisRight->delegated ) {
234 : bartels 1.25 $thisRight->delete();
235 :    
236 : paczian 1.29 $self->application->add_message( 'info', "$readable_name cannot edit this subsystem any more." );
237 : bartels 1.25 }
238 :     else {
239 : paczian 1.29 $self->application->add_message( 'warning', "You can't revoke the right of $readable_name to edit this subsystem." );
240 : bartels 1.25 }
241 :     }
242 :     else {
243 :     $self->application->add_message( 'warning', "You do not have the right to revoke rights for this subsystem." );
244 :     }
245 :     }
246 : bartels 1.1
247 : bartels 1.2 $subsystem = new Subsystem( $name, $fig, 0 );
248 :    
249 :     $content .= $self->start_form( 'form', { subsystem => $name } );
250 :    
251 : bartels 1.1 my ( $ssversion, $sscurator, $pedigree, $ssroles ) = $fig->subsystem_info( $name );
252 : bartels 1.3
253 :     my $versionlink = '';
254 : bartels 1.5
255 : bartels 1.3 if ( $can_alter ) {
256 : bartels 1.16 $versionlink = " -- <A HREF='".$self->application->url()."?page=ResetSubsystem&subsystem=$esc_name'>Reset to Previous Timestamp</A>";
257 : bartels 1.3 }
258 :    
259 : bartels 1.1 my $mod_time = get_mod_time( $name );
260 :     my $class = $fig->subsystem_classification( $name );
261 :     my $ssnotes = $subsystem->get_notes();
262 :    
263 : bartels 1.2 if ( !defined( $ssnotes ) ) {
264 :     $ssnotes = '';
265 :     }
266 :     my $ssdesc = $subsystem->get_description();
267 :    
268 :     if ( !defined( $ssdesc ) ) {
269 :     $ssdesc = '';
270 :     }
271 :    
272 :     my $classification_stuff;
273 :     if ( $can_alter ) {
274 :     $classification_stuff = get_classification_boxes( $fig, $cgi, $class->[0], $class->[1] );
275 :     }
276 :     else {
277 :     $classification_stuff = "<TR><TH>Classification:</TH><TD>$class->[0]</TD></TR>";
278 :     $classification_stuff .= "<TR><TH></TH><TD>$class->[1]</TD></TR>";
279 :     }
280 : bartels 1.1
281 : bartels 1.11 my $infotable = "<TABLE><TR><TH>Name:</TH><TD>$ssname</TD></TR>";
282 : bartels 1.1 $infotable .= "<TR><TH>Author:</TH><TD>$sscurator</TD></TR>";
283 : paczian 1.28 if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) && !$self->application->{anonymous_mode}) {
284 : bartels 1.25
285 :     my $annoGrp = $dbmaster->Scope->get_objects( { name => 'Annotators' } );
286 :     my $annoScope = $dbmaster->UserHasScope->get_objects( { scope => $annoGrp->[0] } );
287 :     my $annoMems = [];
288 :     foreach my $aS ( @$annoScope ) {
289 :     push @$annoMems, $aS->user();
290 :     }
291 :     @$annoMems = sort { $a->lastname cmp $b->lastname || $a->firstname cmp $b->firstname } @$annoMems;
292 :    
293 :     my $editRightButton = "<INPUT TYPE=SUBMIT ID='GrantRightButton' NAME='GrantRightButton' VALUE='Grant Right'>";
294 :     my $revokeRightButton = "<INPUT TYPE=SUBMIT ID='RevokeRightButton' NAME='RevokeRightButton' VALUE='Revoke Right'>";
295 :    
296 : paczian 1.29 my $user_has_scopes = $dbmaster->UserHasScope->get_objects( { user => $user });
297 : paczian 1.33 my $available_groups = {};
298 :     foreach my $user_has_scope (@$user_has_scopes) {
299 :     my $scope = $user_has_scope->scope();
300 :     next if $scope->name() =~ /^user:/;
301 :     next if $scope->name() =~/^Public/;
302 :     $available_groups->{$scope->{_id}} = $scope;
303 :     }
304 :     my $all_ss_edit_rights = $dbmaster->Rights->get_objects( { name => 'edit',
305 :     data_type => 'subsystem',
306 :     data_id => $name } );
307 : paczian 1.29 my $user_groups_have_right = [];
308 :     my $user_groups_not_have_right = [];
309 : paczian 1.33 foreach my $r (@$all_ss_edit_rights) {
310 :     my $scope = $r->scope;
311 : paczian 1.29 next if $scope->name() =~ /^user:/;
312 :     next if $scope->name() =~/^Public/;
313 : paczian 1.33 push(@$user_groups_have_right, [ $scope->_id, $scope->name ]);
314 :     delete $available_groups->{$scope->{_id}};
315 :     }
316 :     foreach my $key (sort(keys(%$available_groups))) {
317 :     my $scope = $available_groups->{$key};
318 :     push(@$user_groups_not_have_right, [ $scope->_id, $scope->name ]);
319 : paczian 1.29 }
320 :    
321 : bartels 1.25 my $annotatorsBox = "<SELECT NAME='ANNOBOX' ID='ANNOBOX'>";
322 :     my $alreadyAnnotatorsBox = "<SELECT NAME='ALANNOBOX' ID='ALANNOBOX'>";
323 : paczian 1.29 foreach my $a ( @$user_groups_have_right ) {
324 : paczian 1.30 $alreadyAnnotatorsBox .= "<OPTION VALUE='".$a->[0]."|group ".$a->[1]."'>group ".$a->[1]."</OPTION>";
325 : paczian 1.29 }
326 :     foreach my $a ( @$user_groups_not_have_right ) {
327 : paczian 1.30 $annotatorsBox .= "<OPTION VALUE='".$a->[0]."|group ".$a->[1]."'>group ".$a->[1]."</OPTION>";
328 : paczian 1.29 }
329 : bartels 1.25 foreach my $a ( @$annoMems ) {
330 : paczian 1.33 my $r = $dbmaster->Rights->get_objects( { name => 'edit',
331 :     scope => $a->get_user_scope,
332 :     data_type => 'subsystem',
333 :     data_id => $name } );
334 :     unless ( scalar(@$r) ) {
335 : paczian 1.29 $annotatorsBox .= "<OPTION VALUE='".$a->get_user_scope->_id."|".$a->firstname." ".$a->lastname."'>".$a->firstname.' '.$a->lastname.' ( '.$a->login." )</OPTION>";
336 : bartels 1.25 }
337 :     else {
338 :     if ( $a->login() ne $user->login() && ( ! $a->has_right( undef, 'edit', 'subsystem', '*' ) ) ) {
339 : paczian 1.29 $alreadyAnnotatorsBox .= "<OPTION VALUE='".$a->get_user_scope->_id."|".$a->firstname." ".$a->lastname."'>".$a->firstname.' '.$a->lastname.' ( '.$a->login." )</OPTION>";
340 : bartels 1.25 }
341 :     }
342 :     }
343 :     $annotatorsBox .= "</SELECT>";
344 :     $alreadyAnnotatorsBox .= "</SELECT>";
345 :    
346 :     $infotable .= "<TR><TH>Grant Right To Edit To:</TH><TD>$annotatorsBox $editRightButton</TD></TR>";
347 :     $infotable .= "<TR><TH>Revoke Right To Edit From:</TH><TD>$alreadyAnnotatorsBox $revokeRightButton</TD></TR>";
348 :     }
349 : bartels 1.3 $infotable .= "<TR><TH>Version:</TH><TD>$ssversion $versionlink</TD></TR>";
350 : bartels 1.1 $infotable .= "<TR><TH>Last Modified:</TH><TD>$mod_time</TD></TR>";
351 : bartels 1.10
352 : bartels 1.13 # Literature #
353 : bartels 1.10 my $lit = getLiteratures( $fig, $name );
354 :     my $litstring = '';
355 :     my $litvoid = '';
356 :     if ( defined( $lit ) && scalar( @$lit ) > 0 ) {
357 :     my @litlinks;
358 :     foreach my $l ( @$lit ) {
359 :     my $thislink = "<a href=\"javascript:void(0)\"onclick=\"window.open('http://www.ncbi.nlm.nih.gov/sites/entrez?cmd=retrieve&db=pubmed&list_uids=" . $l ."')\">$l</a>";
360 :     push @litlinks, $thislink;
361 :     }
362 :     $litstring = join( ', ', @litlinks );
363 :     $litvoid = join( ', ', @$lit );
364 :     }
365 :    
366 : bartels 1.13 # Weblinks #
367 :     my ( $wl, $wlvoid ) = getLinks( $fig, $name );
368 :    
369 : bartels 1.12 my $variants = $subsystem->get_variants();
370 :    
371 : bartels 1.2 if ( $can_alter ) {
372 : bartels 1.10
373 :     my $editLitButton = "<INPUT TYPE=BUTTON ID='EditLitButton' VALUE='Edit Literature' ONCLICK='MakeEditableLit( \"0\" );'><INPUT TYPE=BUTTON ID='ShowLitButton' VALUE='Show Links' STYLE='display: none;' ONCLICK='MakeEditableLit( \"1\" );'>";
374 : bartels 1.13 my $editWLButton = "<INPUT TYPE=BUTTON ID='EditWLButton' VALUE='Edit Weblinks' ONCLICK='MakeEditableWL( \"0\" );'><INPUT TYPE=BUTTON ID='ShowWLButton' VALUE='Show Weblinks' STYLE='display: none;' ONCLICK='MakeEditableWL( \"1\" );'>";
375 :    
376 : bartels 1.10 $infotable .= "<TR><TH>Literature</TH><TD><TABLE><TR><TD><SPAN ID='LitSpan'>$litstring</SPAN></TD><TD>$editLitButton</TD><TD><INPUT TYPE=TEXT STYLE='width: 200px; display: none;' NAME='SUBSYSLIT' ID='SUBSYSLIT' VALUE='$litvoid'></TD><TD><SPAN ID='TEXTSPAN' STYLE='display: none;'>Multiple PMIDs should be separated by \', \'</SPAN></TD></TR></TABLE></TD></TR>";
377 : bartels 1.13 $infotable .= "<TR><TH>Websites</TH><TD><TABLE><TR><TD><SPAN ID='WLSpan'>$wl</SPAN></TD><TD>$editWLButton</TD><TD><TEXTAREA ROWS=3 STYLE='width: 400px; display: none;' NAME='SUBSYSWL' ID='SUBSYSWL'>$wlvoid</TEXTAREA></TD><TD><SPAN ID='AREASPAN' STYLE='display: none;'>Please use the following format:<BR>Description1 http://www.xyz.org/...<BR>Description2 http://www.xzy.de/...</SPAN></TD></TR></TABLE></TD></TR>";
378 : bartels 1.19 $infotable .= "<TR><TH>Description</TH><TD><TEXTAREA NAME='SSDESC' ROWS=15 STYLE='width: 772px;'>$ssdesc</TEXTAREA></TD></TR>";
379 :     $infotable .= "<TR><TH>Notes</TH><TD><TEXTAREA NAME='SSNOTES' ROWS=15 STYLE='width: 772px;'>$ssnotes</TEXTAREA></TD></TR>";
380 : bartels 1.2 }
381 :     else {
382 :     # do a little formating because the notes often contain many many blanks and newlines
383 :     my $ssdesc_brs = $ssdesc;
384 :     $ssdesc_brs =~ s/\n/<BR>/g;
385 :     $ssdesc_brs =~ s/(\n\s)+/\n/g;
386 :     my $ssnotes_brs = $ssnotes;
387 :     $ssnotes_brs =~ s/(\n\s)+/\n/g;
388 :     $ssnotes_brs =~ s/\n/<BR>/g;
389 : bartels 1.11 $infotable .= "<TR><TH>Literature</TH><TD>$litstring</TD></TR>";
390 : bartels 1.14 $infotable .= "<TR><TH>Websites</TH><TD>$wl</TD></TR>";
391 : bartels 1.2 $infotable .= "<TR><TH>Description</TH><TD>$ssdesc_brs</TD></TR>";
392 :     $infotable .= "<TR><TH>Notes</TH><TD>$ssnotes_brs</TD></TR>";
393 :     }
394 : bartels 1.12 # variants
395 :     my $vartable = $self->application->component( 'VarDescTable' );
396 :     $vartable->columns( [ { name => "Variant" }, { name => "Description" } ] );
397 :    
398 :     my $vardata;
399 :     my $has_variants = 0;
400 :     foreach my $kv ( sort keys %$variants ) {
401 :     $has_variants = 1;
402 :     push @$vardata, [ $kv, $variants->{ $kv } ];
403 :     }
404 :     $vartable->data( $vardata );
405 :     $infotable .= "<TR><TH>Variants</TH><TD>";
406 :     if ( $has_variants ) {
407 :     $infotable .= $vartable->output();
408 :     }
409 :    
410 :     if ( $can_alter ) {
411 :     my $variant_outside = "<INPUT TYPE=BUTTON VALUE='Edit Variants in Variant Overview' NAME='EditVariantsOverview' ID='EditVariantsOverview' ONCLICK='window.open( \"".$self->application->url()."?page=ShowVariants&subsystem=$name\" )'>";
412 :     $infotable .= $variant_outside;
413 :     }
414 :    
415 :     $infotable .= "</TD</TR>";
416 :    
417 : bartels 1.2 $infotable .= $classification_stuff;
418 : bartels 1.1 $infotable .= "</TABLE>";
419 :    
420 : bartels 1.2 if ( $can_alter ) {
421 : bartels 1.20 $infotable .= "<INPUT TYPE=SUBMIT VALUE='Save Changes' ID='SUBMIT' NAME='SUBMIT' STYLE='background-color: red;'>";
422 : bartels 1.2 }
423 :    
424 : bartels 1.20 if ( $can_alter ) {
425 :     $content .= "<INPUT TYPE=SUBMIT VALUE='Save Changes' ID='SUBMIT' NAME='SUBMIT' STYLE='background-color: red;'>";
426 :     }
427 : bartels 1.1 $content .= $infotable;
428 : bartels 1.2 $content .= $self->end_form();
429 : bartels 1.1
430 :     return $content;
431 :     }
432 :    
433 :    
434 :     sub get_mod_time {
435 :    
436 :     my ( $ssa, $fig ) = @_;
437 :    
438 :     my( $t, @spreadsheets );
439 :     if ( opendir( BACKUP, "$FIG_Config::data/Subsystems/$ssa/Backup" ) ) {
440 :    
441 :     @spreadsheets = sort { $b <=> $a }
442 :     map { $_ =~ /^spreadsheet.(\d+)/; $1 }
443 :     grep { $_ =~ /^spreadsheet/ }
444 :     readdir(BACKUP);
445 :     closedir(BACKUP);
446 :    
447 :     if ( $t = shift @spreadsheets ) {
448 :     my $last_modified = &FIG::epoch_to_readable( $t );
449 :     return $last_modified;
450 :     }
451 :     }
452 : bartels 1.2 return "$FIG_Config::data/Subsystems/$ssa/Backup";
453 :     }
454 :    
455 :    
456 :     sub get_classification_boxes {
457 :     my ( $fig, $cgi, $class1, $class2 ) = @_;
458 :     my $classified = 1;
459 :    
460 :     my $sdContent = '';
461 :     my $SUBSYSH1 = $class1;
462 :     my $SUBSYSH2 = $class2;
463 :    
464 :     # variables that monitor if we have selected a box
465 :     my $putinh1 = 0;
466 :     my $putinh2 = 0;
467 :    
468 :     if ( !defined( $SUBSYSH1 ) ){
469 :     $putinh1 = 1;
470 :     }
471 :     if ( !defined( $SUBSYSH2 ) ){
472 :     $putinh2 = 1;
473 :     }
474 :    
475 :     my $inh1 = '';
476 :     if ( defined( $cgi->param( 'SUBSYSH1TF' ) ) ) {
477 :     $inh1 = $cgi->param( 'SUBSYSH1TF' );
478 :     }
479 :     elsif ( defined( $SUBSYSH1 ) ) {
480 :     if ( !$putinh1 ) {
481 :     $inh1 = $SUBSYSH1;
482 :     }
483 :     }
484 :     my $inh2 = '';
485 :     if ( defined( $cgi->param( 'SUBSYSH2TF' ) ) ) {
486 :     $inh2 = $cgi->param( 'SUBSYSH2TF' );
487 :     }
488 :     elsif ( defined( $SUBSYSH2 ) ) {
489 :     if ( !$putinh2 ) {
490 :     $inh2 = $SUBSYSH2;
491 :     }
492 :     }
493 :    
494 :     my @ssclassifications = $fig->all_subsystem_classifications();
495 :     my $ssclass;
496 :     foreach my $ssc ( @ssclassifications ) {
497 : bartels 1.24 if ( !defined( $ssc->[1] ) ) {
498 :     $ssc->[1] = '';
499 :     }
500 :     # next if ( ( !defined( $ssc->[0] ) ) || ( !defined( $ssc->[1] ) ) );
501 :     next if ( !defined( $ssc->[0] ) );
502 :     next if ( $ssc->[0] eq '' );
503 :     # next if ( ( $ssc->[0] eq '' ) || ( $ssc->[1] eq '' ) );
504 : bartels 1.2 next if ( ( $ssc->[0] =~ /^\s+$/ ) || ( $ssc->[1] =~ /^\s+$/ ) );
505 :     push @{ $ssclass->{ $ssc->[0] } }, $ssc->[1];
506 :     }
507 :    
508 :    
509 :     my @options;
510 :     foreach my $firstc ( keys %$ssclass ) {
511 :     my $opt = "<SELECT SIZE=5 ID='$firstc' NAME='SUBSYSH2' STYLE='width: 386px;' class='hideme'>";
512 :     my $optstring = '';
513 :     foreach my $secc ( sort @{ $ssclass->{ $firstc } } ) {
514 : bartels 1.8 if ( defined( $SUBSYSH2 ) && $SUBSYSH2 eq $secc && $SUBSYSH1 eq $firstc ) {
515 : bartels 1.2 $optstring .= "<OPTION SELECTED VALUE='$secc'>$secc</OPTION>";
516 :     # we have to show the selectbox if there is a selected value
517 :     $opt = "<SELECT SIZE=5 ID='$firstc' NAME='SUBSYSH2' STYLE='width: 386px;' class='showme'>";
518 :     $putinh2 = 1;
519 :     }
520 :     else {
521 :     $optstring .= "<OPTION VALUE='$secc'>$secc</OPTION>";
522 :     }
523 :     }
524 :     $opt .= $optstring;
525 :     $opt .= "</SELECT>";
526 :     push @options, $opt;
527 :     }
528 :    
529 :     if ( $classified ) {
530 :     $sdContent .= "<TR><TH><INPUT TYPE=\"RADIO\" NAME=\"Classification\" VALUE=\"Classified\" CHECKED onchange='radioclassification();'>Classification:</TH><TD><SELECT SIZE=5 ID='SUBSYSH1' NAME='SUBSYSH1' STYLE='width: 386px;' onclick='gethiddenoption();'>";
531 :     }
532 :     else {
533 :     $sdContent .= "<TR><TD><INPUT TYPE=\"RADIO\" NAME=\"Classification\" VALUE=\"Classified\" onchange='radioclassification();'>Classification:</TD><TD><SELECT SIZE=5 ID='SUBSYSH1' NAME='SUBSYSH1' STYLE='width: 386px;' onclick='gethiddenoption();' DISABLED=DISABLED>";
534 :     }
535 :     foreach my $firstc ( sort keys %$ssclass ) {
536 :     if ( defined( $SUBSYSH1 ) && $SUBSYSH1 eq $firstc ) {
537 :     $sdContent .= "\n<OPTION SELECTED VALUE='$firstc'>$firstc</OPTION>\n";
538 :     $putinh1 = 1;
539 :     }
540 :     else {
541 :     $sdContent .= "\n<OPTION VALUE='$firstc'>$firstc</OPTION>\n";
542 :     }
543 :     }
544 :     $sdContent .= "</SELECT>";
545 :    
546 :     foreach my $opt ( @options ) {
547 :     $sdContent .= $opt;
548 :     }
549 :    
550 :     $sdContent .= "</TD></TR>";
551 :     if ( $classified ) {
552 :     $sdContent .= "<TR><TH><INPUT TYPE=\"RADIO\" NAME=\"Classification\" VALUE=\"User-defined\" onchange='radioclassification();'>User-defined:</TH><TD><INPUT TYPE=TEXT STYLE='width: 386px;' NAME='SUBSYSH1TF' ID='SUBSYSH1TF' VALUE='' DISABLED=\"DISABLED\"><INPUT TYPE=TEXT STYLE='width: 386px;' NAME='SUBSYSH2TF' ID='SUBSYSH2TF' VALUE='' DISABLED=DISABLED></TD></TR>";
553 :     }
554 :     else {
555 :     $sdContent .= "<TR><TH><INPUT TYPE=\"RADIO\" NAME=\"Classification\" VALUE=\"User-defined\" CHECKED onchange='radioclassification();'>User-defined:</TH><TD><INPUT TYPE=TEXT STYLE='width: 386px;' NAME='SUBSYSH1TF' ID='SUBSYSH1TF' VALUE='$inh1'><INPUT TYPE=TEXT STYLE='width: 386px;' NAME='SUBSYSH2TF' ID='SUBSYSH2TF' VALUE='$inh2'></TD></TR>";
556 :     }
557 :    
558 :    
559 :     return $sdContent;
560 :     }
561 :    
562 : bartels 1.10 ########################################
563 :     # get Literature-string for subsystems #
564 :     ########################################
565 :     sub getLiteratures {
566 :     my ( $fig, $name ) = @_;
567 :    
568 : bartels 1.15 my $esc_name = uri_escape($name);
569 :    
570 : bartels 1.10 my $frpubs;
571 : bartels 1.17 my @rel_lit_num = $fig->get_attributes( 'Subsystem:'.$name, "SUBSYSTEM_PUBMED_RELEVANT" );
572 : bartels 1.10
573 :     foreach my $k ( @rel_lit_num ) {
574 :     my ( $ss, $key, $value ) = @$k;
575 :     push @$frpubs, $value;
576 :     }
577 :    
578 :     return $frpubs;
579 :     }
580 :    
581 : bartels 1.13 ######################################
582 :     # get Weblinks-string for subsystems #
583 :     ######################################
584 :     sub getLinks {
585 :     my ( $fig, $name ) = @_;
586 :    
587 : bartels 1.15 my $esc_name = uri_escape($name);
588 :    
589 : bartels 1.13 my $links;
590 :     my $linksstring = '';
591 :     my $linksvoid = '';
592 : bartels 1.17 my @rel_link_num = $fig->get_attributes( 'Subsystem:'.$name, "SUBSYSTEM_WEBLINKS" );
593 : bartels 1.13
594 :     foreach my $k ( @rel_link_num ) {
595 :     my ( $ss, $key, @value ) = @$k;
596 :     $linksstring .= $value[0].": <a href=\"javascript:void(0)\"onclick=\"window.open('".$value[1]."','height=640,width=800,scrollbars=yes,toolbar=yes,status=yes')\">". $value[1]."</a><BR>";
597 :     $linksvoid .= $value[0]." ".$value[1]."\n";
598 :     }
599 :    
600 :     return ( $linksstring, $linksvoid );
601 :     }
602 :    
603 : bartels 1.10 ########################################
604 :     # set Literature-string for subsystems #
605 :     ########################################
606 :     sub setLiteratures {
607 :     my ( $fig, $name, $newpubs ) = @_;
608 :    
609 : bartels 1.15 my $esc_name = uri_escape($name);
610 :    
611 : bartels 1.10 my @values;
612 : bartels 1.17 my @rel_lit_num = $fig->get_attributes( 'Subsystem:'.$name, "SUBSYSTEM_PUBMED_RELEVANT" );
613 : bartels 1.10
614 :     foreach my $k ( @rel_lit_num ) {
615 :     my ( $ss, $key, $value ) = @$k;
616 : bartels 1.20 $fig->delete_matching_attributes( "Subsystem:$name", "SUBSYSTEM_PUBMED_RELEVANT" );
617 : bartels 1.10 }
618 :    
619 :     foreach my $np ( @$newpubs ) {
620 : bartels 1.17 $fig->add_attribute( "Subsystem:$name", "SUBSYSTEM_PUBMED_RELEVANT", $np );
621 : bartels 1.10 }
622 :     }
623 :    
624 : bartels 1.13 ########################################
625 :     # set Literature-string for subsystems #
626 :     ########################################
627 :     sub setWeblinks {
628 :     my ( $fig, $name, $newpubs ) = @_;
629 :    
630 : bartels 1.15 my $esc_name = uri_escape($name);
631 :    
632 : bartels 1.13 my @values;
633 : bartels 1.17 my @rel_lit_num = $fig->get_attributes( 'Subsystem:'.$name, "SUBSYSTEM_WEBLINKS" );
634 : bartels 1.13
635 :     foreach my $k ( @rel_lit_num ) {
636 :     my ( $ss, $key, $value ) = @$k;
637 : bartels 1.20 $fig->delete_matching_attributes( "Subsystem:$name", "SUBSYSTEM_WEBLINKS" );
638 : bartels 1.13 }
639 :    
640 :     foreach my $np ( @$newpubs ) {
641 :     my @h = split( /\s+/, $np );
642 : bartels 1.17 $fig->add_attribute( "Subsystem:$name", "SUBSYSTEM_WEBLINKS", @h );
643 : bartels 1.13 }
644 :     }
645 :    
646 : bartels 1.2 sub supported_rights {
647 :    
648 :     return [ [ 'edit', 'subsystem', '*' ] ];
649 :    
650 : bartels 1.1 }
651 : bartels 1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3