--- loncom/xml/lonxml.pm 2005/05/03 06:44:56 1.373
+++ loncom/xml/lonxml.pm 2005/07/08 10:39:49 1.380
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.373 2005/05/03 06:44:56 albertel Exp $
+# $Id: lonxml.pm,v 1.380 2005/07/08 10:39:49 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -180,8 +180,8 @@ sub xmlend {
$status=$Apache::inputtags::status[-1];
}
my $discussion;
- &Apache::loncommon::get_unprocessed_cgi
- ($env{'query_string'},['LONCAPA_INTERNAL_no_discussion']);
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['LONCAPA_INTERNAL_no_discussion']);
if (! exists($env{'form.LONCAPA_INTERNAL_no_discussion'}) ||
$env{'form.LONCAPA_INTERNAL_no_discussion'} ne 'true') {
$discussion=&Apache::lonfeedback::list_discussion($mode,$status);
@@ -382,33 +382,6 @@ sub xmlparse {
return $finaloutput;
}
-sub htmlclean {
- my ($raw,$full)=@_;
-# Take care of CRLF etc
-
- $raw=~s/\r\f/\n/gs; $raw=~s/\f\r/\n/gs;
- $raw=~s/\r\n/\n/gs; $raw=~s/\n\r/\n/gs;
- $raw=~s/\f/\n/gs; $raw=~s/\r/\n/gs;
- $raw=~s/\&\#10\;/\n/gs; $raw=~s/\&\#13\;/\n/gs;
-
-# Generate empty tags, remove wrong end tags
- $raw=~s/\<(br|hr|img|meta|allow|basefont)([^\>\/]*?)\>/\<$1$2 \/\>/gis;
- $raw=~s/\<\/(br|hr|img|meta|allow|basefont)\>//gis;
- unless ($full) {
- $raw=~s/\<[\/]*(body|head|html)\>//gis;
- }
-# Make standard tags lowercase
- foreach ('html','body','head','meta','h1','h2','h3','h4','b','i','m',
- 'table','tr','td','th','p','br','hr','img','embed','font',
- 'a','strong','center','title','basefont','li','ol','ul',
- 'input','select','form','option','script','pre') {
- $raw=~s/\<$_\s*\>/\<$_\>/gis;
- $raw=~s/\<\/$_\s*\>/<\/$_\>/gis;
- $raw=~s/\<$_\s([^\>]*)\>/<$_ $1\>/gis;
- }
- return $raw;
-}
-
sub latex_special_symbols {
my ($string,$where)=@_;
if ($where eq 'header') {
@@ -424,6 +397,7 @@ sub latex_special_symbols {
$string=~s/\\\%|\%/\\\%/g;
$string=~s/\\{|{/\\{/g;
$string=~s/\\}|}/\\}/g;
+ $string=~s/\\ensuremath\\{\\backslash\\}/\\ensuremath{\\backslash}/g;
$string=~s/\\\$|\$/\\\$/g;
$string=~s/\\\_|\_/\\\_/g;
$string=~s/([^\\]|^)(\~|\^)/$1\\$2\\strut /g;
@@ -844,7 +818,7 @@ sub startredirection {
sub endredirection {
if (!$Apache::lonxml::redirection) {
- &Apache::lonxml::error("Endredirection was called, before a startredirection, perhaps you have unbalanced tags. Some debuging information:".join ":",caller);
+ &Apache::lonxml::error("Endredirection was called before a startredirection, perhaps you have unbalanced tags. Some debugging information:".join ":",caller);
return '';
}
$Apache::lonxml::redirection--;
@@ -1092,7 +1066,7 @@ sub parstring {
sub writeallows {
unless ($#extlinks>=0) { return; }
- my $thisurl='/res/'.&Apache::lonnet::declutter(shift);
+ my $thisurl = &Apache::lonnet::clutter(shift);
if ($env{'httpref.'.$thisurl}) {
$thisurl=$env{'httpref.'.$thisurl};
}
@@ -1238,10 +1212,7 @@ FULLPAGE
$xml_help=&Apache::loncommon::helpLatexCheatsheet();
}
my $cleanbut = '';
- if ($filetype eq 'html') {
- $cleanbut='';
- }
+
my $titledisplay=&display_title();
my %lt=&Apache::lonlocal::texthash('st' => 'Save this',
'vi' => 'View',
@@ -1329,7 +1300,7 @@ sub handler {
# Edit action? Save file.
#
unless ($env{'request.state'} eq 'published') {
- if (($env{'form.savethisfile'}) || ($env{'form.attemptclean'})) {
+ if ($env{'form.savethisfile'}) {
if (&storefile($file,$env{'form.filecont'})) {
&Apache::lonxml::info("".
&mt('Updated').": ".
@@ -1368,10 +1339,6 @@ ENDNOTFOUND
if ($filecontents=~/BEGIN LON-CAPA Internal/) {
&Apache::lonxml::error(&mt('This file appears to be a rendering of a Lon-CAPA resource. If this is correct, this resource will act very oddly and incorrectly.'));
}
-
- if ($env{'form.attemptclean'}) {
- $filecontents=&htmlclean($filecontents,1);
- }
#
# we are in construction space, see if edit mode forced
&Apache::loncommon::get_unprocessed_cgi
@@ -1465,14 +1432,26 @@ sub error {
&Apache::lonmsg::author_res_msg($env{'request.filename'},join('
',@_));
#notify course
if ( $symb && $env{'request.course.id'} ) {
+ my $cnum=$env{'course.'.$env{'request.course.id'}.'.num'};
+ my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
my (undef,%users)=&Apache::lonfeedback::decide_receiver(undef,0,1,1,1);
my $declutter=&Apache::lonnet::declutter($env{'request.filename'});
my @userlist;
foreach (keys %users) {
my ($user,$domain) = split(/:/, $_);
push(@userlist,"$user\@$domain");
- &Apache::lonmsg::user_normal_msg($user,$domain,
+ my $key=$declutter.'_'.$user.'_'.$domain;
+ my %lastnotified=&Apache::lonnet::get('nohist_xmlerrornotifications',
+ [$key],
+ $cdom,$cnum);
+ my $now=time;
+ if ($now-$lastnotified{$key}>86400) {
+ &Apache::lonmsg::user_normal_msg($user,$domain,
"Error [$declutter]",join('
',@_));
+ &Apache::lonnet::put('nohist_xmlerrornotifications',
+ {$key => $now},
+ $cdom,$cnum);
+ }
}
if ($env{'request.role.adv'}) {
$errormsg=&mt("An error occured while processing this resource. The course personnel ([_1]) and the author have been notified.",join(', ',@userlist));
@@ -1489,8 +1468,6 @@ sub warning {
if ($env{'form.grade_target'} ne 'tex') {
if ( &show_error_warn_msg() ) {
- my $request=$Apache::lonxml::request;
- if (!$request) { $request=Apache->request; }
push(@Apache::lonxml::warning_messages,
$Apache::lonxml::warnings_error_header.
"WARNING:".join('
',@_)."
\n");