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

Diff of /SubsystemEditor/WebPage/ShowSubsystem.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4, Thu Dec 13 21:17:21 2007 UTC revision 1.12, Thu Mar 20 19:26:57 2008 UTC
# Line 19  Line 19 
19    my ( $self ) = @_;    my ( $self ) = @_;
20    
21    $self->application->register_component( 'Table', 'sstable'  );    $self->application->register_component( 'Table', 'sstable'  );
22      $self->application->register_component(  'Table', 'VarDescTable'  );
23  }  }
24    
25  #################################  #################################
# Line 36  Line 37 
37  sub output {  sub output {
38    my ( $self ) = @_;    my ( $self ) = @_;
39    
   use Data::Dumper;  
   
40    my $fig = new FIG;    my $fig = new FIG;
41    my $cgi = $self->application->cgi;    my $cgi = $self->application->cgi;
42    
# Line 64  Line 63 
63      }      }
64    }    }
65    
66    if ( $user && $user->has_right( $self->application, 'edit', 'subsystem', $name ) ) {    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          my $su = lc( $seeduser );
76          my $cu = lc( $curatorOfSS );
77          if ( $su eq $cu ) {
78            # 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;      $can_alter = 1;
87      $fig->set_user( $seeduser );      $fig->set_user( $seeduser );
88    }    }
89          }
90        }
91      }
92    
93    ######################    ######################
94    # Construct the menu #    # Construct the menu #
95    ######################    ######################
# Line 77  Line 99 
99    # Build nice tab menu here    # Build nice tab menu here
100    $menu->add_category( 'Subsystem Info', "SubsysEditor.cgi?page=ShowSubsystem&subsystem=$name" );    $menu->add_category( 'Subsystem Info', "SubsysEditor.cgi?page=ShowSubsystem&subsystem=$name" );
101    $menu->add_category( 'Functional Roles', "SubsysEditor.cgi?page=ShowFunctionalRoles&subsystem=$name" );    $menu->add_category( 'Functional Roles', "SubsysEditor.cgi?page=ShowFunctionalRoles&subsystem=$name" );
102    $menu->add_category( 'Subsystem Diagram', "SubsysEditor.cgi?page=ShowDiagram&subsystem=$name" );    $menu->add_category( 'Diagram', "SubsysEditor.cgi?page=ShowDiagram&subsystem=$name" );
103    $menu->add_category( 'Subsystem Spreadsheet', "SubsysEditor.cgi?page=ShowSpreadsheet&subsystem=$name" );    $menu->add_category( 'Illustrations', "SubsysEditor.cgi?page=ShowIllustrations&subsystem=$name" );
104    $menu->add_category( 'Subsystem Check', "SubsysEditor.cgi?page=ShowCheck&subsystem=$name" );    $menu->add_category( 'Spreadsheet', "SubsysEditor.cgi?page=ShowSpreadsheet&subsystem=$name" );
105    $menu->add_category( 'Subsystem Tree', "SubsysEditor.cgi?page=ShowTree&subsystem=$name" );    $menu->add_category( 'Show Check', "SubsysEditor.cgi?page=ShowCheck&subsystem=$name" );
106      $menu->add_category( 'Show Tree', "SubsysEditor.cgi?page=ShowTree&subsystem=$name" );
107    
108    
109    ##############################    ##############################
# Line 143  Line 166 
166      }      }
167      $subsystem->set_classification( [ $class1, $class2 ] );      $subsystem->set_classification( [ $class1, $class2 ] );
168    
169        my $litstoset = $cgi->param( 'SUBSYSLIT' );
170        my @lits = split( ', ', $litstoset );
171        setLiteratures( $fig, $name, \@lits );
172    
173      # here we really edit the files in the subsystem directory #      # here we really edit the files in the subsystem directory #
174      $subsystem->incr_version();      $subsystem->incr_version();
175      $subsystem->db_sync();      $subsystem->db_sync();
# Line 156  Line 183 
183    my ( $ssversion, $sscurator, $pedigree, $ssroles ) = $fig->subsystem_info( $name );    my ( $ssversion, $sscurator, $pedigree, $ssroles ) = $fig->subsystem_info( $name );
184    
185    my $versionlink = '';    my $versionlink = '';
186  print STDERR $can_alter." CANALTER\n";  
187    if ( $can_alter ) {    if ( $can_alter ) {
188      $versionlink = " -- <A HREF='".$self->application->url()."?page=ResetSubsystem&subsystem=$name'>Reset to Previous Timestamp</A>";      $versionlink = " -- <A HREF='".$self->application->url()."?page=ResetSubsystem&subsystem=$name'>Reset to Previous Timestamp</A>";
     print STDERR $versionlink . " VL\n";  
189    }    }
190    
191    my $mod_time = get_mod_time( $name );    my $mod_time = get_mod_time( $name );
# Line 184  Line 210 
210      $classification_stuff .= "<TR><TH></TH><TD>$class->[1]</TD></TR>";      $classification_stuff .= "<TR><TH></TH><TD>$class->[1]</TD></TR>";
211    }    }
212    
213      print STDERR $versionlink . " VL\n";    my $infotable = "<TABLE><TR><TH>Name:</TH><TD>$ssname</TD></TR>";
   my $infotable = "<TABLE><TR><TH>Name:</TH><TD>$ssname</TD><TR>";  
