Diff for /loncom/xml/lonxml.pm between versions 1.198 and 1.206

version 1.198, 2002/10/03 15:04:29 version 1.206, 2002/10/21 17:10:35
Line 60 Line 60
   
 package Apache::lonxml;   package Apache::lonxml; 
 use vars   use vars 
 qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace $prevent_entity_encode);  qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace $prevent_entity_encode $errorcount $warningcount);
 use strict;  use strict;
 use HTML::LCParser();  use HTML::LCParser();
 use HTML::TreeBuilder();  use HTML::TreeBuilder();
Line 100  use Apache::lonnet(); Line 100  use Apache::lonnet();
 use Apache::File();  use Apache::File();
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::lonfeedback();  use Apache::lonfeedback();
   use Apache::lonmsg();
   
 #==================================================   Main subroutine: xmlparse    #==================================================   Main subroutine: xmlparse  
 #debugging control, to turn on debugging modify the correct handler  #debugging control, to turn on debugging modify the correct handler
 $Apache::lonxml::debug=0;  $Apache::lonxml::debug=0;
   
   # keeps count of the number of warnings and errors generated in a parse
   $warningcount=0;
   $errorcount=0;
   
 #path to the directory containing the file currently being processed  #path to the directory containing the file currently being processed
 @pwd=();  @pwd=();
   
