Diff for /loncom/xml/lonxml.pm between versions 1.236 and 1.246

version 1.236, 2003/02/19 14:55:27 version 1.246, 2003/04/03 22:34:26
Line 145  $Apache::lonxml::registered=0; Line 145  $Apache::lonxml::registered=0;
 $Apache::lonxml::request='';  $Apache::lonxml::request='';
   
 # a problem number counter, and check on ether it is used  # a problem number counter, and check on ether it is used
 $Apache::lonxml::counter=4;  $Apache::lonxml::counter=1;
 $Apache::lonxml::counter_changed=0;  $Apache::lonxml::counter_changed=0;
   
 #internal check on whether to look at style defs  #internal check on whether to look at style defs
Line 196  sub xmlend { Line 196  sub xmlend {
                  my $message=$contrib{$idx.':message'};                   my $message=$contrib{$idx.':message'};
                  $message=~s/\n/\<br \/\>/g;                   $message=~s/\n/\<br \/\>/g;
  $message=&Apache::lontexconvert::msgtexconverted($message);   $message=&Apache::lontexconvert::msgtexconverted($message);
                    if ($contrib{$idx.':attachmenturl'}) {
                        my ($fname,$ft)
                           =($contrib{$idx.':attachmenturl'}=~/\/(\w+)\.(\w+)$/);
        $message.='<p>Attachment: <a href="'.
          &Apache::lonnet::tokenwrapper($contrib{$idx.':attachmenturl'}).
                        '"><tt>'.$fname.'.'.$ft.'</tt></a>';
                    }
                  if ($message) {                   if ($message) {
                   if ($hidden) {                    if ($hidden) {
       $message='<font color="#888888">'.$message.'</font>';        $message='<font color="#888888">'.$message.'</font>';
Line 248  sub xmlend { Line 255  sub xmlend {
           }            }
           if ($discussiononly) {            if ($discussiononly) {
       $discussion.=(<<ENDDISCUSS);        $discussion.=(<<ENDDISCUSS);
 <form action="/adm/feedback" method="post" name="mailform">  <form action="/adm/feedback" method="post" name="mailform" enctype="multipart/form-data">
 <input type="submit" name="discuss" value="Post Discussion" />  <input type="submit" name="discuss" value="Post Discussion" />
 <input type="submit" name="anondiscuss" value="Post Anonymous Discussion" />  <input type="submit" name="anondiscuss" value="Post Anonymous Discussion" />
 <input type="hidden" name="symb" value="$symb" />  <input type="hidden" name="symb" value="$symb" />
Line 257  sub xmlend { Line 264  sub xmlend {
 <font size="1">Note: in anonymous discussion, your name is visible only to  <font size="1">Note: in anonymous discussion, your name is visible only to
 course faculty</font><br />  course faculty</font><br />
 <textarea name=comment cols=60 rows=10 wrap=hard></textarea>  <textarea name=comment cols=60 rows=10 wrap=hard></textarea>
   <p>
   Attachment (128 KB max size): <input type="file" name="attachment" />
   </p>
 </form>  </form>
 ENDDISCUSS  ENDDISCUSS
              $discussion.=&Apache::lonfeedback::generate_preview_button();               $discussion.=&Apache::lonfeedback::generate_preview_button();
Line 391  sub xmlparse { Line 401  sub xmlparse {
  &Apache::inputtags::initialize_inputtags();   &Apache::inputtags::initialize_inputtags();
  &Apache::outputtags::initialize_outputtags();   &Apache::outputtags::initialize_outputtags();
  &Apache::edit::initialize_edit();   &Apache::edit::initialize_edit();
   
 #  #
 # do we have a course style file?  # do we have a course style file?
 #  #
Line 458  sub htmlclean { Line 469  sub htmlclean {
 sub latex_special_symbols {  sub latex_special_symbols {
     my ($current_token,$stack,$parstack,$where)=@_;      my ($current_token,$stack,$parstack,$where)=@_;
     if ($where eq 'header') {      if ($where eq 'header') {
       $current_token =~ s/\\/ /g;   $current_token =~ s/(\\|_|\^)/ /g;
       $current_token =~ s/\{/\\\{/g;   $current_token =~ s/(\$|%|\#|&|\{|\})/\\$1/g;
       $current_token =~ s/\}/\\\}/g;  
       $current_token =~ s/_/ /g;  
       $current_token =~ s/\^/ /g;  
       $current_token =~ s/&/\\&/g;  
       $current_token =~ s/\#/\\\#/g;  
       $current_token =~ s/%/\\%/g;  
       $current_token =~ s/\$/\\\$/g;  
     } else {      } else {
      $current_token=~s/\\ /\\char92 /g;   $current_token=~s/\\ /\\char92 /g;
      $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-Za-z\#])/\\$1/g;
      $current_token=~s/([^&])\#/$1\\#/g;   $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/(>|<)/\$$1\$/g; #more or less
      $current_token=~s/</\$<\$/g; #less   if ($current_token=~m/\d%/) {$current_token =~ s/(\d)%/$1\\%/g;} #percent after digit
      if ($current_token=~m/\d%/) {$current_token =~ s/(\d)%/$1\\%/g;} #percent after digit   if ($current_token=~m/\s%/) {$current_token =~ s/(\s)%/$1\\%/g;} #persent after space
      if ($current_token=~m/\s%/) {$current_token =~ s/(\s)%/$1\\%/g;} #persent after space  
     }      }
     return $current_token;      return $current_token;
 }  }
Line 494  sub inner_xmlparse { Line 497  sub inner_xmlparse {
  if ($metamode<1) {   if ($metamode<1) {
     my $text=$token->[1];      my $text=$token->[1];
     if ($token->[0] eq 'C' && $target eq 'tex') {      if ($token->[0] eq 'C' && $target eq 'tex') {
  $text = '%'.$text."\n";   $text = '';
   # $text = '%'.$text."\n";
     }      }
     $result.=$text;      $result.=$text;
  }   }
Line 523  sub inner_xmlparse { Line 527  sub inner_xmlparse {
  while ($token->[1] ne $$stack['-1'] && ($#$stack > -1)) {   while ($token->[1] ne $$stack['-1'] && ($#$stack > -1)) {
   my $lasttag=$$stack[-1];    my $lasttag=$$stack[-1];
   if ($token->[1] =~ /^$lasttag$/i) {    if ($token->[1] =~ /^$lasttag$/i) {
     &Apache::lonxml::warning('Using tag &lt;/'.$token->[1].'&gt; as end tag to &lt;'.$$stack[-1].'&gt;');      &Apache::lonxml::warning('Using tag &lt;/'.$token->[1].'&gt; on line '.$token->[3].' as end tag to &lt;'.$$stack[-1].'&gt;');
     last;      last;
   } else {    } else {
     &Apache::lonxml::warning('Found tag &lt;/'.$token->[1].'&gt; when looking for &lt;/'.$$stack[-1].'&gt; in file');      &Apache::lonxml::warning('Found tag &lt;/'.$token->[1].'&gt; on line '.$token->[3].' when looking for &lt;/'.$$stack[-1].'&gt; in file');
     &end_tag($stack,$parstack,$token);      &end_tag($stack,$parstack,$token);
   }    }
  }   }
Line 802  sub default_homework_load { Line 806  sub default_homework_load {
     my ($safeeval)=@_;      my ($safeeval)=@_;
     &Apache::lonxml::debug('Loading default_homework');      &Apache::lonxml::debug('Loading default_homework');
     my $default=&Apache::lonnet::getfile('/home/httpd/html/res/adm/includes/default_homework.lcpm');      my $default=&Apache::lonnet::getfile('/home/httpd/html/res/adm/includes/default_homework.lcpm');
     if ($default == -1) {      if ($default eq -1) {
  &Apache::lonxml::error("<b>Unable to find <i>default_homework.lcpm</i></b>");   &Apache::lonxml::error("<b>Unable to find <i>default_homework.lcpm</i></b>");
     } else {      } else {
  &Apache::run::run($default,$safeeval);   &Apache::run::run($default,$safeeval);
Line 901  sub increment_counter { Line 905  sub increment_counter {
 sub init_counter {  sub init_counter {
     if (defined($ENV{'form.counter'})) {      if (defined($ENV{'form.counter'})) {
  $Apache::lonxml::counter=$ENV{'form.counter'};   $Apache::lonxml::counter=$ENV{'form.counter'};
     } elsif (not defined($Apache::lonxml::counter)) {      } else {
  $Apache::lonxml::counter=1;   $Apache::lonxml::counter=1;
  &store_counter();   &store_counter();
     }      }
Line 1107  sub inserteditinfo { Line 1111  sub inserteditinfo {
       my ($result,$filecontents)=@_;        my ($result,$filecontents)=@_;
       $filecontents = &HTML::Entities::encode($filecontents);        $filecontents = &HTML::Entities::encode($filecontents);
 #      my $editheader='<a href="#editsection">Edit below</a><hr />';  #      my $editheader='<a href="#editsection">Edit below</a><hr />';
         my $xml_help = '<table><tr><td>'.
     &Apache::loncommon::help_open_topic("Greek_Symbols",'Greek Symbols',
         undef,undef,600)
         .'</td><td>'.
             &Apache::loncommon::help_open_topic("Other_Symbols",'Other Symbols',
         undef,undef,600)
         .'</td></tr></table>';
       my $buttons=(<<BUTTONS);        my $buttons=(<<BUTTONS);
 <input type="submit" name="attemptclean"   <input type="submit" name="attemptclean" 
        value="Save and then attempt to clean HTML" />         value="Save and then attempt to clean HTML" />
Line 1117  BUTTONS Line 1128  BUTTONS
 <hr />  <hr />
 <a name="editsection" />  <a name="editsection" />
 <form method="post">  <form method="post">
   $xml_help
 <input type="hidden" name="editmode" value="Edit" />  <input type="hidden" name="editmode" value="Edit" />
 $buttons<br />  $buttons<br />
 <textarea cols="80" rows="40" name="filecont">$filecontents</textarea>  <textarea cols="80" rows="40" name="filecont">$filecontents</textarea>
Line 1186  sub handler { Line 1198  sub handler {
   my %mystyle;    my %mystyle;
   my $result = '';    my $result = '';
   my $filecontents=&Apache::lonnet::getfile($file);    my $filecontents=&Apache::lonnet::getfile($file);
   if ($filecontents == -1) {    if ($filecontents eq -1) {
     $result=(<<ENDNOTFOUND);      $result=(<<ENDNOTFOUND);
 <html>  <html>
 <head>  <head>
Line 1379  sub description { Line 1391  sub description {
 # calls to lonnet functions for this setup.  # calls to lonnet functions for this setup.
 # - looks for form.grade_ parameters  # - looks for form.grade_ parameters
 sub whichuser {  sub whichuser {
   my ($symb,$courseid,$domain,$name);    my ($symb,$courseid,$domain,$name,$publicuser);
   if (defined($ENV{'form.grade_symb'})) {    if (defined($ENV{'form.grade_symb'})) {
     my $tmp_courseid=$ENV{'form.grade_courseid'};      my $tmp_courseid=$ENV{'form.grade_courseid'};
     my $allowed=&Apache::lonnet::allowed('mgr',$tmp_courseid);      my $allowed=&Apache::lonnet::allowed('mgr',$tmp_courseid);
Line 1390  sub whichuser { Line 1402  sub whichuser {
       $name=$ENV{'form.grade_username'};        $name=$ENV{'form.grade_username'};
     }      }
   } else {    } else {
     $symb=&Apache::lonnet::symbread();        $symb=&Apache::lonnet::symbread();
     $courseid=$ENV{'request.course.id'};        $courseid=$ENV{'request.course.id'};
     $domain=$ENV{'user.domain'};        $domain=$ENV{'user.domain'};
     $name=$ENV{'user.name'};        $name=$ENV{'user.name'};
         if ($name eq 'public' && $domain eq 'public') {
     if (!defined($ENV{'form.username'})) {
         $ENV{'form.username'}.=time.rand(10000000);
     }
     $name.=$ENV{'form.username'};
         }
   }    }
   return ($symb,$courseid,$domain,$name);    return ($symb,$courseid,$domain,$name,$publicuser);
 }  }
   
 1;  1;

Removed from v.1.236  
changed lines
  Added in v.1.246


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