--- loncom/xml/lonxml.pm 2006/01/13 10:33:25 1.395
+++ loncom/xml/lonxml.pm 2006/04/11 14:17:06 1.404
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.395 2006/01/13 10:33:25 albertel Exp $
+# $Id: lonxml.pm,v 1.404 2006/04/11 14:17:06 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -149,6 +149,19 @@ $Apache::lonxml::post_evaluate=1;
#a header message to emit in the case of any generated warning or errors
$Apache::lonxml::warnings_error_header='';
+# Control whether or not LaTeX symbols should be substituted for their
+# \ style equivalents...this may be turned off e.g. in an verbatim
+# environment.
+
+$Apache::lonxml::substitute_LaTeX_symbols = 1; # Starts out on.
+
+sub enable_LaTeX_substitutions {
+ $Apache::lonxml::substitute_LaTeX_symbols = 1;
+}
+sub disable_LaTeX_substitutions {
+ $Apache::lonxml::substitute_LaTeX_symbols = 0;
+}
+
sub xmlbegin {
my ($style)=@_;
my $output='';
@@ -382,6 +395,13 @@ sub xmlparse {
sub latex_special_symbols {
my ($string,$where)=@_;
+ #
+ # If e.g. in verbatim mode, then don't substitute.
+ # but return original string.
+ #
+ if (!($Apache::lonxml::substitute_LaTeX_symbols)) {
+ return $string;
+ }
if ($where eq 'header') {
$string =~ s/(\\|_|\^)/ /g;
$string =~ s/(\$|%|\{|\})/\\$1/g;
@@ -629,6 +649,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;
@@ -950,6 +971,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)= @_;
@@ -1007,9 +1038,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;
@@ -1400,17 +1458,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
-