Diff for /loncom/xml/lonxml.pm between versions 1.373 and 1.380

version 1.373, 2005/05/03 06:44:56 version 1.380, 2005/07/08 10:39:49
Line 180  sub xmlend { Line 180  sub xmlend {
  $status=$Apache::inputtags::status[-1];    $status=$Apache::inputtags::status[-1]; 
     }      }
     my $discussion;      my $discussion;
     &Apache::loncommon::get_unprocessed_cgi      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
         ($env{'query_string'},['LONCAPA_INTERNAL_no_discussion']);     ['LONCAPA_INTERNAL_no_discussion']);
     if (! exists($env{'form.LONCAPA_INTERNAL_no_discussion'}) ||      if (! exists($env{'form.LONCAPA_INTERNAL_no_discussion'}) ||
         $env{'form.LONCAPA_INTERNAL_no_discussion'} ne 'true') {          $env{'form.LONCAPA_INTERNAL_no_discussion'} ne 'true') {
         $discussion=&Apache::lonfeedback::list_discussion($mode,$status);          $discussion=&Apache::lonfeedback::list_discussion($mode,$status);
Line 382  sub xmlparse { Line 382  sub xmlparse {
  return $finaloutput;   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 {  sub latex_special_symbols {
     my ($string,$where)=@_;      my ($string,$where)=@_;
     if ($where eq 'header') {      if ($where eq 'header') {
Line 424  sub latex_special_symbols { Line 397  sub latex_special_symbols {
  $string=~s/\\\%|\%/\\\%/g;   $string=~s/\\\%|\%/\\\%/g;
  $string=~s/\\{|{/\\{/g;   $string=~s/\\{|{/\\{/g;
  $string=~s/\\}|}/\\}/g;   $string=~s/\\}|}/\\}/g;
    $string=~s/\\ensuremath\\{\\backslash\\}/\\ensuremath{\\backslash}/g;
  $string=~s/\\\$|\$/\\\$/g;   $string=~s/\\\$|\$/\\\$/g;
  $string=~s/\\\_|\_/\\\_/g;   $string=~s/\\\_|\_/\\\_/g;
         $string=~s/([^\\]|^)(\~|\^)/$1\\$2\\strut /g;          $string=~s/([^\\]|^)(\~|\^)/$1\\$2\\strut /g;
Line 844  sub startredirection { Line 818  sub startredirection {
   
 sub endredirection {  sub endredirection {
     if (!$Apache::lonxml::redirection) {      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 '';   return '';
     }      }
     $Apache::lonxml::redirection--;      $Apache::lonxml::redirection--;
Line 1092  sub parstring { Line 1066  sub parstring {
   
 sub writeallows {  sub writeallows {
     unless ($#extlinks>=0) { return; }      unless ($#extlinks>=0) { return; }
     my $thisurl='/res/'.&Apache::lonnet::declutter(shift);      my $thisurl = &Apache::lonnet::clutter(shift);
     if ($env{'httpref.'.$thisurl}) {      if ($env{'httpref.'.$thisurl}) {
  $thisurl=$env{'httpref.'.$thisurl};   $thisurl=$env{'httpref.'.$thisurl};
     }      }
Line 1238  FULLPAGE Line 1212  FULLPAGE
   $xml_help=&Apache::loncommon::helpLatexCheatsheet();    $xml_help=&Apache::loncommon::helpLatexCheatsheet();
       }        }
       my $cleanbut = '';        my $cleanbut = '';
       if ($filetype eq 'html') {  
   $cleanbut='<input type="submit" name="attemptclean" value="'.  
       &mt('Save and then attempt to clean HTML').'" />';  
       }  
       my $titledisplay=&display_title();        my $titledisplay=&display_title();
       my %lt=&Apache::lonlocal::texthash('st' => 'Save this',        my %lt=&Apache::lonlocal::texthash('st' => 'Save this',
  'vi' => 'View',   'vi' => 'View',
Line 1329  sub handler { Line 1300  sub handler {
 # Edit action? Save file.  # Edit action? Save file.
 #  #
     unless ($env{'request.state'} eq 'published') {      unless ($env{'request.state'} eq 'published') {
  if (($env{'form.savethisfile'}) || ($env{'form.attemptclean'})) {   if ($env{'form.savethisfile'}) {
     if (&storefile($file,$env{'form.filecont'})) {      if (&storefile($file,$env{'form.filecont'})) {
  &Apache::lonxml::info("<font COLOR=\"#0000FF\">".   &Apache::lonxml::info("<font COLOR=\"#0000FF\">".
       &mt('Updated').": ".        &mt('Updated').": ".
Line 1368  ENDNOTFOUND Line 1339  ENDNOTFOUND
     if ($filecontents=~/BEGIN LON-CAPA Internal/) {      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.'));   &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  # we are in construction space, see if edit mode forced
             &Apache::loncommon::get_unprocessed_cgi              &Apache::loncommon::get_unprocessed_cgi
Line 1465  sub error { Line 1432  sub error {
  &Apache::lonmsg::author_res_msg($env{'request.filename'},join('<br />',@_));   &Apache::lonmsg::author_res_msg($env{'request.filename'},join('<br />',@_));
  #notify course   #notify course
  if ( $symb && $env{'request.course.id'} ) {   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 (undef,%users)=&Apache::lonfeedback::decide_receiver(undef,0,1,1,1);
     my $declutter=&Apache::lonnet::declutter($env{'request.filename'});      my $declutter=&Apache::lonnet::declutter($env{'request.filename'});
     my @userlist;      my @userlist;
     foreach (keys %users) {      foreach (keys %users) {
  my ($user,$domain) = split(/:/, $_);   my ($user,$domain) = split(/:/, $_);
  push(@userlist,"$user\@$domain");   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('<br />',@_));   "Error [$declutter]",join('<br />',@_));
       &Apache::lonnet::put('nohist_xmlerrornotifications',
    {$key => $now},
    $cdom,$cnum);
    }
     }      }
     if ($env{'request.role.adv'}) {      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));   $errormsg=&mt("An error occured while processing this resource. The course personnel ([_1]) and the author have been notified.",join(', ',@userlist));
Line 1489  sub warning { Line 1468  sub warning {
       
     if ($env{'form.grade_target'} ne 'tex') {      if ($env{'form.grade_target'} ne 'tex') {
  if ( &show_error_warn_msg() ) {   if ( &show_error_warn_msg() ) {
     my $request=$Apache::lonxml::request;  
     if (!$request) { $request=Apache->request; }  
     push(@Apache::lonxml::warning_messages,      push(@Apache::lonxml::warning_messages,
  $Apache::lonxml::warnings_error_header.   $Apache::lonxml::warnings_error_header.
  "<b>W</b>ARNING<b>:</b>".join('<br />',@_)."<br />\n");   "<b>W</b>ARNING<b>:</b>".join('<br />',@_)."<br />\n");

Removed from v.1.373  
changed lines
  Added in v.1.380


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>