Diff for /loncom/xml/lonxml.pm between versions 1.294 and 1.301

version 1.294, 2003/11/21 18:54:10 version 1.301, 2004/02/06 20:59:50
Line 167  $Apache::lonxml::style_end_values=''; Line 167  $Apache::lonxml::style_end_values='';
 #should we do the postag variable interpolation  #should we do the postag variable interpolation
 $Apache::lonxml::post_evaluate=1;  $Apache::lonxml::post_evaluate=1;
   
   #a header message to emit in the case of any generated warning or errors
   $Apache::lonxml::warnings_error_header='';
   
 sub xmlbegin {  sub xmlbegin {
   my $output='';    my $output='';
   if ($ENV{'browser.mathml'}) {    if ($ENV{'browser.mathml'}) {
Line 189  sub xmlend { Line 192  sub xmlend {
  $mode='problem';   $mode='problem';
  $status=$Apache::inputtags::status[-1];    $status=$Apache::inputtags::status[-1]; 
     }      }
     return &Apache::lonfeedback::list_discussion().'</html>';      return &Apache::lonfeedback::list_discussion($mode,$status).'</html>';
 }  }
   
 sub tokeninputfield {  sub tokeninputfield {
Line 402  sub latex_special_symbols { Line 405  sub latex_special_symbols {
  $string =~ s/_/ /g;   $string =~ s/_/ /g;
     } else {      } else {
  $string=~s/\\ /\\char92 /g;   $string=~s/\\ /\\char92 /g;
  $string=~s/\^/\\\^ /g;   $string=~s/\^/\\\^\\strut /g;
  $string=~s/\~/\\char126 /g;   $string=~s/\~/\\char126 /g;
  #fixup & if it doesn't look like   #fixup & if it doesn't look like
         # &#123; or &alpha;          # &#123; or &alpha;
  $string=~s/(&(?!((\#[0-9]+)|([a-z]+));))/\\$1/gi;   $string=~s/(&(?!((\#[0-9]+)|([a-z]+));))/\\$1/gi;
  $string=~s/([^&])\#/$1\\#/g;   $string=~s/([^&])\#/$1\\#/g;
    $string=~s/([^\\])\#/$1\\#/g;
  $string=~s/(\$|_|{|})/\\$1/g;   $string=~s/(\$|_|{|})/\\$1/g;
  $string=~s/\\char92 /\\texttt{\\char92}/g;   $string=~s/\\char92 /\\texttt{\\char92}/g;
  $string=~s/(>|<)/\$$1\$/g; #more or less   $string=~s/(>|<)/\$$1\$/g; #more or less
Line 625  sub setup_globals { Line 629  sub setup_globals {
   @Apache::lonxml::extlinks=();    @Apache::lonxml::extlinks=();
   @Apache::lonxml::ssi_info=();    @Apache::lonxml::ssi_info=();
   $Apache::lonxml::post_evaluate=1;    $Apache::lonxml::post_evaluate=1;
     $Apache::lonxml::warnings_error_header='';
   if ($target eq 'meta') {    if ($target eq 'meta') {
     $Apache::lonxml::redirection = 0;      $Apache::lonxml::redirection = 0;
     $Apache::lonxml::metamode = 1;      $Apache::lonxml::metamode = 1;
Line 994  sub parstring { Line 999  sub parstring {
       my $val=$token->[2]->{$_};        my $val=$token->[2]->{$_};
       $val =~ s/([\%\@\\\"\'])/\\$1/g;        $val =~ s/([\%\@\\\"\'])/\\$1/g;
       #if ($val =~ m/^[\%\@]/) { $val="\\".$val; }        #if ($val =~ m/^[\%\@]/) { $val="\\".$val; }
       if ($val !~ m/^\s*\$[a-z_]/i) { $val =~ s/\$/\\\$/g; }  
       $temp .= "my \$$_=\"$val\";";        $temp .= "my \$$_=\"$val\";";
     }      }
   }    }
Line 1291  sub display_title { Line 1295  sub display_title {
 }  }
   
 sub debug {  sub debug {
   if ($Apache::lonxml::debug eq 1) {      if ($Apache::lonxml::debug eq "1") {
     $|=1;   $|=1;
     print('<font size="-2"<pre>DEBUG:'.&HTML::Entities::encode($_[0])."</pre></font>\n");   my $request=$Apache::lonxml::request;
   }   if (!$request) { $request=Apache->request; }
    $request->print('<font size="-2"><pre>DEBUG:'.&HTML::Entities::encode($_[0])."</pre></font>\n");
       }
 }  }
   
 sub error {  sub error {
   $errorcount++;    $errorcount++;
     my $request=$Apache::lonxml::request;
     if (!$request) { $request=Apache->request; }
   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";        $request->print($Apache::lonxml::warnings_error_header.
         "<b>ERROR:</b>".join("\n",@_)."\n");
         $Apache::lonxml::warnings_error_header='';
   } else {    } else {
     print "<b>An Error occured while processing this resource. The instructor has been notified.</b> <br />";      $request->print("<b>An Error occured while processing this resource. The instructor has been notified.</b> <br />");
     #notify author      #notify author
     &Apache::lonmsg::author_res_msg($ENV{'request.filename'},join('<br />',@_));      &Apache::lonmsg::author_res_msg($ENV{'request.filename'},join('<br />',@_));
     #notify course      #notify course
Line 1324  sub error { Line 1334  sub error {
 }  }
   
 sub warning {  sub warning {
   $warningcount++;      $warningcount++;
       
   if ($ENV{'form.grade_target'} ne 'tex') {      if ($ENV{'form.grade_target'} ne 'tex') {
       if ($ENV{'request.state'} eq 'construct' || $Apache::lonxml::debug) {   if ($ENV{'request.state'} eq 'construct' || $Apache::lonxml::debug) {
         print "<b>W</b>ARNING<b>:</b>".join('<br />',@_)."<br />\n";      my $request=$Apache::lonxml::request;
       }      if (!$request) { $request=Apache->request; }
   }      $request->print($Apache::lonxml::warnings_error_header.
         "<b>W</b>ARNING<b>:</b>".join('<br />',@_)."<br />\n");
       $Apache::lonxml::warnings_error_header='';
    }
       }
 }  }
   
 sub get_param {  sub get_param {
Line 1338  sub get_param { Line 1352  sub get_param {
     if ( ! $context ) { $context = -1; }      if ( ! $context ) { $context = -1; }
     my $args ='';      my $args ='';
     if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; }      if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; }
       if ( ! $Apache::lonxml::usestyle ) {
    $args=$Apache::lonxml::style_values.$args;
       }
     if ( ! $args ) { return undef; }      if ( ! $args ) { return undef; }
     if ( $case_insensitive ) {      if ( $case_insensitive ) {
  if ($args =~ s/(my \$)(\Q$param\E)(=\")/$1.lc($2).$3/ei) {   if ($args =~ s/(my \$)(\Q$param\E)(=\")/$1.lc($2).$3/ei) {
Line 1361  sub get_param_var { Line 1378  sub get_param_var {
   if ( ! $context ) { $context = -1; }    if ( ! $context ) { $context = -1; }
   my $args ='';    my $args ='';
   if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; }    if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; }
     if ( ! $Apache::lonxml::usestyle ) {
         $args=$Apache::lonxml::style_values.$args;
     }
   &Apache::lonxml::debug("Args are $args param is $param");    &Apache::lonxml::debug("Args are $args param is $param");
   if ($case_insensitive) {    if ($case_insensitive) {
       if (! ($args=~s/(my \$)(\Q$param\E)(=\")/$1.lc($2).$3/ei)) {        if (! ($args=~s/(my \$)(\Q$param\E)(=\")/$1.lc($2).$3/ei)) {

Removed from v.1.294  
changed lines
  Added in v.1.301


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