--- loncom/xml/londefdef.pm 2003/04/16 19:20:51 1.127 +++ loncom/xml/londefdef.pm 2003/05/21 14:57:31 1.134 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.127 2003/04/16 19:20:51 sakharuk Exp $ +# $Id: londefdef.pm,v 1.134 2003/05/21 14:57:31 sakharuk Exp $ # # # Copyright Michigan State University Board of Trustees @@ -1697,7 +1697,7 @@ sub end_dd { sub start_table { my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $textwidth; - if ($#Apache::londefdef::table==0) { + if (not defined @Apache::londefdef::table) { $textwidth=&recalc($ENV{'form.textwidth'}); $textwidth=~/(\d+)/; $textwidth=$1; @@ -1742,6 +1742,7 @@ sub start_table { $Apache::londefdef::table[-1]{'vvinc'} = ''; } $Apache::londefdef::table[-1]{'output'} = ' \noindent \begin{tabular} '; + $currentstring = '\keephidden{NEW TABLE ENTRY '.$textwidth.'}'; } return $currentstring; } @@ -1760,8 +1761,6 @@ sub end_table { $header_of_table .= $Apache::londefdef::table[-1]{'columns'}[$in].$Apache::londefdef::table[-1]{'vvinc'}; } $header_of_table .= '}'; - - #define the length of the table cells #always starts with TeXwidth (if defined everything else is ignored) my @length_row_final = split(/,/,$Apache::londefdef::table[-1]{'TeXlengthrow'}[0]); @@ -1817,8 +1816,7 @@ sub end_table { if ($#Apache::londefdef::table > 0) { my $inmemory = $Apache::londefdef::table[-1]{'output'}; pop @Apache::londefdef::table; - $Apache::londefdef::table[-1]{'rowdata'}[$Apache::londefdef::table[-1]{'row_number'}] .= $inmemory; ###Need to work with (wrong place to add) - + push @{$Apache::londefdef::table[-1]{'include'}}, $inmemory; } else { $currentstring .= $Apache::londefdef::table[-1]{'output'}; pop @Apache::londefdef::table; @@ -1896,7 +1894,7 @@ sub end_td { } else { if ($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) { my $current_length=&recalc($1); - $current_length=~/(\d+)/; + $current_length=~/(\d+\.?\d*)/; $Apache::londefdef::table[-1]{'TeXlength'} .= $1.','; $Apache::londefdef::table[-1]{'length'} .= '0,'; } else { @@ -1908,9 +1906,11 @@ sub end_td { $Apache::londefdef::table[-1]{'length'} .= $current_length.','; $Apache::londefdef::table[-1]{'TeXlength'} .= '0,'; } - } - $data='\parbox{TOBECHANGEDONNUMBER}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'}; - @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= $data; + } + for (my $in=0; $in<=$#{$Apache::londefdef::table[-1]{'include'}};$in++) { + $data=~s/\\keephidden\{NEW TABLE ENTRY\}/$Apache::londefdef::table[-1]{'include'}[$in]/; + } + @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{TOBECHANGEDONNUMBER}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'}; } return $currentstring; } @@ -1929,29 +1929,48 @@ sub start_th { push @{ $Apache::londefdef::table[-1]{'columns'} }, $what_to_push; $Apache::londefdef::table[-1]{'counter_columns'}++; &Apache::lonxml::startredirection(); - ; } return $currentstring; -} - +} + sub end_th { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring = $token->[2]; } elsif ($target eq 'tex') { my $current_row = $Apache::londefdef::table[-1]{'row_number'}; my $data=&Apache::lonxml::endredirection(); - if ($data=~m/width\s*=\s*(\d+\.*\d*\s*(mm|cm))/) { - $Apache::londefdef::table[-1]{'length'} .= $1.','; + my $TeXwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0); + if (defined $TeXwidth) { + my $current_length=&recalc($TeXwidth); + $current_length=~/(\d+)/; + $Apache::londefdef::table[-1]{'TeXlength'} .= $1.','; + $Apache::londefdef::table[-1]{'length'} .= '0,'; } else { - $Apache::londefdef::table[-1]{'length'} .= '0 mm,'; - } - @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{'.$1.'}{\textbf{'.$data.'}} '.$Apache::londefdef::table[-1]{'vinc'}; + if ($data=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/) { + my $current_length=&recalc($1); + $current_length=~/(\d+)/; + $Apache::londefdef::table[-1]{'TeXlength'} .= $1.','; + $Apache::londefdef::table[-1]{'length'} .= '0,'; + } else { + $data=~/^\s*(\S.*)/; + $data=$1; + $data=~/(.*\S)\s*$/; + $data=$1; + my $current_length=2*length($data); + $Apache::londefdef::table[-1]{'length'} .= $current_length.','; + $Apache::londefdef::table[-1]{'TeXlength'} .= '0,'; + } + } + for (my $in=0; $in<=$#{$Apache::londefdef::table[-1]{'include'}};$in++) { + $data=~s/\\keephidden\{NEW TABLE ENTRY\}/$Apache::londefdef::table[-1]{'include'}[$in]/; + } + $data='\textbf{'.$data.'}'; + @{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{TOBECHANGEDONNUMBER}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'}; } return $currentstring; } - #-- tag sub start_img { my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; @@ -2205,7 +2224,29 @@ sub start_frameset { $currentstring.='
'. &Apache::lonmenu::registerurl(undef,$target).''; } - $currentstring .= $token->[4]; + my $onLoad=''; + foreach my $key (keys(%{$token->[2]})) { + if ($key =~ /^onload$/i) { + $onLoad.=$token->[2]->{$key}.';'; + delete($token->[2]->{$key}); + } + } + $token->[2]->{'onload'}=&Apache::lonmenu::loadevents().';'.$onLoad; + my $onUnload=''; + foreach my $key (keys(%{$token->[2]})) { + if ($key =~ /^onunload$/i) { + $onUnload.=$token->[2]->{$key}.';'; + delete($token->[2]->{$key}); + } + } + $token->[2]->{'onunload'}=&Apache::lonmenu::unloadevents(). + ';'.$onUnload; + + $currentstring .= '<'.$token->[1]; + foreach (keys %{$token->[2]}) { + $currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"'; + } + $currentstring.='>'; } return $currentstring; } @@ -3083,6 +3124,26 @@ sub end_wbr { return $currentstring; } + +#--