[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.20, Thu Aug 14 20:04:20 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    ######################    ######################
96    
97    my $menu = $self->application->menu();    my $menu = $self->application->menu();
98    
99      my $esc_name = uri_escape($name);
100    
101    # Build nice tab menu here    # Build nice tab menu here
102    $menu->add_category( 'Subsystem Info', "SubsysEditor.cgi?page=ShowSubsystem&subsystem=$name" );    $menu->add_category( 'Subsystem Info', "SubsysEditor.cgi?page=ShowSubsystem&subsystem=$esc_name" );
103    $menu->add_category( 'Functional Roles', "SubsysEditor.cgi?page=ShowFunctionalRoles&subsystem=$name" );    $menu->add_category( 'Functional Roles', "SubsysEditor.cgi?page=ShowFunctionalRoles&subsystem=$esc_name" );
104    $menu->add_category( 'Subsystem Diagram', "SubsysEditor.cgi?page=ShowDiagram&subsystem=$name" );    $menu->add_category( 'Diagram', "SubsysEditor.cgi?page=ShowDiagram&subsystem=$esc_name" );
105    $menu->add_category( 'Subsystem Spreadsheet', "SubsysEditor.cgi?page=ShowSpreadsheet&subsystem=$name" );    $menu->add_category( 'Illustrations', "SubsysEditor.cgi?page=ShowIllustrations&subsystem=$esc_name" );
106    $menu->add_category( 'Subsystem Check', "SubsysEditor.cgi?page=ShowCheck&subsystem=$name" );    $menu->add_category( 'Spreadsheet', "SubsysEditor.cgi?page=ShowSpreadsheet&subsystem=$esc_name" );
107    $menu->add_category( 'Subsystem Tree', "SubsysEditor.cgi?page=ShowTree&subsystem=$name" );    $menu->add_category( 'Show Check', "SubsysEditor.cgi?page=ShowCheck&subsystem=$esc_name" );
108      $menu->add_category( 'Show Connections', "SubsysEditor.cgi?page=ShowTree&subsystem=$esc_name" );
109    
110    
111    ##############################    ##############################
# Line 143  Line 168 
168      }      }
169      $subsystem->set_classification( [ $class1, $class2 ] );      $subsystem->set_classification( [ $class1, $class2 ] );
170    
171        my $litstoset = $cgi->param( 'SUBSYSLIT' );
172        my @lits = split( ', ', $litstoset );
173        setLiteratures( $fig, $name, \@lits );
174    
175        my $wlstoset = $cgi->param( 'SUBSYSWL' );
176        if ( defined( $wlstoset ) && $wlstoset =~ /.+\s+.+/ ) {
177          my @wls = split( '\n', $wlstoset );
178          setWeblinks( $fig, $name, \@wls );
179        }
180    
181      # here we really edit the files in the subsystem directory #      # here we really edit the files in the subsystem directory #
182      $subsystem->incr_version();      $subsystem->incr_version();
183      $subsystem->db_sync();      $subsystem->db_sync();
# Line 156  Line 191 
191    my ( $ssversion, $sscurator, $pedigree, $ssroles ) = $fig->subsystem_info( $name );    my ( $ssversion, $sscurator, $pedigree, $ssroles ) = $fig->subsystem_info( $name );
192    
193    my $versionlink = '';    my $versionlink = '';
194  print STDERR $can_alter." CANALTER\n";  
195    if ( $can_alter ) {    if ( $can_alter ) {
196      $versionlink = " -- <A HREF='".$self->application->url()."?page=ResetSubsystem&subsystem=$name'>Reset to Previous Timestamp</A>";      $versionlink = " -- <A HREF='".$self->application->url()."?page=ResetSubsystem&subsystem=$esc_name'>Reset to Previous Timestamp</A>";
     print STDERR $versionlink . " VL\n";  
197    }    }
198    
199    my $mod_time = get_mod_time( $name );    my $mod_time = get_mod_time( $name );
# Line 184  Line 218 
218      $classification_stuff .= "<TR><TH></TH><TD>$class->[1]</TD></TR>";      $classification_stuff .= "<TR><TH></TH><TD>$class->[1]</TD></TR>";
219    }    }
220    
221      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>";  
222    $infotable .= "<TR><TH>Author:</TH><TD>$sscurator</TD></TR>";    $infotable .= "<TR><TH>Author:</TH><TD>$sscurator</TD></TR>";
223    $infotable .= "<TR><TH>Version:</TH><TD>$ssversion $versionlink</TD></TR>";    $infotable .= "<TR><TH>Version:</TH><TD>$ssversion $versionlink</TD></TR>";
224    $infotable .= "<TR><TH>Last Modified:</TH><TD>$mod_time</TD></TR>";    $infotable .= "<TR><TH>Last Modified:</TH><TD>$mod_time</TD></TR>";
225    
226      # Literature #
227      my $lit = getLiteratures( $fig, $name );
228      my $litstring = '';
229      my $litvoid = '';
230      if ( defined( $lit ) && scalar( @$lit ) > 0 ) {
231        my @litlinks;
232        foreach my $l ( @$lit ) {
233          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>";
234          push @litlinks, $thislink;
235        }
236        $litstring = join( ', ', @litlinks );
237        $litvoid = join( ', ', @$lit );
238      }
239    
240      # Weblinks #
241      my ( $wl, $wlvoid ) = getLinks( $fig, $name );
242    
243      my $variants = $subsystem->get_variants();
244    
245    if ( $can_alter ) {    if ( $can_alter ) {
246      $infotable .= "<TR><TH>Description</TH><TD><TEXTAREA NAME='SSDESC' ROWS=6 STYLE='width: 772px;'>$ssdesc</TEXTAREA></TD></TR>";  
247      $infotable .= "<TR><TH>Notes</TH><TD><TEXTAREA NAME='SSNOTES' ROWS=6 STYLE='width: 772px;'>$ssnotes</TEXTAREA></TD></TR>";      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\" );'>";
248        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\" );'>";
249    
250        $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>";
251        $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>";
252        $infotable .= "<TR><TH>Description</TH><TD><TEXTAREA NAME='SSDESC' ROWS=15 STYLE='width: 772px;'>$ssdesc</TEXTAREA></TD></TR>";
253        $infotable .= "<TR><TH>Notes</TH><TD><TEXTAREA NAME='SSNOTES' ROWS=15 STYLE='width: 772px;'>$ssnotes</TEXTAREA></TD></TR>";
254    }    }
255    else {    else {
256      # do a little formating because the notes often contain many many blanks and newlines      # do a little formating because the notes often contain many many blanks and newlines
# Line 201  Line 260 
260      my $ssnotes_brs = $ssnotes;      my $ssnotes_brs = $ssnotes;
261      $ssnotes_brs =~ s/(\n\s)+/\n/g;      $ssnotes_brs =~ s/(\n\s)+/\n/g;
262      $ssnotes_brs =~ s/\n/<BR>/g;      $ssnotes_brs =~ s/\n/<BR>/g;
263        $infotable .= "<TR><TH>Literature</TH><TD>$litstring</TD></TR>";
264        $infotable .= "<TR><TH>Websites</TH><TD>$wl</TD></TR>";
265      $infotable .= "<TR><TH>Description</TH><TD>$ssdesc_brs</TD></TR>";      $infotable .= "<TR><TH>Description</TH><TD>$ssdesc_brs</TD></TR>";
266      $infotable .= "<TR><TH>Notes</TH><TD>$ssnotes_brs</TD></TR>";      $infotable .= "<TR><TH>Notes</TH><TD>$ssnotes_brs</TD></TR>";
267    }    }
268      # variants
269      my $vartable = $self->application->component( 'VarDescTable' );
270      $vartable->columns( [ { name => "Variant" }, { name => "Description" } ] );
271    
272      my $vardata;
273      my $has_variants = 0;
274      foreach my $kv ( sort keys %$variants ) {
275        $has_variants = 1;
276        push @$vardata, [ $kv, $variants->{ $kv } ];
277      }
278      $vartable->data( $vardata );
279      $infotable .= "<TR><TH>Variants</TH><TD>";
280      if ( $has_variants ) {
281        $infotable .= $vartable->output();
282      }
283    
284      if ( $can_alter ) {
285        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\" )'>";
286      $infotable .= $variant_outside;
287      }
288    
289      $infotable .= "</TD</TR>";
290    
291    $infotable .= $classification_stuff;    $infotable .= $classification_stuff;
292    $infotable .= "</TABLE>";    $infotable .= "</TABLE>";
293    
294    if ( $can_alter ) {    if ( $can_alter ) {
295      $infotable .= "<INPUT TYPE=SUBMIT VALUE='Save Changes' ID='SUBMIT' NAME='SUBMIT'>";      $infotable .= "<INPUT TYPE=SUBMIT VALUE='Save Changes' ID='SUBMIT' NAME='SUBMIT' STYLE='background-color: red;'>";
296    }    }
297    
298      if ( $can_alter ) {
299        $content .= "<INPUT TYPE=SUBMIT VALUE='Save Changes' ID='SUBMIT' NAME='SUBMIT'  STYLE='background-color: red;'>";
300      }
301    $content .= $infotable;    $content .= $infotable;
302    $content .= $self->end_form();    $content .= $self->end_form();
303    
# Line 293  Line 380 
380      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'>";
381      my $optstring = '';      my $optstring = '';
382      foreach my $secc ( sort @{ $ssclass->{ $firstc } } ) {      foreach my $secc ( sort @{ $ssclass->{ $firstc } } ) {
383        if ( defined( $SUBSYSH2 ) && $SUBSYSH2 eq $secc ) {        if ( defined( $SUBSYSH2 ) && $SUBSYSH2 eq $secc && $SUBSYSH1 eq $firstc ) {
384          $optstring .= "<OPTION SELECTED VALUE='$secc'>$secc</OPTION>";          $optstring .= "<OPTION SELECTED VALUE='$secc'>$secc</OPTION>";
385          # we have to show the selectbox if there is a selected value          # we have to show the selectbox if there is a selected value
386          $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 428 
428    return $sdContent;    return $sdContent;
429  }  }
430    
431    ########################################
432    # get Literature-string for subsystems #
433    ########################################
434    sub getLiteratures {
435      my ( $fig, $name ) = @_;
436    
437      my $esc_name = uri_escape($name);
438    
439      my $frpubs;
440      my @rel_lit_num = $fig->get_attributes( 'Subsystem:'.$name, "SUBSYSTEM_PUBMED_RELEVANT" );
441    
442      foreach my $k ( @rel_lit_num ) {
443        my ( $ss, $key, $value ) = @$k;
444        push @$frpubs, $value;
445      }
446    
447      return $frpubs;
448    }
449    
450    ######################################
451    # get Weblinks-string for subsystems #
452    ######################################
453    sub getLinks {
454      my ( $fig, $name ) = @_;
455    
456      my $esc_name = uri_escape($name);
457    
458      my $links;
459      my $linksstring = '';
460      my $linksvoid = '';
461      my @rel_link_num = $fig->get_attributes( 'Subsystem:'.$name, "SUBSYSTEM_WEBLINKS" );
462    
463      foreach my $k ( @rel_link_num ) {
464        my ( $ss, $key, @value ) = @$k;
465        $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>";
466        $linksvoid .= $value[0]." ".$value[1]."\n";
467      }
468    
469      return ( $linksstring, $linksvoid );
470    }
471    
472    ########################################
473    # set Literature-string for subsystems #
474    ########################################
475    sub setLiteratures {
476      my ( $fig, $name, $newpubs ) = @_;
477    
478      my $esc_name = uri_escape($name);
479    
480      my @values;
481      my @rel_lit_num = $fig->get_attributes( 'Subsystem:'.$name, "SUBSYSTEM_PUBMED_RELEVANT" );
482    
483      foreach my $k ( @rel_lit_num ) {
484        my ( $ss, $key, $value ) = @$k;
485        $fig->delete_matching_attributes( "Subsystem:$name", "SUBSYSTEM_PUBMED_RELEVANT" );
486      }
487    
488      foreach my $np ( @$newpubs ) {
489        $fig->add_attribute( "Subsystem:$name", "SUBSYSTEM_PUBMED_RELEVANT", $np );
490      }
491    }
492    
493    ########################################
494    # set Literature-string for subsystems #
495    ########################################
496    sub setWeblinks {
497      my ( $fig, $name, $newpubs ) = @_;
498    
499      my $esc_name = uri_escape($name);
500    
501      my @values;
502      my @rel_lit_num = $fig->get_attributes( 'Subsystem:'.$name, "SUBSYSTEM_WEBLINKS" );
503    
504      foreach my $k ( @rel_lit_num ) {
505        my ( $ss, $key, $value ) = @$k;
506        $fig->delete_matching_attributes( "Subsystem:$name", "SUBSYSTEM_WEBLINKS" );
507      }
508    
509      foreach my $np ( @$newpubs ) {
510        my @h = split( /\s+/, $np );
511        $fig->add_attribute( "Subsystem:$name", "SUBSYSTEM_WEBLINKS", @h );
512      }
513    }
514    
515  sub supported_rights {  sub supported_rights {
516    
517    return [ [ 'edit', 'subsystem', '*' ] ];    return [ [ 'edit', 'subsystem', '*' ] ];

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3