[system] / trunk / pg / lib / PGalias.pm Repository:
ViewVC logotype

Diff of /trunk/pg/lib/PGalias.pm

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

Revision 6260 Revision 6261
1################################################################################ 1################################################################################
2# WeBWorK Online Homework Delivery System 2# WeBWorK Online Homework Delivery System
3# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ 3# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
4# $CVSHeader: pg/lib/PGalias.pm,v 1.4 2010/05/14 15:44:55 gage Exp $ 4# $CVSHeader: pg/lib/PGalias.pm,v 1.5 2010/05/15 01:53:57 gage Exp $
5# 5#
6# This program is free software; you can redistribute it and/or modify it under 6# This program is free software; you can redistribute it and/or modify it under
7# the terms of either: (a) the GNU General Public License as published by the 7# the terms of either: (a) the GNU General Public License as published by the
8# Free Software Foundation; either version 2, or (at your option) any later 8# Free Software Foundation; either version 2, or (at your option) any later
9# version, or (b) the "Artistic License" which comes with this package. 9# version, or (b) the "Artistic License" which comes with this package.
158 my $self = shift; 158 my $self = shift;
159 # input is a path to the original auxiliary file 159 # input is a path to the original auxiliary file
160 my $aux_file_path = shift @_; 160 my $aux_file_path = shift @_;
161 my $resource_alias = new PGresource($aux_file_path); # just call it alias? FIXME -- not in use yet. 161 my $resource_alias = new PGresource($aux_file_path); # just call it alias? FIXME -- not in use yet.
162 162
163 # warn "make alias for $aux_file_path";
164 warn "Empty string used as input into the function alias" unless $aux_file_path; 163 warn "Empty string used as input into the function alias" unless $aux_file_path;
165 164
166 my $displayMode = $self->{displayMode}; 165 my $displayMode = $self->{displayMode};
167 my $fileName = $self->{fileName}; # name of .pg file 166 my $fileName = $self->{fileName}; # name of .pg file
168 my $envir = $self->{envir}; 167 my $envir = $self->{envir};
458 if ($aux_file_path =~ m/^$htmlDirectory/ or $aux_file_path =~ m/^$tempDirectory/) { 457 if ($aux_file_path =~ m/^$htmlDirectory/ or $aux_file_path =~ m/^$tempDirectory/) {
459 # we've got a full pathname to a file 458 # we've got a full pathname to a file
460 $gifFilePath = "$aux_file_path.gif"; 459 $gifFilePath = "$aux_file_path.gif";
461 } else { 460 } else {
462 # we assume the file is in the same directory as the problem source file 461 # we assume the file is in the same directory as the problem source file
463 $gifFilePath = $templateDirectory . ($self->directoryFromPath($fileName)) . "$aux_file_path.gif"; 462 my $dir = $self->directoryFromPath($fileName);
463 $gifFilePath = "$templateDirectory${dir}$aux_file_path.gif";
464 } 464 }
465 465
466 my $gifFileName = $self->fileFromPath($gifFilePath); 466 my $gifFileName = $self->fileFromPath($gifFilePath);
467
468 $gifFileName =~ /^(.*)\.gif$/; 467 $gifFileName =~ /^(.*)\.gif$/;
469 my $pngFilePath = $self->surePathToTmpFile("${tempDirectory}png/$setNumber-$probNum-$1.png"); 468 my $pngFilePath = $self->surePathToTmpFile("${tempDirectory}png/$setNumber-$probNum-$1.png");
469 my $command = $envir->{externalGif2PngPath};
470 my $returnCode = system "cat $gifFilePath | ${$envir->{externalGif2PngPath}} > $pngFilePath"; 470 my $returnCode = system "cat $gifFilePath | $command > $pngFilePath";
471 471 #warn "FILE path $pngFilePath exists =", -e $pngFilePath;
472 if ($returnCode or not -e $pngFilePath) { 472 if ($returnCode or not -e $pngFilePath) {
473 die "failed to convert $gifFilePath to $pngFilePath using gif->png with ${$envir->{externalGif2PngPath}}: $!\n"; 473 warn "returnCode $returnCode: failed to convert $gifFilePath to $pngFilePath using gif->png with $command: $!";
474 } 474 }
475 475
476 $adr_output = $pngFilePath; 476 $adr_output = $pngFilePath;
477 } else { 477 } else {
478 # Since we're not creating PDF files; we're probably just using a plain 478 # Since we're not creating PDF files; we're probably just using a plain
573 my $filePath = $self->directoryFromPath($fileName); 573 my $filePath = $self->directoryFromPath($fileName);
574 574
575 # $fileName is obtained from environment for PGeval 575 # $fileName is obtained from environment for PGeval
576 # it gives the full path to the current problem 576 # it gives the full path to the current problem
577 my $pngSourceFile = $self->convertPath("$templateDirectory${filePath}$aux_file_path.png"); 577 my $pngSourceFile = $self->convertPath("$templateDirectory${filePath}$aux_file_path.png");
578 my $uniqIDstub = $self->{uniqIDstub};
578 my $link = "gif/".$self->{uniqIDstub}."-$aux_file_path.$ext"; 579 my $link = "gif/${uniqIDstub}-$aux_file_path.$ext";
579 my $linkPath = $self->surePathToTmpFile($link); 580 my $linkPath = $self->surePathToTmpFile($link);
580 $adr_output = "${tempURL}$link"; 581 $adr_output = "${tempURL}$link";
581 #warn "linkPath is $linkPath"; 582 #warn "linkPath is $linkPath";
582 #warn "adr_output is $adr_output"; 583 #warn "adr_output is $adr_output";
583 if (-e $pngSourceFile) { 584 if (-e $pngSourceFile) {
633 if ($aux_file_path =~ m/^$htmlDirectory/ or $aux_file_path =~ m/^$tempDirectory/) { 634 if ($aux_file_path =~ m/^$htmlDirectory/ or $aux_file_path =~ m/^$tempDirectory/) {
634 # we've got a full pathname to a file 635 # we've got a full pathname to a file
635 $pngFilePath = "$aux_file_path.png"; 636 $pngFilePath = "$aux_file_path.png";
636 } else { 637 } else {
637 # we assume the file is in the same directory as the problem source file 638 # we assume the file is in the same directory as the problem source file
638 $pngFilePath = $templateDirectory . ($self->directoryFromPath($fileName)) . "$aux_file_path.png"; 639 my $dir = $self->directoryFromPath($fileName);
640 $pngFilePath = "$templateDirectory${dir}$aux_file_path.png";
639 } 641 }
640 642
641 $adr_output = $pngFilePath; 643 $adr_output = $pngFilePath;
642 } else { 644 } else {
643 # Since we're not creating PDF files; we're probably just using a plain 645 # Since we're not creating PDF files; we're probably just using a plain

Legend:
Removed from v.6260  
changed lines
  Added in v.6261

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9