--- loncom/xml/londefdef.pm 2003/03/18 15:32:15 1.122 +++ loncom/xml/londefdef.pm 2003/05/07 16:59:01 1.131 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.122 2003/03/18 15:32:15 albertel Exp $ +# $Id: londefdef.pm,v 1.131 2003/05/07 16:59:01 sakharuk Exp $ # # # Copyright Michigan State University Board of Trustees @@ -46,7 +46,7 @@ package Apache::londefdef; use Apache::lonnet(); use strict; -use Apache::lonxml(); +use Apache::lonxml; use Apache::File(); use Image::Magick; use Apache::lonmenu(); @@ -394,10 +394,15 @@ sub start_accessrule { ('effect',$parstack,$safeeval,undef,1); my $realm=&Apache::lonxml::get_param ('realm',$parstack,$safeeval,undef,1); - my $cont=&Apache::lonxml::get_param - ('content',$parstack,$safeeval,undef,1); - $cont=~s/\s+//g; - $cont=~s/\W/\;/g; + my $role=&Apache::lonxml::get_param + ('role',$parstack,$safeeval,undef,1); + $realm=~s/\s+//g; + $realm=~s/\//\_/g; + $realm=~s/^\_//; + $realm=~s/\W/\;/g; + $role=~s/\s+//g; + $role=~s/\//\_/g; + $role=~s/\W/\;/g; if ($target eq 'web') { my $args=''; if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; } @@ -408,7 +413,7 @@ sub start_accessrule { } } if ($target eq 'meta') { - $currentstring=''.$eff.':'.$realm.':'.$cont.''; + $currentstring=''.$eff.':'.$realm.':'.$role.''; } return $currentstring; } @@ -568,12 +573,23 @@ sub end_strong { #--

tag sub start_h1 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '{\large \textbf{'; + my $pre; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $pre='\begin{center}'; + } elsif ($align eq 'left') { + $pre='\rlap{'; + } elsif ($align eq 'right') { + $pre=' \hfill \llap{'; + } + my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0); + if (not defined $TeXsize) {$TeXsize="large";} + $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; } elsif ($target eq 'meta') { $currentstring=''; &start_output(); @@ -582,12 +598,21 @@ sub start_h1 { } sub end_h1 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { - $currentstring .= '}}'; + my $post; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $post='\end{center}'; + } elsif ($align eq 'left') { + $post='} \hfill'.'\vskip 0 mm '; + } elsif ($align eq 'right') { + $post='}'.'\vskip 0 mm '; + } + $currentstring .= '}}'.$post; } elsif ($target eq 'meta') { &end_output(); $currentstring=''; @@ -597,115 +622,215 @@ sub end_h1 { #--

tag sub start_h2 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '{\large \textbf{'; + my $pre; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $pre='\begin{center}'; + } elsif ($align eq 'left') { + $pre='\rlap{'; + } elsif ($align eq 'right') { + $pre=' \hfill \llap{'; + } + my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0); + if (not defined $TeXsize) {$TeXsize="large";} + $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; } return $currentstring; } sub end_h2 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { - $currentstring .= '}}'; + my $post; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $post='\end{center}'; + } elsif ($align eq 'left') { + $post='} \hfill'.'\vskip 0 mm '; + } elsif ($align eq 'right') { + $post='}'.'\vskip 0 mm '; + } + $currentstring .= '}}'.$post; } return $currentstring; } #--

tag sub start_h3 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '{\large \textbf{'; + my $pre; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $pre='\begin{center}'; + } elsif ($align eq 'left') { + $pre='\rlap{'; + } elsif ($align eq 'right') { + $pre=' \hfill \llap{'; + } + my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0); + if (not defined $TeXsize) {$TeXsize="large";} + $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; } return $currentstring; } sub end_h3 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { - $currentstring .= '}}'; + my $post; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $post='\end{center}'; + } elsif ($align eq 'left') { + $post='} \hfill'.'\vskip 0 mm '; + } elsif ($align eq 'right') { + $post='}'.'\vskip 0 mm '; + } + $currentstring .= '}}'.$post; } return $currentstring; } #--

