[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 18 Jul 2006 18:19:51 -0000
albertel Tue Jul 18 14:19:51 2006 EDT
Modified files:
/loncom/interface lonprintout.pm
Log:
- xhtml
- turn back on the regexp rewriting of the page dimesions for 2 column mode
- simplify the code setting up the default page sizes
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.463 loncom/interface/lonprintout.pm:1.464
--- loncom/interface/lonprintout.pm:1.463 Mon Jul 17 19:11:10 2006
+++ loncom/interface/lonprintout.pm Tue Jul 18 14:19:51 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.463 2006/07/17 23:11:10 foxr Exp $
+# $Id: lonprintout.pm,v 1.464 2006/07/18 18:19:51 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1759,12 +1759,12 @@
$selectionmade,
$helper->{'VARS'}->{'ANSWER_TYPE'});
}
- if ($numberofcolumns == 1) {
+ #if ($numberofcolumns == 1) {
$result =~ s/\\textwidth\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textwidth= $helper->{'VARS'}->{'pagesize.width'} $helper->{'VARS'}->{'pagesize.widthunit'} /;
$result =~ s/\\textheight\s*=?\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textheight $helper->{'VARS'}->{'pagesize.height'} $helper->{'VARS'}->{'pagesize.heightunit'} /;
$result =~ s/\\evensidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\evensidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /;
$result =~ s/\\oddsidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\oddsidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /;
- }
+ #}
#-- writing .tex file in prtspool
my $temp_file;
@@ -2979,7 +2979,7 @@
my $var = $self->{'variable'};
if (defined $self->{ERROR_MSG}) {
- $result .= '<br /><font color="#FF0000">' . $self->{ERROR_MSG} . '</font><br />';
+ $result .= '<br /><span class="LC_error">' . $self->{ERROR_MSG} . '</span><br />';
}
my $format = $helper->{VARS}->{$self->{'formatvar'}};
@@ -2998,78 +2998,63 @@
}
-
- my ($width_and_units,
- $height_and_units,
- $margin_and_units) =
- &Apache::lonprintout::page_format($papersize, $laystyle, $cols);
-
-
- my ($width, $wunits) = split(/ /, $width_and_units);
- my ($height, $hunits) = split(/ /, $height_and_units);
- my ($margin, $munits) = split(/ /, $margin_and_units);
-
-
-
- # This code is a bit ugly and not very scalable with additional units.
- # but I'm not sure my poor perlmanship knows a better way yet RF
-
- my ($wuoptions, $huoptions, $muoptions);
+ my %size;
+ ($size{'width_and_units'},
+ $size{'height_and_units'},
+ $size{'margin_and_units'})=
+ &Apache::lonprintout::page_format($papersize, $laystyle, $cols);
- if ($wunits eq 'cm') {
- $wuoptions = '<option>cm</option><option>in</option>';
- } else {
- $wuoptions = '<option>in</option><option>cm</option>';
- }
- if ($hunits eq 'cm') {
- $huoptions = '<option>cm</option><option>in</option>';
- } else {
- $huoptions = '<option>in</option><option>cm</option>';
- }
- if ($munits eq 'cm') {
- $muoptions = '<option>cm</option><option>in</option>';
- } else {
- $muoptions = '<option>in</option><option>cm</option>';
+ foreach my $dimension ('width','height','margin') {
+ ($size{$dimension},$size{$dimension.'_unit'}) =
+ split(/ +/, $size{$dimension.'_and_units'},2);
+
+ foreach my $unit ('cm','in') {
+ $size{$dimension.'_options'} .= '<option ';
+ if ($size{$dimension.'_unit'} eq $unit) {
+ $size{$dimension.'_options'} .= 'selected="selected" ';
+ }
+ $size{$dimension.'_options'} .= '>'.$unit.'</option>';
+ }
}
$result .= <<ELEMENTHTML;
-<p>How should the column be formatted?</p>
+<p>How should each column be formatted?</p>
<table cellpadding='3'>
<tr>
<td align='right'><b>Width</b>:</td>
- <td align='left'><input type='text' name='$var.width' value="$width" size='4'></td>
+ <td align='left'><input type='text' name='$var.width' value="$size{'width'}" size='4' /></td>
<td align='left'>
<select name='$var.widthunit'>
- $wuoptions
+ $size{'width_options'}
</select>
</td>
</tr>
<tr>
<td align='right'><b>Height</b>:</td>
- <td align='left'><input type='text' name="$var.height" value="$height" size='4'></td>
+ <td align='left'><input type='text' name="$var.height" value="$size{'height'}" size='4' /></td>
<td align='left'>
<select name='$var.heightunit'>
- $huoptions
+ $size{'height_options'}
</select>
</td>
</tr>
<tr>
<td align='right'><b>Left margin</b>:</td>
- <td align='left'><input type='text' name='$var.lmargin' value="$margin" size='4'></td>
+ <td align='left'><input type='text' name='$var.lmargin' value="$size{'margin'}" size='4' /></td>
<td align='left'>
<select name='$var.lmarginunit'>
- $muoptions
+ $size{'margin_options'}
</select>
</td>
</tr>
</table>
-<p>Hint: Some instructors like to leave scratch space for the student by
-making the width much smaller than the width of the page.</p>
+<!--<p>Hint: Some instructors like to leave scratch space for the student by
+making the width much smaller than the width of the page.</p>-->
ELEMENTHTML
@@ -3103,13 +3088,13 @@
# /^-?[0-9]+(\.[0-9]*)?$/ -> optional minus, at least on digit, followed
# by an optional period, followed by digits, ending the string
- if ($width !~ /^-?[0-9]+(\.[0-9]*)?$/) {
+ if ($width !~ /^-?[0-9]*(\.[0-9]*)?$/) {
$error .= "Invalid width; please type only a number.<br />\n";
}
- if ($height !~ /^-?[0-9]+(\.[0-9]*)?$/) {
+ if ($height !~ /^-?[0-9]*(\.[0-9]*)?$/) {
$error .= "Invalid height; please type only a number.<br />\n";
}
- if ($lmargin !~ /^-?[0-9]+(\.[0-9]*)?$/) {
+ if ($lmargin !~ /^-?[0-9]*(\.[0-9]*)?$/) {
$error .= "Invalid left margin; please type only a number.<br />\n";
}