Diff for /loncom/xml/lonxml.pm between versions 1.354 and 1.366

version 1.354, 2005/01/30 12:56:45 version 1.366, 2005/03/17 13:56:32
Line 149  $Apache::lonxml::post_evaluate=1; Line 149  $Apache::lonxml::post_evaluate=1;
 $Apache::lonxml::warnings_error_header='';  $Apache::lonxml::warnings_error_header='';
   
 sub xmlbegin {  sub xmlbegin {
   my $output='';      my ($style)=@_;
   @htmlareafields=();      my $output='';
   if ($ENV{'browser.mathml'}) {      @htmlareafields=();
       $output='<?xml version="1.0"?>'      if ($ENV{'browser.mathml'}) {
             .'<?xml-stylesheet type="text/css" href="/adm/MathML/mathml.css"?>'   $output='<?xml version="1.0"?>'
             .'<!DOCTYPE html SYSTEM "/adm/MathML/mathml.dtd" '              #.'<?xml-stylesheet type="text/css" href="/adm/MathML/mathml.css"?>'."\n"
             .'[<!ENTITY mathns "http://www.w3.org/1998/Math/MathML">]>'  #            .'<!DOCTYPE html SYSTEM "/adm/MathML/mathml.dtd" '
               
   #    .'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [<!ENTITY mathns "http://www.w3.org/1998/Math/MathML">] >'
       .'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">'
             .'<html xmlns:math="http://www.w3.org/1998/Math/MathML" '               .'<html xmlns:math="http://www.w3.org/1998/Math/MathML" ' 
  .'xmlns="http://www.w3.org/TR/REC-html40">';      .'xmlns="http://www.w3.org/1999/xhtml">';
   } else {      } else {
       $output='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   $output='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>';
 <html>';      }
   }      if ($style eq 'encode') {
   return $output;   $output=&HTML::Entities::encode($output,'<>&"');
       }
       return $output;
 }  }
   
 sub xmlend {  sub xmlend {
Line 173  sub xmlend { Line 178  sub xmlend {
  $mode='problem';   $mode='problem';
  $status=$Apache::inputtags::status[-1];    $status=$Apache::inputtags::status[-1]; 
     }      }
     my $discussion=&Apache::lonfeedback::list_discussion($mode,$status);          my $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);
       }
     if ($target eq 'tex') {      if ($target eq 'tex') {
  $discussion.='<tex>\keephidden{ENDOFPROBLEM}\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\end{document}</tex>';   $discussion.='<tex>\keephidden{ENDOFPROBLEM}\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\end{document}</tex>';
  &Apache::lonxml::newparser($parser,\$discussion,'');   &Apache::lonxml::newparser($parser,\$discussion,'');
  return '';   return '';
     } else {      } else {
  return $discussion.'</html>';   return $discussion.&Apache::loncommon::endbodytag();
     }      }
 }  }
   