214    $infotable .= "<TR><TH>Author:</TH><TD>$sscurator</TD></TR>";    $infotable .= "<TR><TH>Author:</TH><TD>$sscurator</TD></TR>";
215    $infotable .= "<TR><TH>Version:</TH><TD>$ssversion $versionlink</TD></TR>";    $infotable .= "<TR><TH>Version:</TH><TD>$ssversion $versionlink</TD></TR>";
216    $infotable .= "<TR><TH>Last Modified:</TH><TD>$mod_time</TD></TR>";    $infotable .= "<TR><TH>Last Modified:</TH><TD>$mod_time</TD></TR>";
217    
218      my $lit = getLiteratures( $fig, $name );
219      my $litstring = '';
220      my $litvoid = '';
221      if ( defined( $lit ) && scalar( @$lit ) > 0 ) {
222        my @litlinks;
223        foreach my $l ( @$lit ) {
224          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>";
225          push @litlinks, $thislink;
226        }
227        $litstring = join( ', ', @litlinks );
228        $litvoid = join( ', ', @$lit );
229      }
230    
231      my $variants = $subsystem->get_variants();
232    
233    if ( $can_alter ) {    if ( $can_alter ) {
234    
235        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\" );'>";
236        $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>";
237      $infotable .= "<TR><TH>Description</TH><TD><TEXTAREA NAME='SSDESC' ROWS=6 STYLE='width: 772px;'>$ssdesc</TEXTAREA></TD></TR>";      $infotable .= "<TR><TH>Description</TH><TD><TEXTAREA NAME='SSDESC' ROWS=6 STYLE='width: 772px;'>$ssdesc</TEXTAREA></TD></TR>";
238      $infotable .= "<TR><TH>Notes</TH><TD><TEXTAREA NAME='SSNOTES' ROWS=6 STYLE='width: 772px;'>$ssnotes</TEXTAREA></TD></TR>";      $infotable .= "<TR><TH>Notes</TH><TD><TEXTAREA NAME='SSNOTES' ROWS=6 STYLE='width: 772px;'>$ssnotes</TEXTAREA></TD></TR>";
239    }    }
# Line 201  Line 245 
245      my $ssnotes_brs = $ssnotes;      my $ssnotes_brs = $ssnotes;
246      $ssnotes_brs =~ s/(\n\s)+/\n/g;      $ssnotes_brs =~ s/(\n\s)+/\n/g;
247      $ssnotes_brs =~ s/\n/<BR>/g;      $ssnotes_brs =~ s/\n/<BR>/g;
248        $infotable .= "<TR><TH>Literature</TH><TD>$litstring</TD></TR>";
249      $infotable .= "<TR><TH>Description</TH><TD>$ssdesc_brs</TD></TR>";      $infotable .= "<TR><TH>Description</TH><TD>$ssdesc_brs</TD></TR>";
250      $infotable .= "<TR><TH>Notes</TH><TD>$ssnotes_brs</TD></TR>";      $infotable .= "<TR><TH>Notes</TH><TD>$ssnotes_brs</TD></TR>";
251    }    }
252      # variants
253      my $vartable = $self->application->component( 'VarDescTable' );
254      $vartable->columns( [ { name => "Variant" }, { name => "Description" } ] );
255    
256      my $vardata;
257      my $has_variants = 0;
258      foreach my $kv ( sort keys %$variants ) {
259        $has_variants = 1;
260        push @$vardata, [ $kv, $variants->{ $kv } ];
261      }
262      $vartable->data( $vardata );
263      $infotable .= "<TR><TH>Variants</TH><TD>";
264      if ( $has_variants ) {
265        $infotable .= $vartable->output();
266      }
267    
268      if ( $can_alter ) {
269        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\" )'>";
270      $infotable .= $variant_outside;
271      }
272    
273      $infotable .= "</TD</TR>";
274    
275    $infotable .= $classification_stuff;    $infotable .= $classification_stuff;
276    $infotable .= "</TABLE>";    $infotable .= "</TABLE>";
277    
# Line 293  Line 361 
361      my $opt = "<SELECT SIZE=5 ID='$firstc' NAME='SUBSYSH2' STYLE='width: 386px;' class='hideme'>";      my $opt = "<SELECT SIZE=5 ID='$firstc' NAME='SUBSYSH2' STYLE='width: 386px;' class='hideme'>";
362      my $optstring = '';      my $optstring = '';
363      foreach my $secc ( sort @{ $ssclass->{ $firstc } } ) {      foreach my $secc ( sort @{ $ssclass->{ $firstc } } ) {
364        if ( defined( $SUBSYSH2 ) && $SUBSYSH2 eq $secc ) {        if ( defined( $SUBSYSH2 ) && $SUBSYSH2 eq $secc && $SUBSYSH1 eq $firstc ) {
365          $optstring .= "<OPTION SELECTED VALUE='$secc'>$secc</OPTION>";          $optstring .= "<OPTION SELECTED VALUE='$secc'>$secc</OPTION>";
366          # we have to show the selectbox if there is a selected value          # we have to show the selectbox if there is a selected value
367          $opt = "<SELECT SIZE=5 ID='$firstc' NAME='SUBSYSH2' STYLE='width: 386px;' class='showme'>";          $opt = "<SELECT SIZE=5 ID='$firstc' NAME='SUBSYSH2' STYLE='width: 386px;' class='showme'>";
# Line 341  Line 409 
409    return $sdContent;    return $sdContent;
410  }  }
411    
412    ########################################
413    # get Literature-string for subsystems #
414    ########################################
415    sub getLiteratures {
416      my ( $fig, $name ) = @_;
417    
418      my $frpubs;
419      my @rel_lit_num = $fig->get_attributes( 'Subsystem:'.$name, "SUBSYSTEM_PUBMED_RELEVANT" );
420    
421      foreach my $k ( @rel_lit_num ) {
422        my ( $ss, $key, $value ) = @$k;
423        push @$frpubs, $value;
424      }
425    
426      return $frpubs;
427    }
428    
429    ########################################
430    # set Literature-string for subsystems #
431    ########################################
432    sub setLiteratures {
433      my ( $fig, $name, $newpubs ) = @_;
434    
435      my @values;
436      my @rel_lit_num = $fig->get_attributes( 'Subsystem:'.$name, "SUBSYSTEM_PUBMED_RELEVANT" );
437    
438      foreach my $k ( @rel_lit_num ) {
439        my ( $ss, $key, $value ) = @$k;
440        $fig->delete_matching_attributes( "Subsystem:$name", "SUBSYSTEM_PUBMED_RELEVANT", $value );
441      }
442    
443      foreach my $np ( @$newpubs ) {
444        $fig->add_attribute( "Subsystem:$name", "SUBSYSTEM_PUBMED_RELEVANT", $np );
445      }
446    }
447    
448  sub supported_rights {  sub supported_rights {
449    
450    return [ [ 'edit', 'subsystem', '*' ] ];    return [ [ 'edit', 'subsystem', '*' ] ];

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.12

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3