[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.8, Mon Jan 31 19:08:11 2011 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( 'Subsets', "SubsysEditor.cgi?page=ShowSubsets&subsystem=$esc_name" );
70    $menu->add_category( 'Illustrations', "SubsysEditor.cgi?page=ShowIllustrations&subsystem=$name" );    $menu->add_category( 'Diagrams and Illustrations' );
71    $menu->add_category( 'Spreadsheet', "SubsysEditor.cgi?page=ShowSpreadsheet&subsystem=$name" );    $menu->add_entry( 'Diagrams and Illustrations', 'Diagram', "SubsysEditor.cgi?page=ShowDiagram&subsystem=$esc_name" );
72    $menu->add_category( 'Show Check', "SubsysEditor.cgi?page=ShowCheck&subsystem=$name" );    $menu->add_entry( 'Diagrams and Illustrations', 'Illustrations', "SubsysEditor.cgi?page=ShowIllustrations&subsystem=$esc_name" );
73    $menu->add_category( 'Show Tree', "SubsysEditor.cgi?page=ShowTree&subsystem=$name" );    $menu->add_category( 'Spreadsheet', "SubsysEditor.cgi?page=ShowSpreadsheet&subsystem=$esc_name" );
74      $menu->add_category( 'Show Check', "SubsysEditor.cgi?page=ShowCheck&subsystem=$esc_name" );
75      $menu->add_category( 'Show Connections', "SubsysEditor.cgi?page=ShowTree&subsystem=$esc_name" );
76    
77    my $error = '';    my $error = '';
78    my $comment = '';    my $comment = '';
79    
80      #########
81      # TASKS #
82      #########
83    
84      if ( defined( $cgi->param( 'DELETEBUTTONPRESSED' ) ) && $cgi->param( 'DELETEBUTTONPRESSED' ) == 1 ) {
85        my $diagramid = $cgi->param( 'DIAGRAMID' );
86        &delete_illustration( $subsystem, $diagramid );
87        $cgi->delete( 'diagram' );
88        $cgi->delete( 'DIAGRAMID' );
89        $cgi->delete( 'diagram_selectbox' );
90      }
91    
92    ##############################    ##############################
93    # Construct the page content #    # Construct the page content #
94    ##############################    ##############################
# Line 131  Line 149 
149      $subsystem_pretty =~ s/_/ /g;      $subsystem_pretty =~ s/_/ /g;
150      my ( $subsystem, $newDiagrams, $defaultDiagram ) = get_data( $fig, $subsystem_name );      my ( $subsystem, $newDiagrams, $defaultDiagram ) = get_data( $fig, $subsystem_name );
151    
152        my $esc_name = uri_escape($subsystem_name);
153    
154      # check subsystem      # check subsystem
155      unless ( $subsystem ) {      unless ( $subsystem ) {
156        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 169 
169      # print out an error message if there is no 'new' diagram      # print out an error message if there is no 'new' diagram
170      my $diagram_id  = $cgi->param( 'diagram' ) || $cgi->param( 'diagram_selectbox' ) || '';      my $diagram_id  = $cgi->param( 'diagram' ) || $cgi->param( 'diagram_selectbox' ) || '';
171    
172      if ( defined( $cgi->param( 'Show this diagram' ) ) ) {      if ( defined( $cgi->param( 'Show this illustration' ) ) ) {
173        $diagram_id = $cgi->param( 'diagram_selectbox' );        $diagram_id = $cgi->param( 'diagram_selectbox' );
174      }      }
175    
176      unless ( $diagram_id ) {      unless ( $diagram_id ) {
177        $diagram_id = $defaultDiagram;        $diagram_id = $defaultDiagram;
178          $cgi->param( 'diagram_selectbox', $diagram_id );
179      }      }
180    
181      # check diagram id      # check diagram id
# Line 181  Line 202 
202      $content .= "<DIV id='controlpanel'>$choose</DIV></TD><TR><TR><TD>";      $content .= "<DIV id='controlpanel'>$choose</DIV></TD><TR><TR><TD>";
203    
204      if ( $diagram_id ) {      if ( $diagram_id ) {
205    
206        # fetch the diagram        # fetch the diagram
207        my $diagram_dir = $subsystem->{dir}."/diagrams/$diagram_id/";        my $diagram_dir = $subsystem->{dir}."/diagrams/$diagram_id/";
208    
209          if ( !( -d $diagram_dir ) ) {
210            $errortext .= "<P>The given diagram can not be found</P>";
211          }
212    
213        my $d = $diagram_dir;        my $d = $diagram_dir;
214        if ( -f $diagram_dir.'diagram.png' ) {        if ( -f $diagram_dir.'diagram.png' ) {
215          $d = $diagram_dir.'diagram.png';          $d = $diagram_dir.'diagram.png';
# Line 196  Line 222 
222        }        }
223    
224        # print diagram        # print diagram
225        my $image = new WebGD( $d );        my $image = WebGD->new( $d );
226    
227    
228        my ( $width, $height ) = ( $image->getBounds() );        my ( $width, $height ) = ( $image->getBounds() );
229    
230        unless ( $cgi->param( 'dont_scale' ) ) {        unless ( $cgi->param( 'dont_scale' ) ) {
# Line 207  Line 235 
235    
236        # add an info line about diagram scaling        # add an info line about diagram scaling
237        my $scaling_info;        my $scaling_info;
238        my $calculate_scale = 1;        if ( $scale == 1 ) {
       my $scale = $calculate_scale * 100;  
       if ( $scale == 100 ) {  
239          $scaling_info .= '<p><em>This diagram is not scaled.</em></p>';          $scaling_info .= '<p><em>This diagram is not scaled.</em></p>';
240        }        }
241        else {        else {
242          $scaling_info .= '<p><em>This diagram has been scaled to '.sprintf("%.2f", $scale).'%. ';          $scaling_info .= '<p><em>This diagram has been scaled to '.$scale.'%. ';
243          $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'>".
244            "view in original size</a>)";            "view in original size</a>)";
245          $scaling_info .= '</em></p>';          $scaling_info .= '</em></p>';
246        }        }
247        if ( $cgi->param( 'dont_scale' ) ) {        if ( $cgi->param( 'dont_scale' ) ) {
248          $scaling_info .= '<p><em>You have switched off scaling this diagram down. ';          $scaling_info .= '<p><em>You have switched off scaling this diagram down. ';
249          $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'>".
250            "Allow scaling</a>)";            "Allow scaling</a>)";
251          $scaling_info .= '</em></p>';          $scaling_info .= '</em></p>';
252        }        }
# Line 232  Line 258 
258    
259      # upload diagram only if can_alter #      # upload diagram only if can_alter #
260      if ( $can_alter ) {      if ( $can_alter ) {
261        my $upload = $self->build_upload_diagram( $fig, $subsystem_name );        my $upload = $self->build_upload_diagram( $fig, $esc_name );
262        $content .= "$upload";        $content .= "$upload";
263    
264          my $delete = '';
265          if ( defined( $diagram_id ) ) {
266            $delete = $self->build_delete_diagram( $fig, $esc_name, $diagram_id );
267            $content .= "$delete";
268          }
269      }      }
270    
271      $content .= "</DIV></TD><TR></TABLE>";      $content .= "</DIV></TD><TR></TABLE>";
272    
273      # hiddens for subsystem, diagram, scale #      # hiddens for subsystem, diagram, scale #
274      $content .= $cgi->hidden( -name  => 'subsystem',      $content .= $cgi->hidden( -name  => 'subsystem',
275                                -value => $subsystem_name );                                -value => $esc_name );
276      $content .= $cgi->hidden( -name  => 'diagram',      $content .= $cgi->hidden( -name  => 'diagram',
277                                -value => $diagram_id );                                -value => $diagram_id );
278    
# Line 272  Line 304 
304      $counter++;      $counter++;
305    }    }
306    
307    my $diagramchoose = "<H2>Choose other diagram</H2>\n";    my $diagramchoose = "<H2>Choose other illustration</H2>\n";
308    if ( scalar( @ids ) == 1 ) {    if ( scalar( @ids ) == 1 ) {
309      $diagramchoose .= "<P>There is one illustration for this subsystem.</P>";      $diagramchoose .= "<P>There is one illustration for this subsystem.</P>";
310    }    }
# Line 286  Line 318 
318                                        -maxlength  => 150,                                        -maxlength  => 150,
319                                      );                                      );
320    
321    $diagramchoose .= $cgi->submit( -name => 'Show this diagram' );    $diagramchoose .= $cgi->submit( -name => 'Show this illustration' );
322    
323    return $diagramchoose;    return $diagramchoose;
324  }  }
# Line 299  Line 331 
331    
332    my ( $self, $fig, $subsystem_name ) = @_;    my ( $self, $fig, $subsystem_name ) = @_;
333    
334    my $diagramupload = "<H2>Upload new diagram</H2>\n";    my $diagramupload = "<H2>Upload new illustration</H2>\n";
335    $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>";
336    
337      return $diagramupload;
338    
339    }
340    
341    ###################################
342    # build the little delete diagram #
343    ###################################
344    sub build_delete_diagram {
345    
346      my ( $self, $fig, $subsystem, $diagramid ) = @_;
347    
348      my $diagramdelete = "<H2>Delete currently shown illustration</H2>\n";
349    
350      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?\" ) ) {
351     document.getElementById( \"DELETEBUTTONPRESSED\" ).value = 1;
352     document.getElementById( \"diagram_select_genome\" ).submit(); }'>";
353    
354      $diagramdelete .= $deletebutton;
355    
356  }  }
357    
# Line 321  Line 372 
372    return ( $scale, $scale * $width, $scale * $height );    return ( $scale, $scale * $width, $scale * $height );
373  }  }
374    
375    sub delete_illustration {
376    
377      my ( $subsystem, $id ) = @_;
378    
379      $subsystem->delete_diagram( $id );
380    }

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3