[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.5, Mon May 5 19:34:28 2008 UTC
# Line 46  Line 46 
46    my $ssname = $name;    my $ssname = $name;
47    $ssname =~ s/\_/ /g;    $ssname =~ s/\_/ /g;
48    
49      my $esc_name = uri_escape($name);
50    
51      my $subsystem = new Subsystem( $name, $fig, 0 );
52    
53    # look if someone is logged in and can write the subsystem #    # look if someone is logged in and can write the subsystem #
54    my $can_alter = 0;    my $can_alter = 0;
55    my $user = $self->application->session->user;    my $user = $self->application->session->user;
# Line 60  Line 64 
64    my $menu = $self->application->menu();    my $menu = $self->application->menu();
65    
66    # Build nice tab menu here    # Build nice tab menu here
67    $menu->add_category( 'Subsystem Info', "SubsysEditor.cgi?page=ShowSubsystem&subsystem=$name" );    $menu->add_category( 'Subsystem Info', "SubsysEditor.cgi?page=ShowSubsystem&subsystem=$esc_name" );
68    $menu->add_category( 'Functional Roles', "SubsysEditor.cgi?page=ShowFunctionalRoles&subsystem=$name" );    $menu->add_category( 'Functional Roles', "SubsysEditor.cgi?page=ShowFunctionalRoles&subsystem=$esc_name" );
69    $menu->add_category( 'Diagram', "SubsysEditor.cgi?page=ShowDiagram&subsystem=$name" );    $menu->add_category( 'Diagram', "SubsysEditor.cgi?page=ShowDiagram&subsystem=$esc_name" );
70    $menu->add_category( 'Illustrations', "SubsysEditor.cgi?page=ShowIllustrations&subsystem=$name" );    $menu->add_category( 'Illustrations', "SubsysEditor.cgi?page=ShowIllustrations&subsystem=$esc_name" );
71    $menu->add_category( 'Spreadsheet', "SubsysEditor.cgi?page=ShowSpreadsheet&subsystem=$name" );    $menu->add_category( 'Spreadsheet', "SubsysEditor.cgi?page=ShowSpreadsheet&subsystem=$esc_name" );
72    $menu->add_category( 'Show Check', "SubsysEditor.cgi?page=ShowCheck&subsystem=$name" );    $menu->add_category( 'Show Check', "SubsysEditor.cgi?page=ShowCheck&subsystem=$esc_name" );
73    $menu->add_category( 'Show Tree', "SubsysEditor.cgi?page=ShowTree&subsystem=$name" );    $menu->add_category( 'Show Connections', "SubsysEditor.cgi?page=ShowTree&subsystem=$esc_name" );
74    
75    my $error = '';    my $error = '';
76    my $comment = '';    my $comment = '';
77    
78      #########
79      # TASKS #
80      #########
81    
82      if ( defined( $cgi->param( 'DELETEBUTTONPRESSED' ) ) && $cgi->param( 'DELETEBUTTONPRESSED' ) == 1 ) {
83        my $diagramid = $cgi->param( 'DIAGRAMID' );
84        &delete_illustration( $subsystem, $diagramid );
85        $cgi->delete( 'diagram' );
86        $cgi->delete( 'DIAGRAMID' );
87        $cgi->delete( 'diagram_selectbox' );
88      }
89    
90    ##############################    ##############################
91    # Construct the page content #    # Construct the page content #
92    ##############################    ##############################
# Line 131  Line 147 
147      $subsystem_pretty =~ s/_/ /g;      $subsystem_pretty =~ s/_/ /g;
148      my ( $subsystem, $newDiagrams, $defaultDiagram ) = get_data( $fig, $subsystem_name );      my ( $subsystem, $newDiagrams, $defaultDiagram ) = get_data( $fig, $subsystem_name );
149    
150        my $esc_name = uri_escape($subsystem_name);
151    
152      # check subsystem      # check subsystem
153      unless ( $subsystem ) {      unless ( $subsystem ) {
154        return "<p>Unable to find a subsystem called '$subsystem_name'.</p>";        return "<p>Unable to find a subsystem called '$subsystem_name'.</p>";
# Line 149  Line 167 
167      # print out an error message if there is no 'new' diagram      # print out an error message if there is no 'new' diagram
168      my $diagram_id  = $cgi->param( 'diagram' ) || $cgi->param( 'diagram_selectbox' ) || '';      my $diagram_id  = $cgi->param( 'diagram' ) || $cgi->param( 'diagram_selectbox' ) || '';
169    
170      if ( defined( $cgi->param( 'Show this diagram' ) ) ) {      if ( defined( $cgi->param( 'Show this illustration' ) ) ) {
171        $diagram_id = $cgi->param( 'diagram_selectbox' );        $diagram_id = $cgi->param( 'diagram_selectbox' );
172      }      }
173    
174      unless ( $diagram_id ) {      unless ( $diagram_id ) {
175        $diagram_id = $defaultDiagram;        $diagram_id = $defaultDiagram;
176          $cgi->param( 'diagram_selectbox', $diagram_id );
177      }      }
178    
179      # check diagram id      # check diagram id
# Line 181  Line 200 
200      $content .= "<DIV id='controlpanel'>$choose</DIV></TD><TR><TR><TD>";      $content .= "<DIV id='controlpanel'>$choose</DIV></TD><TR><TR><TD>";
201    
202      if ( $diagram_id ) {      if ( $diagram_id ) {
203    
204        # fetch the diagram        # fetch the diagram
205        my $diagram_dir = $subsystem->{dir}."/diagrams/$diagram_id/";        my $diagram_dir = $subsystem->{dir}."/diagrams/$diagram_id/";
206    
207          if ( !( -d $diagram_dir ) ) {
208            $errortext .= "<P>The given diagram can not be found</P>";
209          }
210    
211        my $d = $diagram_dir;        my $d = $diagram_dir;
212        if ( -f $diagram_dir.'diagram.png' ) {        if ( -f $diagram_dir.'diagram.png' ) {
213          $d = $diagram_dir.'diagram.png';          $d = $diagram_dir.'diagram.png';
# Line 207  Line 231 
231    
232        # add an info line about diagram scaling        # add an info line about diagram scaling
233        my $scaling_info;        my $scaling_info;
234        my $calculate_scale = 1;        if ( $scale == 1 ) {
       my $scale = $calculate_scale * 100;  
       if ( $scale == 100 ) {  
235          $scaling_info .= '<p><em>This diagram is not scaled.</em></p>';          $scaling_info .= '<p><em>This diagram is not scaled.</em></p>';
236        }        }
237        else {        else {
238          $scaling_info .= '<p><em>This diagram has been scaled to '.sprintf("%.2f", $scale).'%. ';          $scaling_info .= '<p><em>This diagram has been scaled to '.$scale.'%. ';
239          $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=ShowIllustrations&subsystem=$esc_name&diagram=$diagram_id&dont_scale=1'>".
240            "view in original size</a>)";            "view in original size</a>)";
241          $scaling_info .= '</em></p>';          $scaling_info .= '</em></p>';
242        }        }
243        if ( $cgi->param( 'dont_scale' ) ) {        if ( $cgi->param( 'dont_scale' ) ) {
244          $scaling_info .= '<p><em>You have switched off scaling this diagram down. ';          $scaling_info .= '<p><em>You have switched off scaling this diagram down. ';
245          $scaling_info .= "(<a href='".$self->application->url()."?page=ShowDiagram&subsystem=$subsystem_name&diagram=$diagram_id'>".          $scaling_info .= "(<a href='".$self->application->url()."?page=ShowIllustrations&subsystem=$esc_name&diagram=$diagram_id'>".
246            "Allow scaling</a>)";            "Allow scaling</a>)";
247          $scaling_info .= '</em></p>';          $scaling_info .= '</em></p>';
248        }        }
# Line 232  Line 254 
254    
255      # upload diagram only if can_alter #      # upload diagram only if can_alter #
256      if ( $can_alter ) {      if ( $can_alter ) {
257        my $upload = $self->build_upload_diagram( $fig, $subsystem_name );        my $upload = $self->build_upload_diagram( $fig, $esc_name );
258        $content .= "$upload";        $content .= "$upload";
259    
260          my $delete = '';
261          if ( defined( $diagram_id ) ) {
262            $delete = $self->build_delete_diagram( $fig, $esc_name, $diagram_id );
263            $content .= "$delete";
264          }
265      }      }
266    
267      $content .= "</DIV></TD><TR></TABLE>";      $content .= "</DIV></TD><TR></TABLE>";
268    
269      # hiddens for subsystem, diagram, scale #      # hiddens for subsystem, diagram, scale #
270      $content .= $cgi->hidden( -name  => 'subsystem',      $content .= $cgi->hidden( -name  => 'subsystem',
271                                -value => $subsystem_name );                                -value => $esc_name );
272      $content .= $cgi->hidden( -name  => 'diagram',      $content .= $cgi->hidden( -name  => 'diagram',
273                                -value => $diagram_id );                                -value => $diagram_id );
274    
# Line 272  Line 300 
300      $counter++;      $counter++;
301    }    }
302    
303    my $diagramchoose = "<H2>Choose other diagram</H2>\n";    my $diagramchoose = "<H2>Choose other illustration</H2>\n";
304    if ( scalar( @ids ) == 1 ) {    if ( scalar( @ids ) == 1 ) {
305      $diagramchoose .= "<P>There is one illustration for this subsystem.</P>";      $diagramchoose .= "<P>There is one illustration for this subsystem.</P>";
306    }    }
# Line 286  Line 314 
314                                        -maxlength  => 150,                                        -maxlength  => 150,
315                                      );                                      );
316    
317    $diagramchoose .= $cgi->submit( -name => 'Show this diagram' );    $diagramchoose .= $cgi->submit( -name => 'Show this illustration' );
318    
319    return $diagramchoose;    return $diagramchoose;
320  }  }
# Line 299  Line 327 
327    
328    my ( $self, $fig, $subsystem_name ) = @_;    my ( $self, $fig, $subsystem_name ) = @_;
329    
330    my $diagramupload = "<H2>Upload new diagram</H2>\n";    my $diagramupload = "<H2>Upload new illustration</H2>\n";
331    $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>";
332    
333      return $diagramupload;
334    
335    }
336    
337    ###################################
338    # build the little delete diagram #
339    ###################################
340    sub build_delete_diagram {
341    
342      my ( $self, $fig, $subsystem, $diagramid ) = @_;
343    
344      my $diagramdelete = "<H2>Delete currently shown illustration</H2>\n";
345    
346      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?\" ) ) {
347     document.getElementById( \"DELETEBUTTONPRESSED\" ).value = 1;
348     document.getElementById( \"diagram_select_genome\" ).submit(); }'>";
349    
350      $diagramdelete .= $deletebutton;
351    
352  }  }
353    
# Line 321  Line 368 
368    return ( $scale, $scale * $width, $scale * $height );    return ( $scale, $scale * $width, $scale * $height );
369  }  }
370    
371    sub delete_illustration {
372    
373      my ( $subsystem, $id ) = @_;
374    
375      $subsystem->delete_diagram( $id );
376    }

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3