[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.7, Sat Jan 29 22:28:01 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 207  Line 233 
233    
234        # add an info line about diagram scaling        # add an info line about diagram scaling
235        my $scaling_info;        my $scaling_info;
236        my $calculate_scale = 1;        if ( $scale == 1 ) {
       my $scale = $calculate_scale * 100;  
       if ( $scale == 100 ) {  
237          $scaling_info .= '<p><em>This diagram is not scaled.</em></p>';          $scaling_info .= '<p><em>This diagram is not scaled.</em></p>';
238        }        }
239        else {        else {
240          $scaling_info .= '<p><em>This diagram has been scaled to '.sprintf("%.2f", $scale).'%. ';          $scaling_info .= '<p><em>This diagram has been scaled to '.$scale.'%. ';
241          $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'>".
242            "view in original size</a>)";            "view in original size</a>)";
243          $scaling_info .= '</em></p>';          $scaling_info .= '</em></p>';
244        }        }
245        if ( $cgi->param( 'dont_scale' ) ) {        if ( $cgi->param( 'dont_scale' ) ) {
246          $scaling_info .= '<p><em>You have switched off scaling this diagram down. ';          $scaling_info .= '<p><em>You have switched off scaling this diagram down. ';
247          $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'>".
248            "Allow scaling</a>)";            "Allow scaling</a>)";
249          $scaling_info .= '</em></p>';          $scaling_info .= '</em></p>';
250        }        }
# Line 232  Line 256 
256    
257      # upload diagram only if can_alter #      # upload diagram only if can_alter #
258      if ( $can_alter ) {      if ( $can_alter ) {
259        my $upload = $self->build_upload_diagram( $fig, $subsystem_name );        my $upload = $self->build_upload_diagram( $fig, $esc_name );
260        $content .= "$upload";        $content .= "$upload";
261    
262          my $delete = '';
263          if ( defined( $diagram_id ) ) {
264            $delete = $self->build_delete_diagram( $fig, $esc_name, $diagram_id );
265            $content .= "$delete";
266          }
267      }      }
268    
269      $content .= "</DIV></TD><TR></TABLE>";      $content .= "</DIV></TD><TR></TABLE>";
270    
271      # hiddens for subsystem, diagram, scale #      # hiddens for subsystem, diagram, scale #
272      $content .= $cgi->hidden( -name  => 'subsystem',      $content .= $cgi->hidden( -name  => 'subsystem',
273                                -value => $subsystem_name );                                -value => $esc_name );
274      $content .= $cgi->hidden( -name  => 'diagram',      $content .= $cgi->hidden( -name  => 'diagram',
275                                -value => $diagram_id );                                -value => $diagram_id );
276    
# Line 272  Line 302 
302      $counter++;      $counter++;
303    }    }
304    
305    my $diagramchoose = "<H2>Choose other diagram</H2>\n";    my $diagramchoose = "<H2>Choose other illustration</H2>\n";
306    if ( scalar( @ids ) == 1 ) {    if ( scalar( @ids ) == 1 ) {
307      $diagramchoose .= "<P>There is one illustration for this subsystem.</P>";      $diagramchoose .= "<P>There is one illustration for this subsystem.</P>";
308    }    }
# Line 286  Line 316 
316                                        -maxlength  => 150,                                        -maxlength  => 150,
317                                      );                                      );
318    
319    $diagramchoose .= $cgi->submit( -name => 'Show this diagram' );    $diagramchoose .= $cgi->submit( -name => 'Show this illustration' );
320    
321    return $diagramchoose;    return $diagramchoose;
322  }  }
# Line 299  Line 329 
329    
330    my ( $self, $fig, $subsystem_name ) = @_;    my ( $self, $fig, $subsystem_name ) = @_;
331    
332    my $diagramupload = "<H2>Upload new diagram</H2>\n";    my $diagramupload = "<H2>Upload new illustration</H2>\n";
333    $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>";
334    
335      return $diagramupload;
336    
337    }
338    
339    ###################################
340    # build the little delete diagram #
341    ###################################
342    sub build_delete_diagram {
343    
344      my ( $self, $fig, $subsystem, $diagramid ) = @_;
345    
346      my $diagramdelete = "<H2>Delete currently shown illustration</H2>\n";
347    
348      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?\" ) ) {
349     document.getElementById( \"DELETEBUTTONPRESSED\" ).value = 1;
350     document.getElementById( \"diagram_select_genome\" ).submit(); }'>";
351    
352      $diagramdelete .= $deletebutton;
353    
354  }  }
355    
# Line 321  Line 370 
370    return ( $scale, $scale * $width, $scale * $height );    return ( $scale, $scale * $width, $scale * $height );
371  }  }
372    
373    sub delete_illustration {
374    
375      my ( $subsystem, $id ) = @_;
376    
377      $subsystem->delete_diagram( $id );
378    }

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3