--- loncom/xml/londefdef.pm 2006/04/11 18:42:43 1.326 +++ loncom/xml/londefdef.pm 2006/04/18 20:45:40 1.327 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.326 2006/04/11 18:42:43 albertel Exp $ +# $Id: londefdef.pm,v 1.327 2006/04/18 20:45:40 albertel Exp $ # # # Copyright Michigan State University Board of Trustees @@ -79,6 +79,8 @@ sub initialize_londefdef { @Apache::londefdef::DT=(0); @Apache::londefdef::seenDT=(0); $Apache::londefdef::list_index=0; + undef($Apache::londefdef::head); + undef($Apache::londefdef::title); } #======================= TAG SUBROUTINES ===================== @@ -178,10 +180,9 @@ sub end_tthoption { sub start_html { my ($target,$token) = @_; my $currentstring = ''; - my $options=$env{'course.'.$env{'request.course.id'}.'.tthoptions'}; &Apache::lontexconvert::init_tth(); if ($target eq 'web' || $target eq 'edit' || $target eq 'webgrade' ) { - $currentstring = &Apache::lonxml::xmlbegin(); + # start_body() takes care of emitting the } elsif ($target eq 'tex') { $currentstring .= '\documentclass[letterpaper,twoside]{article}'; if (($env{'form.latex_type'}=~'batchmode') || @@ -212,7 +213,7 @@ sub end_html { my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web' || $target eq 'webgrade') { - $currentstring = ''; + # end_body takes care of the } return $currentstring; } @@ -222,7 +223,7 @@ sub start_head { my ($target,$token) = @_; my $currentstring = ''; if ($target eq 'web' || $target eq 'webgrade') { - $currentstring = $token->[4].&Apache::lonxml::fontsettings(); + &Apache::lonxml::startredirection(); } return $currentstring; } @@ -232,8 +233,10 @@ sub end_head { my $currentstring = ''; if (($target eq 'web' && $env{'request.state'} eq 'published') || ($target eq 'webgrade' && $env{'request.state'} eq 'published')) { - $currentstring = &Apache::lonmenu::registerurl(undef,$target). - $token->[2]; + # in case there is a but no + if ($Apache::lonxml::redirection) { + $Apache::londefdef::head = &Apache::lonxml::endredirection(); + } } return $currentstring; } @@ -365,10 +368,11 @@ sub end_form { #-- tag (end tag required) sub start_title { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_; my $currentstring = ''; if ($target eq 'web' || $target eq 'webgrade') { - $currentstring = $token->[4]; + $Apache::londefdef::title = + &Apache::lonxml::get_all_text('/title',$parser,$style); } elsif ($target eq 'tex') { $currentstring .= '\keephidden{Title of the document: ' } @@ -383,7 +387,7 @@ sub end_title { my ($target,$token) = @_; my $currentstring = ''; if ($target eq 'web' || $target eq 'webgrade') { - $currentstring = $token->[2]; + # start_title takes care of swallowing the title } elsif ($target eq 'tex') { $currentstring .= '}'; } @@ -518,71 +522,24 @@ sub start_body { &Apache::lonxml::warning("<body> tag found inside of <problem> tag this can cause problems."); return ''; } - if (!$Apache::lonxml::registered && - $env{'request.state'} eq 'published') { - $currentstring.='<head>'. - &Apache::lonmenu::registerurl(undef,$target).'</head>'; - } -# Accessibility - if ($env{'browser.imagesuppress'} eq 'on') { - delete($token->[2]->{'background'}); - } - if ($env{'browser.fontenhance'} eq 'on') { - my $style=''; - foreach my $key (keys(%{$token->[2]})) { - if ($key =~ /^style$/i) { - $style.=$token->[2]->{$key}.';'; - delete($token->[2]->{$key}); - } - } - $token->[2]->{'style'}=$style.'; font-size: x-large;'; - } - if ($env{'browser.blackwhite'} eq 'on') { - delete($token->[2]->{'font'}); - delete($token->[2]->{'link'}); - delete($token->[2]->{'alink'}); - delete($token->[2]->{'vlink'}); - delete($token->[2]->{'bgcolor'}); - delete($token->[2]->{'background'}); - } -# Overload loads - 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]->{$_}.'"'; + if (&is_inside_of($tagstack, "head")) { + &end_head(@_); } - $currentstring.='>'; - $currentstring.=&Apache::lontexconvert::init_math_support(); + $currentstring = + &Apache::loncommon::start_page($Apache::londefdef::title, + $Apache::londefdef::head, + {'add_entries' => $token->[2], + 'no_title' => 1, + 'force_register' => 1}); + if ($env{'request.state'} ne 'published') { - if ($env{'environment.remote'} eq 'off') { - $currentstring.= - &Apache::lonmenu::constspaceform(). - &Apache::lonmenu::menubuttons(1,'web',1); - } $currentstring.=(<<EDITBUTTON); <form method="post"> <input type="submit" name="editmode" accesskey="e" value="Edit" /> </form> +<br /> EDITBUTTON - } else { - $currentstring.=&Apache::lonmenu::menubuttons(undef,$target,1); } $currentstring.=&Apache::lonxml::message_location(); } elsif ($target eq 'tex') { @@ -595,7 +552,7 @@ sub end_body { my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = &end_p(); # Close off unclosed <p> if ($target eq 'web' || $target eq 'webgrade') { - $currentstring .= &Apache::lonxml::xmlend($target,$parser); + $currentstring .= &Apache::loncommon::end_page({'discussion' => 1}); } elsif ($target eq 'tex') { $currentstring .= '\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent \end{document}'; }