--- loncom/xml/lonplot.pm 2002/04/23 15:21:36 1.65 +++ loncom/xml/lonplot.pm 2002/04/25 17:40:50 1.71 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Dynamic plot # -# $Id: lonplot.pm,v 1.65 2002/04/23 15:21:36 matthew Exp $ +# $Id: lonplot.pm,v 1.71 2002/04/25 17:40:50 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -104,7 +104,7 @@ my $onoff_test = sub {$_[0]=~/^(on|o my $key_pos_test = sub {$_[0]=~/^(top|bottom|right|left|outside|below| )+$/}; my $sml_test = sub {$_[0]=~/^(small|medium|large)$/}; my $linestyle_test = sub {exists($linestyles{$_[0]})}; -my $words_test = sub {$_[0]=~s/\s+/ /g;$_[0]=~/^([\w\(\)]+ ?)+$/}; +my $words_test = sub {$_[0]=~s/\s+/ /g;$_[0]=~/^([\w~!\@\#\$\%^&\*\(\)-=_\+\[\]\{\}:\;\'<>,\.\/\?\\]+ ?)+$/}; ################################################################### ## ## @@ -484,23 +484,22 @@ sub end_gnuplot { ## Determine filename my $tmpdir = '/home/httpd/perl/tmp/'; my $filename = $ENV{'user.name'}.'_'.$ENV{'user.domain'}. - '_'.time.'_'.$$.$randnumber.'_plot.data'; + '_'.time.'_'.$$.$randnumber.'_plot'; ## Write the plot description to the file &write_gnuplot_file($tmpdir,$filename,$target); $filename = &Apache::lonnet::escape($filename); ## return image tag for the plot if ($target eq 'web') { $result .= <<"ENDIMAGE"; -$plot{'alttag'} ENDIMAGE } elsif ($target eq 'tex') { - &Apache::lonnet::ssi('cgi-bin/plot.gif?file=$filename'. - '&output=eps'); - $result = "$filename.eps"; + &Apache::lonnet::ssi("/cgi-bin/plot.gif?file=$filename.data&output=eps"); + $result = '\\\\ \graphicspath{/home/httpd/perl/tmp/}\fbox{\includegraphics[width=9.0 cm]{'.&Apache::lonnet::unescape($filename).'.eps}} \\\\'; } } elsif ($target eq 'edit') { $result.=&Apache::edit::tag_end($target,$token); @@ -992,14 +991,16 @@ sub write_gnuplot_file { $gnuplot_input .= "set output\n"; } elsif ($target eq 'tex') { $gnuplot_input .= "set term postscript eps monochrome\n"; - $gnuplot_input .= "set output \"$filename.eps\"\n"; + $gnuplot_input .= "set output \"/home/httpd/perl/tmp/". + &Apache::lonnet::unescape($filename).".eps\"\n"; } # grid $gnuplot_input .= 'set grid'.$/ if ($plot{'grid'} eq 'on'); # border $gnuplot_input .= ($plot{'border'} eq 'on'? 'set border'.$/ : - 'set noborder'.$/ ); # title, xlabel, ylabel + 'set noborder'.$/ ); + # title, xlabel, ylabel # titles $gnuplot_input .= "set title \"$title\"\n" if (defined($title)) ; $gnuplot_input .= "set xlabel \"$xlabel\"\n" if (defined($xlabel)); @@ -1028,7 +1029,7 @@ sub write_gnuplot_file { if (%key) { $gnuplot_input .= 'set key '.$key{'pos'}.' '; if ($key{'title'} ne '') { - $gnuplot_input .= 'title " '.$key{'title'}.'" '; + $gnuplot_input .= 'title "'.$key{'title'}.'" '; } $gnuplot_input .= ($key{'box'} eq 'on' ? 'box ' : 'nobox ').$/; } else { @@ -1067,7 +1068,7 @@ sub write_gnuplot_file { # Store data values in $datatext my $datatext = ''; # get new filename - my $datafilename = "$tmpdir/$filename.$i"; + my $datafilename = "$tmpdir/$filename.data.$i"; my $fh=Apache::File->new(">$datafilename"); # Compile data my @Data = @{$curve->{'data'}}; @@ -1098,7 +1099,7 @@ sub write_gnuplot_file { } } # Write the output to a file. - my $fh=Apache::File->new(">$tmpdir$filename"); + my $fh=Apache::File->new(">$tmpdir$filename.data"); print $fh $gnuplot_input; close($fh); # That's all folks.