Line 139  $Apache::lonxml::registered=0; Line 144  $Apache::lonxml::registered=0;
 # a pointer the the Apache request object  # a pointer the the Apache request object
 $Apache::lonxml::request='';  $Apache::lonxml::request='';
   
   # a problem number counter, and check on hether it is used
   $Apache::lonxml::counter=0;
   $Apache::lonxml::counter_changed=0;
   
 sub xmlbegin {  sub xmlbegin {
   my $output='';    my $output='';
   if ($ENV{'browser.mathml'}) {    if ($ENV{'browser.mathml'}) {
Line 382  sub registerurl { Line 391  sub registerurl {
     $Apache::lonxml::registered=1;      $Apache::lonxml::registered=1;
     my $nothing='';      my $nothing='';
     if ($ENV{'browser.type'} eq 'explorer') { $nothing='javascript:void(0);'; }      if ($ENV{'browser.type'} eq 'explorer') { $nothing='javascript:void(0);'; }
       my $newmail='';
       if (&Apache::lonmsg::newmail()) { 
          $newmail='menu.setstatus("you have","messages");';
       }
     my $timesync='menu.syncclock(1000*'.time.');';      my $timesync='menu.syncclock(1000*'.time.');';
     if (($ENV{'REQUEST_URI'}!~/^\/(res\/)*adm\//) || ($forcereg)) {      if (($ENV{'REQUEST_URI'}!~/^\/(res\/)*adm\//) || ($forcereg)) {
         my $hwkadd='';          my $hwkadd='';
Line 411  ENDPARM Line 424  ENDPARM
   menu=window.open("$nothing","LONCAPAmenu","",false);    menu=window.open("$nothing","LONCAPAmenu","",false);
           menu.clearTimeout(menu.menucltim);            menu.clearTimeout(menu.menucltim);
           $timesync            $timesync
             $newmail
   menu.currentURL=window.location.pathname;    menu.currentURL=window.location.pathname;
           menu.reloadURL=window.location.pathname;            menu.reloadURL=window.location.pathname;
           menu.currentStale=0;            menu.currentStale=0;
Line 549  sub xmlparse { Line 563  sub xmlparse {
  if ($ENV{'request.uri'}) {   if ($ENV{'request.uri'}) {
     &writeallows($ENV{'request.uri'});      &writeallows($ENV{'request.uri'});
  }   }
    if ($Apache::lonxml::counter_changed) { &store_counter() }
  return $finaloutput;   return $finaloutput;
 }  }
   
Line 579  sub latex_special_symbols { Line 594  sub latex_special_symbols {
     $current_token=~s/\^/\\char94 /g;      $current_token=~s/\^/\\char94 /g;
     $current_token=~s/\~/\\char126 /g;      $current_token=~s/\~/\\char126 /g;
     $current_token=~s/(&[^a-z\#])/\\$1/g;      $current_token=~s/(&[^a-z\#])/\\$1/g;
     if ($current_token=~/ \#\w/) {      $current_token=~s/([^&])\#/$1\\#/g;
  $current_token=~s/ \#(\w)/ \\#$1/;  
     } else {  
  $current_token=~s/([^&]\#)/\\$1/g;  
     }  
     $current_token=~s/(\$|_|{|})/\\$1/g;      $current_token=~s/(\$|_|{|})/\\$1/g;
     $current_token=~s/\\char92 /\\texttt{\\char92}/g;      $current_token=~s/\\char92 /\\texttt{\\char92}/g;
     $current_token=~s/>/\$>\$/g; #more      $current_token=~s/>/\$>\$/g; #more
Line 845  sub setup_globals { Line 856  sub setup_globals {
   my ($request,$target)=@_;    my ($request,$target)=@_;
   $Apache::lonxml::request=$request;    $Apache::lonxml::request=$request;
   $Apache::lonxml::registered = 0;    $Apache::lonxml::registered = 0;
     $errorcount=0;
     $warningcount=0;
     &init_counter();
   @Apache::lonxml::pwd=();    @Apache::lonxml::pwd=();
   @Apache::lonxml::extlinks=();    @Apache::lonxml::extlinks=();
   if ($target eq 'meta') {    if ($target eq 'meta') {
Line 1028  sub get_all_text_unbalanced { Line 1042  sub get_all_text_unbalanced {
  return $result   return $result
 }  }
   
   sub increment_counter {
       $Apache::lonxml::counter++;
       $Apache::lonxml::counter_changed=1;
   }
   
   sub init_counter {
       if (defined($ENV{'form.counter'})) {
    $Apache::lonxml::counter=$ENV{'form.counter'};
       } elsif (not defined($Apache::lonxml::counter)) {
    $Apache::lonxml::counter=1;
    &store_counter();
       }
       $Apache::lonxml::counter_changed=0;
   }
   
   sub store_counter {
       &Apache::lonnet::appenv(('form.counter' => $Apache::lonxml::counter));
       return '';
   }
   
 sub get_all_text {  sub get_all_text {
  my($tag,$pars)= @_;   my($tag,$pars)= @_;
  my $depth=0;   my $depth=0;
Line 1319  ENDNOTFOUND Line 1353  ENDNOTFOUND
 sub debug {  sub debug {
   if ($Apache::lonxml::debug eq 1) {    if ($Apache::lonxml::debug eq 1) {
     $|=1;      $|=1;
     print("DEBUG:".&HTML::Entities::encode($_[0])."<br />\n");      print('<font size="-2"<pre>DEBUG:'.&HTML::Entities::encode($_[0])."</pre></font>\n");
   }    }
 }  }
   
 sub error {  sub error {
     $errorcount++;
   if (($Apache::lonxml::debug eq 1) || ($ENV{'request.state'} eq 'construct') ) {    if (($Apache::lonxml::debug eq 1) || ($ENV{'request.state'} eq 'construct') ) {
     # If printing in construction space, put the error inside <pre></pre>      # If printing in construction space, put the error inside <pre></pre>
     print "<b>ERROR:</b>".join("\n",@_)."\n";      print "<b>ERROR:</b>".join("\n",@_)."\n";
Line 1349  sub error { Line 1384  sub error {
 }  }
   
 sub warning {  sub warning {
     $warningcount++;
   if ($ENV{'request.state'} eq 'construct') {    if ($ENV{'request.state'} eq 'construct') {
     print "<b>W</b>ARNING<b>:</b>".join('<br />',@_)."<br />\n";      print "<b>W</b>ARNING<b>:</b>".join('<br />',@_)."<br />\n";
   }    }

Removed from v.1.198  
changed lines
  Added in v.1.206


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