--- loncom/xml/lonxml.pm 2006/02/04 22:11:42 1.396
+++ loncom/xml/lonxml.pm 2006/04/18 20:55:26 1.409
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.396 2006/02/04 22:11:42 foxr Exp $
+# $Id: lonxml.pm,v 1.409 2006/04/18 20:55:26 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -162,28 +162,6 @@ sub disable_LaTeX_substitutions {
$Apache::lonxml::substitute_LaTeX_symbols = 0;
}
-sub xmlbegin {
- my ($style)=@_;
- my $output='';
- @htmlareafields=();
- if ($env{'browser.mathml'}) {
- $output=''
- #.''."\n"
-# .'] >'
- .''
- .'';
- } else {
- $output='';
- }
- if ($style eq 'encode') {
- $output=&HTML::Entities::encode($output,'<>&"');
- }
- return $output;
-}
-
sub xmlend {
my ($target,$parser)=@_;
my $mode='xml';
@@ -204,9 +182,9 @@ sub xmlend {
$discussion.='\keephidden{ENDOFPROBLEM}\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\end{document}';
&Apache::lonxml::newparser($parser,\$discussion,'');
return '';
- } else {
- return $discussion.&Apache::loncommon::endbodytag();
}
+
+ return $discussion;
}
sub tokeninputfield {
@@ -304,18 +282,6 @@ sub printtokenheader {
}
}
-sub fontsettings {
- my $headerstring='';
- if (($env{'browser.os'} eq 'mac') && (!$env{'browser.mathml'})) {
- $headerstring.=
- '';
- } elsif (!$env{'browser.mathml'} && $env{'browser.unicode'}) {
- $headerstring.=
- '';
- }
- return $headerstring;
-}
-
sub printalltags {
my $temp;
foreach $temp (sort keys %Apache::lonxml::alltags) {
@@ -649,6 +615,7 @@ sub setup_globals {
@Apache::lonxml::ssi_info=();
$Apache::lonxml::post_evaluate=1;
$Apache::lonxml::warnings_error_header='';
+ $Apache::lonxml::substitute_LaTeX_symbols = 1;
if ($target eq 'meta') {
$Apache::lonxml::redirection = 0;
$Apache::lonxml::metamode = 1;
@@ -970,6 +937,16 @@ sub decreasedepth {
#print "
e $Apache::lonxml::depth : $Apache::lonxml::olddepth : $token->[1] : $curdepth\n";
}
+sub get_id {
+ my ($parstack,$safeeval)=@_;
+ my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
+ if ($env{'request.state'} eq 'construct' && $id =~ /(\.|_)/) {
+ &error(&mt("IDs are not allowed to contain "_" or ".""));
+ }
+ if ($id =~ /^\s*$/) { $id = $Apache::lonxml::curdepth; }
+ return $id;
+}
+
sub get_all_text_unbalanced {
#there is a copy of this in lonpublisher.pm
my($tag,$pars)= @_;
@@ -1027,9 +1004,36 @@ sub init_counter {
sub store_counter {
&Apache::lonnet::appenv(('form.counter' => $Apache::lonxml::counter));
+ $Apache::lonxml::counter_changed=0;
return '';
}
+{
+ my $state;
+ sub clear_problem_counter {
+ undef($state);
+ &Apache::lonnet::delenv('form.counter');
+ &Apache::lonxml::init_counter();
+ &Apache::lonxml::store_counter();
+ }
+
+ sub remember_problem_counter {
+ &Apache::lonnet::transfer_profile_to_env();
+ $state = $env{'form.counter'};
+ }
+
+ sub restore_problem_counter {
+ if (defined($state)) {
+ &Apache::lonnet::appenv(('form.counter' => $state));
+ }
+ }
+ sub get_problem_counter {
+ if ($Apache::lonxml::counter_changed) { &store_counter() }
+ &Apache::lonnet::transfer_profile_to_env();
+ return $env{'form.counter'};
+ }
+}
+
sub get_all_text {
my($tag,$pars,$style)= @_;
my $gotfullstack=1;
@@ -1420,17 +1424,13 @@ sub handler {
my $result = '';
my $filecontents=&Apache::lonnet::getfile($file);
if ($filecontents eq -1) {
- my $bodytag=&Apache::loncommon::bodytag('File Error');
+ my $start_page=&Apache::loncommon::start_page('File Error');
+ my $end_page=&Apache::loncommon::end_page('File Error');
my $fnf=&mt('File not found');
$result=(<
-
-$fnf
-
-$bodytag
+$start_page
$fnf: $file
-
-
+$end_page
ENDNOTFOUND
$filecontents='';
if ($env{'request.state'} ne 'published') {
@@ -1468,18 +1468,20 @@ ENDNOTFOUND
if ($env{'form.editmode'} && (!($env{'form.viewmode'}))) {
my $displayfile=$request->uri;
$displayfile=~s/^\/[^\/]*//;
- my $bodytag='';
- if ($env{'environment.remote'} eq 'off') {
- $bodytag=&Apache::loncommon::bodytag();
+ my %options = ();
+ if ($env{'environment.remote'} ne 'off') {
+ $options{'bgcolor'} = '#FFFFFF';
}
- $result=''.$bodytag.
+ my $start_page = &Apache::loncommon::start_page(undef,undef,
+ \%options);
+ $result=$start_page.
&Apache::lonxml::message_location().''.
$displayfile.
- '
';
+ ''.&Apache::loncommon::end_page();
$result=&inserteditinfo($result,$filecontents,$filetype);
}
}
- if ($filetype eq 'html') { writeallows($request->uri); }
+ if ($filetype eq 'html') { &writeallows($request->uri); }
&Apache::lonxml::add_messages(\$result);
@@ -1542,9 +1544,10 @@ sub error {
if ( !$symb ) {
#public or browsers
$errormsg=&mt("An error occured while processing this resource. The author has been notified.");
- }
+ }
+ my $msg = join('
',@_);
#notify author
- &Apache::lonmsg::author_res_msg($env{'request.filename'},join('
',@_));
+ &Apache::lonmsg::author_res_msg($env{'request.filename'},$msg);
#notify course
if ( $symb && $env{'request.course.id'} ) {
my $cnum=$env{'course.'.$env{'request.course.id'}.'.num'};
@@ -1562,7 +1565,7 @@ sub error {
my $now=time;
if ($now-$lastnotified{$key}>86400) {
&Apache::lonmsg::user_normal_msg($user,$domain,
- "Error [$declutter]",join('
',@_));
+ "Error [$declutter]",$msg);
&Apache::lonnet::put('nohist_xmlerrornotifications',
{$key => $now},
$cdom,$cnum);