tag sub start_h4 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '{\large \textbf{'; + my $pre; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $pre='\begin{center}'; + } elsif ($align eq 'left') { + $pre='\rlap{'; + } elsif ($align eq 'right') { + $pre=' \hfill \llap{'; + } + my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0); + if (not defined $TeXsize) {$TeXsize="large";} + $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; } return $currentstring; } sub end_h4 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { - $currentstring .= '}}'; + my $post; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $post='\end{center}'; + } elsif ($align eq 'left') { + $post='} \hfill'.'\vskip 0 mm '; + } elsif ($align eq 'right') { + $post='}'.'\vskip 0 mm '; + } + $currentstring .= '}}'.$post; } return $currentstring; } #--

tag sub start_h5 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '{\large \textbf{'; + my $pre; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $pre='\begin{center}'; + } elsif ($align eq 'left') { + $pre='\rlap{'; + } elsif ($align eq 'right') { + $pre=' \hfill \llap{'; + } + my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0); + if (not defined $TeXsize) {$TeXsize="large";} + $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; } return $currentstring; } sub end_h5 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { - $currentstring .= '}}'; + my $post; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $post='\end{center}'; + } elsif ($align eq 'left') { + $post='} \hfill'.'\vskip 0 mm '; + } elsif ($align eq 'right') { + $post='}'.'\vskip 0 mm '; + } + $currentstring .= '}}'.$post; } return $currentstring; } #--
tag sub start_h6 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '{\large \textbf{'; + my $pre; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $pre='\begin{center}'; + } elsif ($align eq 'left') { + $pre='\rlap{'; + } elsif ($align eq 'right') { + $pre=' \hfill \llap{'; + } + my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0); + if (not defined $TeXsize) {$TeXsize="large";} + $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; } return $currentstring; } sub end_h6 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { - $currentstring .= '}}'; + my $post; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $post='\end{center}'; + } elsif ($align eq 'left') { + $post='} \hfill'.'\vskip 0 mm '; + } elsif ($align eq 'right') { + $post='}'.'\vskip 0 mm '; + } + $currentstring .= '}}'.$post; } return $currentstring; } @@ -1057,20 +1182,30 @@ sub end_small { #-- tag sub start_basefont { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; my $currentstring = ''; if ($target eq 'web') { $currentstring = $token->[4]; - } + } elsif ($target eq 'tex') { + my $basesize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval); + if (defined $basesize) { + $currentstring = '{\\'.$basesize.' '; + } + } return $currentstring; } sub end_basefont { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring = $token->[4]; - } + } elsif ($target eq 'tex') { + my $basesize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval); + if (defined $basesize) { + $currentstring = '}'; + } + } return $currentstring; } @@ -1082,7 +1217,12 @@ sub start_font { my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval); if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode++;} $currentstring = $token->[4]; - } + } elsif ($target eq 'tex') { + my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval); + if (defined $fontsize) { + $currentstring = '{\\'.$fontsize.' '; + } + } return $currentstring; } @@ -1093,7 +1233,12 @@ sub end_font { my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval); if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode--;} $currentstring = $token->[2]; - } + } elsif ($target eq 'tex') { + my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval); + if (defined $fontsize) { + $currentstring = '}'; + } + } return $currentstring; } @@ -1197,12 +1342,31 @@ sub end_sup { #--
tag sub start_hr { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '\vskip 0 mm \noindent\makebox[\textwidth/2 ][b]{\hrulefill}\vskip 0 mm '; + my $LaTeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,0); + if (defined $LaTeXwidth) { + if ($LaTeXwidth=~/^%/) { + substr($LaTeXwidth,0,1)=''; + $LaTeXwidth=($LaTeXwidth/100).'\textwidth'; + } + } else { + $LaTeXwidth ='0.95\textwidth'; + } + my ($pre,$post); + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $pre=''; $post=''; + } elsif ($align eq 'left') { + $pre='\rlap{'; $post='} \hfill'; + } elsif ($align eq 'right') { + $pre=' \hfill \llap{'; $post='}'; + } + $currentstring .= ' \vskip 0 mm \noindent\makebox[\textwidth]{'.$pre.'\makebox['. + $LaTeXwidth.'][b]{\hrulefill}'.$post.'}\vskip 0 mm '; } return $currentstring; } @@ -1324,12 +1488,29 @@ sub end_u { #--