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

Annotation of /SubsystemEditor/WebPage/ShowSubsystem.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.25 - (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 :     my $thisUsers = $dbmaster->User->get_objects( { login => $newAnno } );
192 :     if ( defined( $thisUsers->[0] ) ) {
193 :    
194 :     my $rights = $dbmaster->Rights->get_objects( { name => 'edit',
195 :     data_type => 'subsystem',
196 :     data_id => $name,
197 :     scope => $thisUsers->[0]->get_user_scope() } );
198 :     if ( defined( $rights->[0] ) ) {
199 :     $self->application->add_message( 'warning', "User $newAnno already has the right to edit this subsystem." );
200 :     }
201 :     else {
202 :     my $right = $dbmaster->Rights->create( { granted => 1,
203 :     delegated => 1,
204 :     name => 'edit',
205 :     data_type => 'subsystem',
206 :     data_id => $name,
207 :     scope => $thisUsers->[0]->get_user_scope() } );
208 :     if ( $right ) {
209 :     $self->application->add_message( 'info', "$newAnno can now edit this subsystem" );
210 :     }
211 :     else {
212 :     $self->application->add_message( 'warning', "Could not create right to edit the subsystem for user $newAnno" );
213 :     }
214 :     }
215 :     }
216 :     }
217 :     else {
218 :     $self->application->add_message( 'warning', "You do not have the right to share the subsystem." );
219 :     }
220 :     }
221 :     elsif ( defined( $cgi->param( 'RevokeRightButton' ) ) ) {
222 :     if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) ) {
223 :     my $newAnno = $cgi->param( 'ALANNOBOX' );
224 :     my $thisUsers = $dbmaster->User->get_objects( { login => $newAnno } );
225 :     my $rights = $dbmaster->Rights->get_objects( { name => 'edit',
226 :     data_type => 'subsystem',
227 :     data_id => $name,
228 :     scope => $thisUsers->[0]->get_user_scope() } );
229 :    
230 :     my $thisRight = $rights->[0];
231 :     if ( defined( $thisRight ) && $thisRight->delegated ) {
232 :     $thisRight->delete();
233 :    
234 :     $self->application->add_message( 'info', "$newAnno cannot edit this subsystem any more." );
235 :     }
236 :     else {
237 :     $self->application->add_message( 'warning', "You can't revoke the right of $newAnno to edit this subsystem." );
238 :     }
239 :     }
240 :     else {
241 :     $self->application->add_message( 'warning', "You do not have the right to revoke rights for this subsystem." );
242 :     }
243 :     }
244 : bartels 1.1
245 : bartels 1.2 $subsystem = new Subsystem( $name, $fig, 0 );
246 :    
247 :     $content .= $self->start_form( 'form', { subsystem => $name } );
248 :    
249 : bartels 1.1 my ( $ssversion, $sscurator, $pedigree, $ssroles ) = $fig->subsystem_info( $name );
250 : bartels 1.3
251 :     my $versionlink = '';
252 : bartels 1.5
253 : bartels 1.3 if ( $can_alter ) {
254 : bartels 1.16 $versionlink = " -- <A HREF='".$self->application->url()."?page=ResetSubsystem&subsystem=$esc_name'>Reset to Previous Timestamp</A>";
255 : bartels 1.3 }
256 :    
257 : bartels 1.1 my $mod_time = get_mod_time( $name );
258 :     my $class = $fig->subsystem_classification( $name );
259 :     my $ssnotes = $subsystem->get_notes();
260 :    
261 : bartels 1.2 if ( !defined( $ssnotes ) ) {
262 :     $ssnotes = '';
263 :     }
264 :     my $ssdesc = $subsystem->get_description();
265 :    
266 :     if ( !defined( $ssdesc ) ) {
267 :     $ssdesc = '';
268 :     }
269 :    
270 :     my $classification_stuff;
271 :     if ( $can_alter ) {
272 :     $classification_stuff = get_classification_boxes( $fig, $cgi, $class->[0], $class->[1] );
273 :     }
274 :     else {
275 :     $classification_stuff = "<TR><TH>Classification:</TH><TD>$class->[0]</TD></TR>";
276 :     $classification_stuff .= "<TR><TH></TH><TD>$class->[1]</TD></TR>";
277 :     }
278 : bartels 1.1
279 : bartels 1.11 my $infotable = "<TABLE><TR><TH>Name:</TH><TD>$ssname</TD></TR>";
280 : bartels 1.1 $infotable .= "<TR><TH>Author:</TH><TD>$sscurator</TD></TR>";
281 : bartels 1.25 if ( $can_alter && $user->has_right( undef, 'edit', 'subsystem', $name, 1 ) ) {
282 :    
283 :     my $annoGrp = $dbmaster->Scope->get_objects( { name => 'Annotators' } );
284 :     my $annoScope = $dbmaster->UserHasScope->get_objects( { scope => $annoGrp->[0] } );
285 :     my $annoMems = [];
286 :     foreach my $aS ( @$annoScope ) {
287 :     push @$annoMems, $aS->user();
288 :     }
289 :     @$annoMems = sort { $a->lastname cmp $b->lastname || $a->firstname cmp $b->firstname } @$annoMems;
290 :    
291 :     my $editRightButton = "<INPUT TYPE=SUBMIT ID='GrantRightButton' NAME='GrantRightButton' VALUE='Grant Right'>";
292 :     my $revokeRightButton = "<INPUT TYPE=SUBMIT ID='RevokeRightButton' NAME='RevokeRightButton' VALUE='Revoke Right'>";
293 :    
294 :     my $annotatorsBox = "<SELECT NAME='ANNOBOX' ID='ANNOBOX'>";
295 :     my $alreadyAnnotatorsBox = "<SELECT NAME='ALANNOBOX' ID='ALANNOBOX'>";
296 :     foreach my $a ( @$annoMems ) {
297 :     unless ( $a->has_right( undef, 'edit', 'subsystem', $name ) ) {
298 :     $annotatorsBox .= "<OPTION VALUE='".$a->login."'>".$a->firstname.' '.$a->lastname.' ( '.$a->login." )</OPTION>";
299 :     }
300 :     else {
301 :     if ( $a->login() ne $user->login() && ( ! $a->has_right( undef, 'edit', 'subsystem', '*' ) ) ) {
302 :     $alreadyAnnotatorsBox .= "<OPTION VALUE='".$a->login."'>".$a->firstname.' '.$a->lastname.' ( '.$a->login." )</OPTION>";
303 :     }
304 :     }
305 :     }
306 :     $annotatorsBox .= "</SELECT>";
307 :     $alreadyAnnotatorsBox .= "</SELECT>";
308 :    
309 :     $infotable .= "<TR><TH>Grant Right To Edit To:</TH><TD>$annotatorsBox $editRightButton</TD></TR>";
310 :     $infotable .= "<TR><TH>Revoke Right To Edit From:</TH><TD>$alreadyAnnotatorsBox $revokeRightButton</TD></TR>";
311 :     }
312 : bartels 1.3 $infotable .= "<TR><TH>Version:</TH><TD>$ssversion $versionlink</TD></TR>";
313 : bartels 1.1 $infotable .= "<TR><TH>Last Modified:</TH><TD>$mod_time</TD></TR>";
314 : bartels 1.10
315 : bartels 1.13 # Literature #
316 : bartels 1.10 my $lit = getLiteratures( $fig, $name );
317 :     my $litstring = '';
318 :     my $litvoid = '';
319 :     if ( defined( $lit ) && scalar( @$lit ) > 0 ) {
320 :     my @litlinks;
321 :     foreach my $l ( @$lit ) {
322 :     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>";
323 :     push @litlinks, $thislink;
324 :     }
325 :     $litstring = join( ', ', @litlinks );
326 :     $litvoid = join( ', ', @$lit );
327 :     }
328 :    
329 : bartels 1.13 # Weblinks #
330 :     my ( $wl, $wlvoid ) = getLinks( $fig, $name );
331 :    
332 : bartels 1.12 my $variants = $subsystem->get_variants();
333 :    
334 : bartels 1.2 if ( $can_alter ) {
335 : bartels 1.10
336 :     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\" );'>";
337 : 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\" );'>";
338 :    
339 : 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>";
340 : 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>";
341 : bartels 1.19 $infotable .= "<TR><TH>Description</TH><TD><TEXTAREA NAME='SSDESC' ROWS=15 STYLE='width: 772px;'>$ssdesc</TEXTAREA></TD></TR>";
342 :     $infotable .= "<TR><TH>Notes</TH><TD><TEXTAREA NAME='SSNOTES' ROWS=15 STYLE='width: 772px;'>$ssnotes</TEXTAREA></TD></TR>";
343 : bartels 1.2 }
344 :     else {
345 :     # do a little formating because the notes often contain many many blanks and newlines
346 :     my $ssdesc_brs = $ssdesc;
347 :     $ssdesc_brs =~ s/\n/<BR>/g;
348 :     $ssdesc_brs =~ s/(\n\s)+/\n/g;
349 :     my $ssnotes_brs = $ssnotes;
350 :     $ssnotes_brs =~ s/(\n\s)+/\n/g;
351 :     $ssnotes_brs =~ s/\n/<BR>/g;
352 : bartels 1.11 $infotable .= "<TR><TH>Literature</TH><TD>$litstring</TD></TR>";
353 : bartels 1.14 $infotable .= "<TR><TH>Websites</TH><TD>$wl</TD></TR>";
354 : bartels 1.2 $infotable .= "<TR><TH>Description</TH><TD>$ssdesc_brs</TD></TR>";
355 :     $infotable .= "<TR><TH>Notes</TH><TD>$ssnotes_brs</TD></TR>";
356 :     }
357 : bartels 1.12 # variants
358 :     my $vartable = $self->application->component( 'VarDescTable' );
359 :     $vartable->columns( [ { name => "Variant" }, { name => "Description" } ] );
360 :    
361 :     my $vardata;
362 :     my $has_variants = 0;
363 :     foreach my $kv ( sort keys %$variants ) {
364 :     $has_variants = 1;
365 :     push @$vardata, [ $kv, $variants->{ $kv } ];
366 :     }
367 :     $vartable->data( $vardata );
368 :     $infotable .= "<TR><TH>Variants</TH><TD>";
369 :     if ( $has_variants ) {
370 :     $infotable .= $vartable->output();
371 :     }
372 :    
373 :     if ( $can_alter ) {
374 :     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\" )'>";
375 :     $infotable .= $variant_outside;
376 :     }
377 :    
378 :     $infotable .= "</TD</TR>";
379 :    
380 : bartels 1.2 $infotable .= $classification_stuff;
381 : bartels 1.1 $infotable .= "</TABLE>";
382 :    
383 : bartels 1.2 if ( $can_alter ) {
384 : bartels 1.20 $infotable .= "<INPUT TYPE=SUBMIT VALUE='Save Changes' ID='SUBMIT' NAME='SUBMIT' STYLE='background-color: red;'>";
385 : bartels 1.2 }
386 :    
387 : bartels 1.20 if ( $can_alter ) {
388 :     $content .= "<INPUT TYPE=SUBMIT VALUE='Save Changes' ID='SUBMIT' NAME='SUBMIT' STYLE='background-color: red;'>";
389 :     }
390 : bartels 1.1 $content .= $infotable;
391 : bartels 1.2 $content .= $self->end_form();
392 : bartels 1.1
393 :     return $content;
394 :     }
395 :    
396 :    
397 :     sub get_mod_time {
398 :    
399 :     my ( $ssa, $fig ) = @_;
400 :    
401 :     my( $t, @spreadsheets );
402 :     if ( opendir( BACKUP, "$FIG_Config::data/Subsystems/$ssa/Backup" ) ) {
403 :    
404 :     @spreadsheets = sort { $b <=> $a }
405 :     map { $_ =~ /^spreadsheet.(\d+)/; $1 }
406 :     grep { $_ =~ /^spreadsheet/ }
407 :     readdir(BACKUP);
408 :     closedir(BACKUP);
409 :    
410 :     if ( $t = shift @spreadsheets ) {
411 :     my $last_modified = &FIG::epoch_to_readable( $t );
412 :     return $last_modified;
413 :     }
414 :     }
415 : bartels 1.2 return "$FIG_Config::data/Subsystems/$ssa/Backup";
416 :     }
417 :    
418 :    
419 :     sub get_classification_boxes {
420 :     my ( $fig, $cgi, $class1, $class2 ) = @_;
421 :     my $classified = 1;
422 :    
423 :     my $sdContent = '';
424 :     my $SUBSYSH1 = $class1;
425 :     my $SUBSYSH2 = $class2;
426 :    
427 :     # variables that monitor if we have selected a box
428 :     my $putinh1 = 0;
429 :     my $putinh2 = 0;
430 :    
431 :     if ( !defined( $SUBSYSH1 ) ){
432 :     $putinh1 = 1;
433 :     }
434 :     if ( !defined( $SUBSYSH2 ) ){
435 :     $putinh2 = 1;
436 :     }
437 :    
438 :     my $inh1 = '';
439 :     if ( defined( $cgi->param( 'SUBSYSH1TF' ) ) ) {
440 :     $inh1 = $cgi->param( 'SUBSYSH1TF' );
441 :     }
442 :     elsif ( defined( $SUBSYSH1 ) ) {
443 :     if ( !$putinh1 ) {
444 :     $inh1 = $SUBSYSH1;
445 :     }
446 :     }
447 :     my $inh2 = '';
448 :     if ( defined( $cgi->param( 'SUBSYSH2TF' ) ) ) {
449 :     $inh2 = $cgi->param( 'SUBSYSH2TF' );
450 :     }
451 :     elsif ( defined( $SUBSYSH2 ) ) {
452 :     if ( !$putinh2 ) {
453 :     $inh2 = $SUBSYSH2;
454 :     }
455 :     }
456 :    
457 :     my @ssclassifications = $fig->all_subsystem_classifications();
458 :     my $ssclass;
459 :     foreach my $ssc ( @ssclassifications ) {
460 : bartels 1.24 if ( !defined( $ssc->[1] ) ) {
461 :     $ssc->[1] = '';
462 :     }
463 :     # next if ( ( !defined( $ssc->[0] ) ) || ( !defined( $ssc->[1] ) ) );
464 :     next if ( !defined( $ssc->[0] ) );
465 :     next if ( $ssc->[0] eq '' );
466 :     # next if ( ( $ssc->[0] eq '' ) || ( $ssc->[1] eq '' ) );
467 : bartels 1.2 next if ( ( $ssc->[0] =~ /^\s+$/ ) || ( $ssc->[1] =~ /^\s+$/ ) );
468 :     push @{ $ssclass->{ $ssc->[0] } }, $ssc->[1];
469 :     }
470 :    
471 :    
472 :     my @options;
473 :     foreach my $firstc ( keys %$ssclass ) {
474 :     my $opt = "<SELECT SIZE=5 ID='$firstc' NAME='SUBSYSH2' STYLE='width: 386px;' class='hideme'>";
475 :     my $optstring = '';
476 :     foreach my $secc ( sort @{ $ssclass->{ $firstc } } ) {
477 : bartels 1.8 if ( defined( $SUBSYSH2 ) && $SUBSYSH2 eq $secc && $SUBSYSH1 eq $firstc ) {
478 : bartels 1.2 $optstring .= "<OPTION SELECTED VALUE='$secc'>$secc</OPTION>";
479 :     # we have to show the selectbox if there is a selected value
480 :     $opt = "<SELECT SIZE=5 ID='$firstc' NAME='SUBSYSH2' STYLE='width: 386px;' class='showme'>";
481 :     $putinh2 = 1;
482 :     }
483 :     else {
484 :     $optstring .= "<OPTION VALUE='$secc'>$secc</OPTION>";
485 :     }
486 :     }
487 :     $opt .= $optstring;
488 :     $opt .= "</SELECT>";
489 :     push @options, $opt;
490 :     }
491 :    
492 :     if ( $classified ) {
493 :     $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();'>";
494 :     }
495 :     else {
496 :     $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>";
497 :     }
498 :     foreach my $firstc ( sort keys %$ssclass ) {
499 :     if ( defined( $SUBSYSH1 ) && $SUBSYSH1 eq $firstc ) {
500 :     $sdContent .= "\n<OPTION SELECTED VALUE='$firstc'>$firstc</OPTION>\n";
501 :     $putinh1 = 1;
502 :     }
503 :     else {
504 :     $sdContent .= "\n<OPTION VALUE='$firstc'>$firstc</OPTION>\n";
505 :     }
506 :     }
507 :     $sdContent .= "</SELECT>";
508 :    
509 :     foreach my $opt ( @options ) {
510 :     $sdContent .= $opt;
511 :     }
512 :    
513 :     $sdContent .= "</TD></TR>";
514 :     if ( $classified ) {
515 :     $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>";
516 :     }
517 :     else {
518 :     $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>";
519 :     }
520 :    
521 :    
522 :     return $sdContent;
523 :     }
524 :    
525 : bartels 1.10 ########################################
526 :     # get Literature-string for subsystems #
527 :     ########################################
528 :     sub getLiteratures {
529 :     my ( $fig, $name ) = @_;
530 :    
531 : bartels 1.15 my $esc_name = uri_escape($name);
532 :    
533 : bartels 1.10 my $frpubs;
534 : bartels 1.17 my @rel_lit_num = $fig->get_attributes( 'Subsystem:'.$name, "SUBSYSTEM_PUBMED_RELEVANT" );
535 : bartels 1.10
536 :     foreach my $k ( @rel_lit_num ) {
537 :     my ( $ss, $key, $value ) = @$k;
538 :     push @$frpubs, $value;
539 :     }
540 :    
541 :     return $frpubs;
542 :     }
543 :    
544 : bartels 1.13 ######################################
545 :     # get Weblinks-string for subsystems #
546 :     ######################################
547 :     sub getLinks {
548 :     my ( $fig, $name ) = @_;
549 :    
550 : bartels 1.15 my $esc_name = uri_escape($name);
551 :    
552 : bartels 1.13 my $links;
553 :     my $linksstring = '';
554 :     my $linksvoid = '';
555 : bartels 1.17 my @rel_link_num = $fig->get_attributes( 'Subsystem:'.$name, "SUBSYSTEM_WEBLINKS" );
556 : bartels 1.13
557 :     foreach my $k ( @rel_link_num ) {
558 :     my ( $ss, $key, @value ) = @$k;
559 :     $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>";
560 :     $linksvoid .= $value[0]." ".$value[1]."\n";
561 :     }
562 :    
563 :     return ( $linksstring, $linksvoid );
564 :     }
565 :    
566 : bartels 1.10 ########################################
567 :     # set Literature-string for subsystems #
568 :     ########################################
569 :     sub setLiteratures {
570 :     my ( $fig, $name, $newpubs ) = @_;
571 :    
572 : bartels 1.15 my $esc_name = uri_escape($name);
573 :    
574 : bartels 1.10 my @values;
575 : bartels 1.17 my @rel_lit_num = $fig->get_attributes( 'Subsystem:'.$name, "SUBSYSTEM_PUBMED_RELEVANT" );
576 : bartels 1.10
577 :     foreach my $k ( @rel_lit_num ) {
578 :     my ( $ss, $key, $value ) = @$k;
579 : bartels 1.20 $fig->delete_matching_attributes( "Subsystem:$name", "SUBSYSTEM_PUBMED_RELEVANT" );
580 : bartels 1.10 }
581 :    
582 :     foreach my $np ( @$newpubs ) {
583 : bartels 1.17 $fig->add_attribute( "Subsystem:$name", "SUBSYSTEM_PUBMED_RELEVANT", $np );
584 : bartels 1.10 }
585 :     }
586 :    
587 : bartels 1.13 ########################################
588 :     # set Literature-string for subsystems #
589 :     ########################################
590 :     sub setWeblinks {
591 :     my ( $fig, $name, $newpubs ) = @_;
592 :    
593 : bartels 1.15 my $esc_name = uri_escape($name);
594 :    
595 : bartels 1.13 my @values;
596 : bartels 1.17 my @rel_lit_num = $fig->get_attributes( 'Subsystem:'.$name, "SUBSYSTEM_WEBLINKS" );
597 : bartels 1.13
598 :     foreach my $k ( @rel_lit_num ) {
599 :     my ( $ss, $key, $value ) = @$k;
600 : bartels 1.20 $fig->delete_matching_attributes( "Subsystem:$name", "SUBSYSTEM_WEBLINKS" );
601 : bartels 1.13 }
602 :    
603 :     foreach my $np ( @$newpubs ) {
604 :     my @h = split( /\s+/, $np );
605 : bartels 1.17 $fig->add_attribute( "Subsystem:$name", "SUBSYSTEM_WEBLINKS", @h );
606 : bartels 1.13 }
607 :     }
608 :    
609 : bartels 1.2 sub supported_rights {
610 :    
611 :     return [ [ 'edit', 'subsystem', '*' ] ];
612 :    
613 : bartels 1.1 }
614 : bartels 1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3