--- loncom/xml/lonxml.pm 2007/08/22 19:02:06 1.453 +++ loncom/xml/lonxml.pm 2007/09/11 23:53:13 1.459 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.453 2007/08/22 19:02:06 albertel Exp $ +# $Id: lonxml.pm,v 1.459 2007/09/11 23:53:13 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -800,6 +800,7 @@ sub init_safespace { $safehole->wrap(\&Math::Random::random_set_seed_from_phrase,$safeeval,'&random_set_seed_from_phrase'); $safehole->wrap(\&Math::Random::random_get_seed,$safeeval,'&random_get_seed'); $safehole->wrap(\&Math::Random::random_set_seed,$safeeval,'&random_set_seed'); + $safehole->wrap(\&Apache::loncommon::languages,$safeeval,'&languages'); $safehole->wrap(\&Apache::lonxml::error,$safeeval,'&LONCAPA_INTERNAL_ERROR'); $safehole->wrap(\&Apache::lonxml::debug,$safeeval,'&LONCAPA_INTERNAL_DEBUG'); $safehole->wrap(\&Apache::lonnet::logthis,$safeeval,'&LONCAPA_INTERNAL_LOGTHIS'); @@ -908,6 +909,9 @@ sub endredirection { } pop @Apache::lonxml::outputstack; } +sub in_redirection { + return ($Apache::lonxml::redirection > 0) +} sub end_tag { my ($tagstack,$parstack,$token)=@_; @@ -1357,13 +1361,13 @@ sub inserteditinfo { my $initialize=''; my $textarea_id = 'filecont'; my ($add_to_onload, $add_to_onresize); - if ($filetype eq 'html') { - my $addbuttons=&Apache::lonhtmlcommon::htmlareaaddbuttons(); - $initialize=&Apache::lonhtmlcommon::spellheader(); - if (!&Apache::lonhtmlcommon::htmlareablocked() && - &Apache::lonhtmlcommon::htmlareabrowser()) { - $textarea_id .= '_htmlarea'; - $initialize.=(< $addbuttons @@ -1383,8 +1387,8 @@ $addbuttons } FULLPAGE - } else { - $initialize.=(< $addbuttons function initDocument() { @@ -1392,9 +1396,12 @@ $addbuttons } FULLPAGE - } - $add_to_onload = 'initDocument();'; - $add_to_onresize = "resize_textarea('$textarea_id','LC_aftertextarea');"; + } + + $add_to_onload = 'initDocument();'; + $add_to_onresize = "resize_textarea('$textarea_id','LC_aftertextarea');"; + + if ($filetype eq 'html') { $xml_help=&Apache::loncommon::helpLatexCheatsheet(); } @@ -1409,7 +1416,7 @@ FULLPAGE my $buttons=(< -
+
BUTTONS @@ -1529,15 +1536,30 @@ ENDNOTFOUND ['editmode']); } if (!$env{'form.editmode'} || $env{'form.viewmode'} || $env{'form.discardview'}) { + &Apache::structuretags::reset_problem_globals(); $result = &Apache::lonxml::xmlparse($request,$target,$filecontents, '',%mystyle); - undef($Apache::lonhomework::parsing_a_task); + # .html files may contain or need to clean + # up if it did + &Apache::structuretags::reset_problem_globals(); + &Apache::lonhomework::finished_parsing(); &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['rawmode']); if ($env{'form.rawmode'}) { $result = $filecontents; } + if ($filetype eq 'sty') { + my $controls = + ($env{'request.state'} eq 'construct') ? &Apache::londefdef::edit_controls() + : ''; + my %options = ('bgcolor' => '#FFFFFF'); + $result = + &Apache::loncommon::start_page(undef,undef,\%options). + $controls. + $result. + &Apache::loncommon::end_page(); + } } } - + # # Edit action? Insert editing commands # @@ -1620,12 +1642,28 @@ sub show_error_warn_msg { } sub error { + my @errors = @_; + $errorcount++; + + if (defined($Apache::inputtags::part)) { + if ( @Apache::inputtags::response ) { + push(@errors, + &mt("This error occurred while processing response [_1] in part [_2]", + $Apache::inputtags::response[-1], + $Apache::inputtags::part)); + } else { + push(@errors, + &mt("This error occurred while processing part [_1]", + $Apache::inputtags::part)); + } + } + if ( &show_error_warn_msg() ) { # If printing in construction space, put the error inside

 	push(@Apache::lonxml::error_messages,
 	     $Apache::lonxml::warnings_error_header.
-	     "ERROR:".join("
\n",@_)."
\n"); + "ERROR:".join("
\n",@errors)."
\n"); $Apache::lonxml::warnings_error_header=''; } else { my $errormsg; @@ -1635,7 +1673,10 @@ sub error { $errormsg=&mt("An error occured while processing this resource. The author has been notified."); } my $host=$Apache::lonnet::perlvar{'lonHostID'}; - my $msg = join('
',(@_,"The error occurred on host $host")); + push(@errors, "The error occurred on host $host"); + + my $msg = join('
', @errors); + #notify author &Apache::lonmsg::author_res_msg($env{'request.filename'},$msg); #notify course