--- loncom/xml/londefdef.pm 2010/11/18 18:07:02 1.403.4.4 +++ loncom/xml/londefdef.pm 2009/05/15 14:48:50 1.404 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.403.4.4 2010/11/18 18:07:02 raeburn Exp $ +# $Id: londefdef.pm,v 1.404 2009/05/15 14:48:50 bisitz Exp $ # # # Copyright Michigan State University Board of Trustees @@ -543,7 +543,7 @@ sub start_body { $Apache::londefdef::head .$extra_head, {'add_entries' => $token->[2], - 'no_title' => 1, +# 'no_title' => 1, 'force_register' => 1}); if ($env{'request.state'} ne 'published') { @@ -2018,39 +2018,29 @@ sub start_table { my $width = &Apache::lonxml::get_param('TeXwidth', $parstack, $safeeval, undef, 0); my $theme = &Apache::lonxml::get_param('TeXtheme', $parstack, $safeeval, undef, 0); my $align = &Apache::lonxml::get_param('align', $parstack, $safeeval, undef, 0); - my $cell_border = &Apache::lonxml::get_param('rules', $parstack, $safeeval, undef, 0); # The only thing that needs any figuring out is the width.. and then only if it is # a percent. If not it's assumed to be some valid TeX measurement unit e.g. 3.0cm # my $table = new Apache::lontable(); - if ((defined $border) && ($border > 0)) { - # &Apache::lonnet::logthis("Turning on table borders: $border"); - $table->table_border(1); - if ($cell_border ne 'none') { - $table->cell_border(1); # html specs that border turns on both...unless rules='none'. - } - } - # Only all or nothing for cell borders for now: - - if ((defined $cell_border) && ($cell_border ne 'none')) { - # &Apache::lonnet::logthis("Turning on cell borders: $cell_border"); - $table->cell_border(1); - } - if (defined $theme) { + if ($border ne '') { + $table->table_border(1); + $table->cell_border(1); + } + if ($theme ne '') { $table->theme($theme); } - if (defined $align) { + if ($align ne '') { $table->alignment($align); } # Missing width is most of page width - if (!(defined $width)) { + if ($width eq "") { $width = '70%'; } - + # If a percentage, need to calculate what this means in terms of # page width: @@ -2702,26 +2692,17 @@ sub tag_check { # sub cell_config_hash { - my ($align, $rowspan, $colspan, $width) = @_; - if ($rowspan ne '') { - $rowspan =~ s/^\s+|\s+$//g; - } - if ($colspan ne '') { - $colspan =~ s/^\s+|\s+$//g; - } + my ($align, $rowspan, $colspan) = @_; my %config; if ($align ne '') { $config{'halign'} = $align; } - if (($colspan =~ /^\d+$/) && ($colspan > 0)) { + if ($colspan ne "") { $config{'colspan'} = $colspan; } - if (($rowspan =~ /^\d+$/) && ($rowspan > 0)) { + if ($rowspan ne '') { $config{'rowspan'} = $rowspan; } - if ($width ne '') { - $config{'width'} = $width; - } return \%config; } @@ -2733,11 +2714,11 @@ sub start_td_tex { # attributes, but empty of text. end_td_tex will # fetch the contents from the recursive parse and # fill the cell with them: - my $align = &Apache::lonxml::get_param('align', $parstack, $safeeval); - my $rowspan = &Apache::lonxml::get_param('rowspan', $parstack, $safeeval); - my $colspan = &Apache::lonxml::get_param('colspan', $parstack, $safeeval); - my $width = &Apache::lonxml::get_param('TeXwidth', $parstack, $safeeval); - my $config = &cell_config_hash($align, $rowspan, $colspan, $width); + my $align = &Apache::lonxml::get_param('align', $parstack, $safeeval, undef, 1); + my $rowspan = &Apache::lonxml::get_param('rowspan', $parstack, $safeeval, undef, 1); + my $colspan = &Apache::lonxml::get_param('colspan', $parstack, $safeeval, undef, 1); + + my $config = &cell_config_hash($align, $rowspan, $colspan); my $table = $Apache::londefdef::table[-1]; $table->add_cell('', $config); @@ -3264,28 +3245,21 @@ sub start_img { ['','bottom','middle','top','left','right'],$token,5); $currentstring .=&Apache::edit::select_arg('TeXwrap:', 'TeXwrap', ['', 'none','parbox', 'parpic', 'wrapfigure'], $token, 2); - my $alt= &Apache::lonxml::get_param('alt',$parstack,$safeeval); - my $enc= &Apache::lonxml::get_param('encrypturl',$parstack,$safeeval); - $currentstring .=&Apache::edit::select_arg('Encrypt URL:','encrypturl', ['no','yes'], $token, 2); - if (($alt=~/\S/) && (lc($enc) eq 'yes')) { - $currentstring.='
'.&mt('Warning: the description "[_1]" will be available, even for encrypted URL',$alt).'
'; - } $currentstring .=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); my $src= &Apache::lonxml::get_param('src',$parstack,$safeeval); + my $alt= &Apache::lonxml::get_param('alt',$parstack,$safeeval); my $width= &Apache::lonxml::get_param('width',$parstack,$safeeval); my $height= &Apache::lonxml::get_param('height',$parstack,$safeeval); if ($token->[2]{'src'}=~/\$/) { - $currentstring.=&mt('Variable image source'); - } elsif ($token->[2]{'src'}=~/\S/) { + $currentstring.='Variable image source'; + } else { $currentstring .= ''.$alt.' $token->[2], - 'no_title' => 1, +# 'no_title' => 1, 'force_register' => 1, 'frameset' => 1,}); @@ -4747,7 +4721,7 @@ sub align_latex_image { # Even though we set a default alignment value, the user # could have given us an illegal value. In that case we # just use the default alignment of bottom.. - $currentstring = ''; + $currentstring = "\n% figurewrapping \n"; if ($align eq "top") { $currentstring .= '\raisebox{-'.$height.'mm}{'.$image; $closure = '}'; @@ -4790,6 +4764,8 @@ sub align_latex_image { $currentstring .= "{$image"; $closure = '}'; } + $currentstring .= "\n% end wrappage\n"; + $closure = "\n% Begin closure\n".$closure."\n% End closure\n"; return ($currentstring, $closure); } @@ -4809,7 +4785,8 @@ sub is_inside_of { # # This sub provides the typical LaTeX prefix matter for tex output: # -sub latex_header { +sub latex_header +{ my ($mode) = @_; my $currentstring = '';