Line 284  sub printtokenheader { Line 295  sub printtokenheader {
     }      }
 }  }
   
 sub fontsettings() {  sub fontsettings {
     my $headerstring='';      my $headerstring='';
     if (($ENV{'browser.os'} eq 'mac') && (!$ENV{'browser.mathml'})) {       if (($ENV{'browser.os'} eq 'mac') && (!$ENV{'browser.mathml'})) { 
  $headerstring.=   $headerstring.=
Line 353  sub xmlparse { Line 364  sub xmlparse {
   
  my @stack = ();   my @stack = ();
  my @parstack = ();   my @parstack = ();
  &initdepth;   &initdepth();
    &init_alarm();
  my $finaloutput = &inner_xmlparse($target,\@stack,\@parstack,\@pars,   my $finaloutput = &inner_xmlparse($target,\@stack,\@parstack,\@pars,
    $safeeval,\%style_for_target);     $safeeval,\%style_for_target);
   
Line 363  sub xmlparse { Line 374  sub xmlparse {
  }   }
  &do_registered_ssi();   &do_registered_ssi();
  if ($Apache::lonxml::counter_changed) { &store_counter() }   if ($Apache::lonxml::counter_changed) { &store_counter() }
    if ($ENV{'form.return_only_error_and_warning_counts'}) {
        return "$errorcount:$warningcount";
    }
  return $finaloutput;   return $finaloutput;
 }  }
   
Line 384  sub htmlclean { Line 398  sub htmlclean {
 # Make standard tags lowercase  # Make standard tags lowercase
     foreach ('html','body','head','meta','h1','h2','h3','h4','b','i','m',      foreach ('html','body','head','meta','h1','h2','h3','h4','b','i','m',
              'table','tr','td','th','p','br','hr','img','embed','font',               'table','tr','td','th','p','br','hr','img','embed','font',
              'a','strong','center','title','basefont') {               '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*\>/<\/$_\>/gis;          $raw=~s/\<\/$_\s*\>/<\/$_\>/gis;
         $raw=~s/\<$_\s([^\>]*)\>/<$_ $1\>/gis;          $raw=~s/\<$_\s([^\>]*)\>/<$_ $1\>/gis;
Line 786  sub default_homework_load { Line 801  sub default_homework_load {
     }      }
 }  }
   
   {
       my $alarm_depth;
       sub init_alarm {
    alarm(0);
    $alarm_depth=0;
       }
   
       sub start_alarm {
    if ($alarm_depth<1) {
       my $old=alarm($Apache::lonnet::perlvar{'lonScriptTimeout'});
       if ($old) {
    &Apache::lonxml::error("Cancelled an alarm of $old, this shouldn't occur.");
       }
    }
    $alarm_depth++;
       }
   
       sub end_alarm {
    $alarm_depth--;
    if ($alarm_depth<1) { alarm(0); }
       }
   }
 my $metamode_was;  my $metamode_was;
 sub startredirection {  sub startredirection {
     if (!$Apache::lonxml::redirection) {      if (!$Apache::lonxml::redirection) {
Line 1019  sub get_all_text { Line 1056  sub get_all_text {
 sub newparser {  sub newparser {
   my ($parser,$contentref,$dir) = @_;    my ($parser,$contentref,$dir) = @_;
   push (@$parser,HTML::LCParser->new($contentref));    push (@$parser,HTML::LCParser->new($contentref));
   $$parser['-1']->xml_mode('1');    $$parser[-1]->xml_mode(1);
     $$parser[-1]->marked_sections(1);
   if ( $dir eq '' ) {    if ( $dir eq '' ) {
     push (@Apache::lonxml::pwd, $Apache::lonxml::pwd[$#Apache::lonxml::pwd]);      push (@Apache::lonxml::pwd, $Apache::lonxml::pwd[$#Apache::lonxml::pwd]);
   } else {    } else {
Line 1214  $initialize Line 1252  $initialize
 $xml_help  $xml_help
 <input type="hidden" name="editmode" value="$lt{'ed'}" />  <input type="hidden" name="editmode" value="$lt{'ed'}" />
 $buttons<br />  $buttons<br />
 <textarea cols="80" rows="44" name="filecont" id="filecont">$filecontents</textarea>  <textarea style="width:100%" cols="80" rows="44" name="filecont" id="filecont">$filecontents</textarea>
 <br />$buttons  <br />$buttons
 <br />  <br />
 </form>  </form>
Line 1260  sub handler { Line 1298  sub handler {
           
     $Apache::lonxml::debug=$ENV{'user.debug'};      $Apache::lonxml::debug=$ENV{'user.debug'};
           
     if ($ENV{'browser.mathml'}) {      &Apache::loncommon::content_type($request,'text/html');
  &Apache::loncommon::content_type($request,'text/xml');  
     } else {  
  &Apache::loncommon::content_type($request,'text/html');  
     }  
     &Apache::loncommon::no_cache($request);      &Apache::loncommon::no_cache($request);
     $request->set_last_modified(&Apache::lonnet::metadata($request->uri,      if ($ENV{'request.state'} eq 'published') {
   'lastrevisiondate'));   $request->set_last_modified(&Apache::lonnet::metadata($request->uri,
         'lastrevisiondate'));
       }
     $request->send_http_header;      $request->send_http_header;
           
     return OK if $request->header_only;      return OK if $request->header_only;

Removed from v.1.354  
changed lines
  Added in v.1.366


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