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

Annotation of /SubsystemEditor/WebPage/ShowSubsystem.pm

Parent Directory Parent Directory | Revision Log Revision Log


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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3