Diff for /loncom/interface/lonprintout.pm between versions 1.463 and 1.464

version 1.463, 2006/07/17 23:11:10 version 1.464, 2006/07/18 18:19:51
Line 1759  ENDPART Line 1759  ENDPART
        $selectionmade,          $selectionmade, 
        $helper->{'VARS'}->{'ANSWER_TYPE'});         $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/\\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/\\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/\\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'} /;   $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   #-- writing .tex file in prtspool 
     my $temp_file;      my $temp_file;
Line 2979  sub render { Line 2979  sub render {
     my $var = $self->{'variable'};      my $var = $self->{'variable'};
   
     if (defined $self->{ERROR_MSG}) {      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'}};      my $format = $helper->{VARS}->{$self->{'formatvar'}};
Line 2998  sub render { Line 2998  sub render {
     }      }
   
   
       my %size;
     my ($width_and_units,      ($size{'width_and_units'},
  $height_and_units,       $size{'height_and_units'},
  $margin_and_units)  =        $size{'margin_and_units'})=
     &Apache::lonprintout::page_format($papersize, $laystyle, $cols);   &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);  
           
     if ($wunits eq 'cm') {      foreach my $dimension ('width','height','margin') {
  $wuoptions = '<option>cm</option><option>in</option>';   ($size{$dimension},$size{$dimension.'_unit'}) =
     } else {      split(/ +/, $size{$dimension.'_and_units'},2);
  $wuoptions = '<option>in</option><option>cm</option>';         
     }   foreach my $unit ('cm','in') {
     if ($hunits eq 'cm') {      $size{$dimension.'_options'} .= '<option ';
  $huoptions =  '<option>cm</option><option>in</option>';      if ($size{$dimension.'_unit'} eq $unit) {
     } else {   $size{$dimension.'_options'} .= 'selected="selected" ';
  $huoptions = '<option>in</option><option>cm</option>';      }
     }      $size{$dimension.'_options'} .= '>'.$unit.'</option>';
     if ($munits eq 'cm') {   }
  $muoptions = '<option>cm</option><option>in</option>';  
     } else {  
  $muoptions = '<option>in</option><option>cm</option>';  
     }      }
   
     $result .= <<ELEMENTHTML;      $result .= <<ELEMENTHTML;
   
   
   
 <p>How should the column be formatted?</p>  <p>How should each column be formatted?</p>
   
 <table cellpadding='3'>  <table cellpadding='3'>
   <tr>    <tr>
     <td align='right'><b>Width</b>:</td>      <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'>      <td align='left'>
       <select name='$var.widthunit'>        <select name='$var.widthunit'>
       $wuoptions        $size{'width_options'}
       </select>        </select>
     </td>      </td>
   </tr>    </tr>
   <tr>    <tr>
     <td align='right'><b>Height</b>:</td>      <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'>      <td align='left'>
       <select name='$var.heightunit'>        <select name='$var.heightunit'>
       $huoptions        $size{'height_options'}
       </select>        </select>
     </td>      </td>
   </tr>    </tr>
   <tr>    <tr>
     <td align='right'><b>Left margin</b>:</td>      <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'>      <td align='left'>
       <select name='$var.lmarginunit'>        <select name='$var.lmarginunit'>
       $muoptions        $size{'margin_options'}
       </select>        </select>
     </td>      </td>
   </tr>    </tr>
 </table>  </table>
   
 <p>Hint: Some instructors like to leave scratch space for the student by  <!--<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>  making the width much smaller than the width of the page.</p>-->
   
 ELEMENTHTML  ELEMENTHTML
   
Line 3103  sub postprocess { Line 3088  sub postprocess {
     # /^-?[0-9]+(\.[0-9]*)?$/ -> optional minus, at least on digit, followed       # /^-?[0-9]+(\.[0-9]*)?$/ -> optional minus, at least on digit, followed 
     # by an optional period, followed by digits, ending the string      # 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";          $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";          $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";          $error .= "Invalid left margin; please type only a number.<br />\n";
     }      }
   

Removed from v.1.463  
changed lines
  Added in v.1.464


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>