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

Diff of /SubsystemEditor/WebPage/ShowIllustrations.pm

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

revision 1.1, Wed Mar 12 16:11:09 2008 UTC revision 1.4, Mon Apr 7 21:03:50 2008 UTC
# Line 46  Line 46 
46    my $ssname = $name;    my $ssname = $name;
47    $ssname =~ s/\_/ /g;    $ssname =~ s/\_/ /g;
48    
49      my $subsystem = new Subsystem( $name, $fig, 0 );
50    
51    # look if someone is logged in and can write the subsystem #    # look if someone is logged in and can write the subsystem #
52    my $can_alter = 0;    my $can_alter = 0;
53    my $user = $self->application->session->user;    my $user = $self->application->session->user;
# Line 66  Line 68 
68    $menu->add_category( 'Illustrations', "SubsysEditor.cgi?page=ShowIllustrations&subsystem=$name" );    $menu->add_category( 'Illustrations', "SubsysEditor.cgi?page=ShowIllustrations&subsystem=$name" );
69    $menu->add_category( 'Spreadsheet', "SubsysEditor.cgi?page=ShowSpreadsheet&subsystem=$name" );    $menu->add_category( 'Spreadsheet', "SubsysEditor.cgi?page=ShowSpreadsheet&subsystem=$name" );
70    $menu->add_category( 'Show Check', "SubsysEditor.cgi?page=ShowCheck&subsystem=$name" );    $menu->add_category( 'Show Check', "SubsysEditor.cgi?page=ShowCheck&subsystem=$name" );
71    $menu->add_category( 'Show Tree', "SubsysEditor.cgi?page=ShowTree&subsystem=$name" );    $menu->add_category( 'Show Connections', "SubsysEditor.cgi?page=ShowTree&subsystem=$name" );
72    
73    my $error = '';    my $error = '';
74    my $comment = '';    my $comment = '';
75    
76      #########
77      # TASKS #
78      #########
79    
80      if ( defined( $cgi->param( 'DELETEBUTTONPRESSED' ) ) && $cgi->param( 'DELETEBUTTONPRESSED' ) == 1 ) {
81        my $diagramid = $cgi->param( 'DIAGRAMID' );
82        &delete_illustration( $subsystem, $diagramid );
83        $cgi->delete( 'diagram' );
84        $cgi->delete( 'DIAGRAMID' );
85        $cgi->delete( 'diagram_selectbox' );
86      }
87    
88    ##############################    ##############################
89    # Construct the page content #    # Construct the page content #
90    ##############################    ##############################
# Line 149  Line 163 
163      # print out an error message if there is no 'new' diagram      # print out an error message if there is no 'new' diagram
164      my $diagram_id  = $cgi->param( 'diagram' ) || $cgi->param( 'diagram_selectbox' ) || '';      my $diagram_id  = $cgi->param( 'diagram' ) || $cgi->param( 'diagram_selectbox' ) || '';
165    
166      if ( defined( $cgi->param( 'Show this diagram' ) ) ) {      if ( defined( $cgi->param( 'Show this illustration' ) ) ) {
167        $diagram_id = $cgi->param( 'diagram_selectbox' );        $diagram_id = $cgi->param( 'diagram_selectbox' );
168      }      }
169    
170      unless ( $diagram_id ) {      unless ( $diagram_id ) {
171        $diagram_id = $defaultDiagram;        $diagram_id = $defaultDiagram;
172          $cgi->param( 'diagram_selectbox', $diagram_id );
173      }      }
174    
175      # check diagram id      # check diagram id
# Line 181  Line 196 
196      $content .= "<DIV id='controlpanel'>$choose</DIV></TD><TR><TR><TD>";      $content .= "<DIV id='controlpanel'>$choose</DIV></TD><TR><TR><TD>";
197    
198      if ( $diagram_id ) {      if ( $diagram_id ) {
199    
200        # fetch the diagram        # fetch the diagram
201        my $diagram_dir = $subsystem->{dir}."/diagrams/$diagram_id/";        my $diagram_dir = $subsystem->{dir}."/diagrams/$diagram_id/";
202    
203          if ( !( -d $diagram_dir ) ) {
204            $errortext .= "<P>The given diagram can not be found</P>";
205          }
206    
207        my $d = $diagram_dir;        my $d = $diagram_dir;
208        if ( -f $diagram_dir.'diagram.png' ) {        if ( -f $diagram_dir.'diagram.png' ) {
209          $d = $diagram_dir.'diagram.png';          $d = $diagram_dir.'diagram.png';
# Line 207  Line 227 
227    
228        # add an info line about diagram scaling        # add an info line about diagram scaling
229        my $scaling_info;        my $scaling_info;
230        my $calculate_scale = 1;        if ( $scale == 1 ) {
       my $scale = $calculate_scale * 100;  
       if ( $scale == 100 ) {  
231          $scaling_info .= '<p><em>This diagram is not scaled.</em></p>';          $scaling_info .= '<p><em>This diagram is not scaled.</em></p>';
232        }        }
233        else {        else {
234          $scaling_info .= '<p><em>This diagram has been scaled to '.sprintf("%.2f", $scale).'%. ';          $scaling_info .= '<p><em>This diagram has been scaled to '.$scale.'%. ';
235          $scaling_info .= "(<a href='".$self->application->url()."?page=ShowDiagram&subsystem=$subsystem_name&diagram=$diagram_id&dont_scale=1'>".          $scaling_info .= "(<a href='".$self->application->url()."?page=ShowDiagram&subsystem=$subsystem_name&diagram=$diagram_id&dont_scale=1'>".
236            "view in original size</a>)";            "view in original size</a>)";
237          $scaling_info .= '</em></p>';          $scaling_info .= '</em></p>';
# Line 234  Line 252 
252      if ( $can_alter ) {      if ( $can_alter ) {
253        my $upload = $self->build_upload_diagram( $fig, $subsystem_name );        my $upload = $self->build_upload_diagram( $fig, $subsystem_name );
254        $content .= "$upload";        $content .= "$upload";
255    
256          my $delete = '';
257          if ( defined( $diagram_id ) ) {
258            $delete = $self->build_delete_diagram( $fig, $subsystem_name, $diagram_id );
259            $content .= "$delete";
260          }
261      }      }
262    
263      $content .= "</DIV></TD><TR></TABLE>";      $content .= "</DIV></TD><TR></TABLE>";
# Line 272  Line 296 
296      $counter++;      $counter++;
297    }    }
298    
299    my $diagramchoose = "<H2>Choose other diagram</H2>\n";    my $diagramchoose = "<H2>Choose other illustration</H2>\n";
300    if ( scalar( @ids ) == 1 ) {    if ( scalar( @ids ) == 1 ) {
301      $diagramchoose .= "<P>There is one illustration for this subsystem.</P>";      $diagramchoose .= "<P>There is one illustration for this subsystem.</P>";
302    }    }
# Line 286  Line 310 
310                                        -maxlength  => 150,                                        -maxlength  => 150,
311                                      );                                      );
312    
313    $diagramchoose .= $cgi->submit( -name => 'Show this diagram' );    $diagramchoose .= $cgi->submit( -name => 'Show this illustration' );
314    
315    return $diagramchoose;    return $diagramchoose;
316  }  }
# Line 299  Line 323 
323    
324    my ( $self, $fig, $subsystem_name ) = @_;    my ( $self, $fig, $subsystem_name ) = @_;
325    
326    my $diagramupload = "<H2>Upload new diagram</H2>\n";    my $diagramupload = "<H2>Upload new illustration</H2>\n";
327    $diagramupload .= "<A HREF='".$self->application->url()."?page=UploadDiagram&subsystem=$subsystem_name'>Upload a new diagram or change an existing one for this subsystem</A>";    $diagramupload .= "<A HREF='".$self->application->url()."?page=UploadDiagram&subsystem=$subsystem_name&illustration=1' target='_blank'>Upload a new illustration or change an existing one for this subsystem</A>";
328    
329      return $diagramupload;
330    
331    }
332    
333    ###################################
334    # build the little delete diagram #
335    ###################################
336    sub build_delete_diagram {
337    
338      my ( $self, $fig, $subsystem, $diagramid ) = @_;
339    
340      my $diagramdelete = "<H2>Delete currently shown illustration</H2>\n";
341    
342      my $deletebutton = "<INPUT TYPE=HIDDEN NAME='DIAGRAMID' ID='DIAGRAMID' VALUE='$diagramid'><INPUT TYPE=HIDDEN NAME='DELETEBUTTONPRESSED' ID='DELETEBUTTONPRESSED' VALUE=0><INPUT TYPE=BUTTON VALUE='Delete Illustration' NAME='DELETEDIAGRAMBUTTON' ID='DELETEDIAGRAMBUTTON' ONCLICK='if ( confirm( \"Do you really want to illustration the diagram $diagramid?\" ) ) {
343     document.getElementById( \"DELETEBUTTONPRESSED\" ).value = 1;
344     document.getElementById( \"diagram_select_genome\" ).submit(); }'>";
345    
346      $diagramdelete .= $deletebutton;
347    
348  }  }
349    
# Line 321  Line 364 
364    return ( $scale, $scale * $width, $scale * $height );    return ( $scale, $scale * $width, $scale * $height );
365  }  }
366    
367    sub delete_illustration {
368    
369      my ( $subsystem, $id ) = @_;
370    
371      $subsystem->delete_diagram( $id );
372    }

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3