Diff for /loncom/xml/scripttag.pm between versions 1.103 and 1.113

version 1.103, 2003/10/30 20:52:54 version 1.113, 2004/07/15 16:43:37
Line 109  sub start_script { Line 109  sub start_script {
     } elsif ( $target eq 'web' || $target eq 'tex' ||      } elsif ( $target eq 'web' || $target eq 'tex' ||
       $target eq 'grade' || $target eq 'answer' ||        $target eq 'grade' || $target eq 'answer' ||
       $target eq 'analyze' ) {        $target eq 'analyze' ) {
  my $bodytext=&Apache::lonxml::get_all_text("/script",$parser);   my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
  if (!$Apache::lonxml::default_homework_loaded) {   if (!$Apache::lonxml::default_homework_loaded) {
     &Apache::lonxml::default_homework_load($safeeval);      &Apache::lonxml::default_homework_load($safeeval);
  }   }
Line 118  sub start_script { Line 118  sub start_script {
     ($ENV{'form.answer_output_mode'} ne 'tex') &&      ($ENV{'form.answer_output_mode'} ne 'tex') &&
     ($Apache::lonhomework::viewgrades == 'F')) {      ($Apache::lonhomework::viewgrades == 'F')) {
     $Apache::lonxml::evaluate--;      $Apache::lonxml::evaluate--;
     $result.="<script type=\"text/javascript\"> function LONCAPA_scriptvars_$Apache::lonxml::curdepth() {newWindow=open('','new_W','width=500,height=200,scrollbars=1');newWindow.document.open('text/html','replace');newWindow.document.writeln('<html><head><title>Script Vars</title></head><body bgcolor=\"#FFFFFF\"><pre>";      my (undef,undef,$udom,$uname)=&Apache::lonxml::whichuser();
       $result.="<script type=\"text/javascript\"> function LONCAPA_scriptvars_".$uname."_".$udom."_"."$Apache::lonxml::curdepth() {newWindow=open('','new_W','width=500,height=500,scrollbars=1,resizable=yes');newWindow.document.open('text/html','replace');newWindow.document.writeln('<html><head><title>Script Vars</title></head><body bgcolor=\"#FFFFFF\"><pre>";
     my $listing=&Apache::run::dump($target,$safeeval);      my $listing=&Apache::run::dump($target,$safeeval);
     $listing=~s/\'/\\\'/g;      $listing=~s/\'/\\\'/g;
     $listing=~s/\n/\\n/g;      $listing=~s/\n/\\n/g;
     $listing=~s/\r/\\r/g;      $listing=~s/\r/\\r/g;
     $result.=$listing;      $result.=$listing;
     $result.= "</pre></body></html>');newWindow.document.close();}</script><a href=\"javascript:LONCAPA_scriptvars_$Apache::lonxml::curdepth();void(0);\">Script Vars</a><br />";      $result.= "</pre></body></html>');newWindow.document.close();}</script><a href=\"javascript:LONCAPA_scriptvars_".$uname."_".$udom."_$Apache::lonxml::curdepth();void(0);\">Script Vars</a><br />";
  }   }
     } elsif ($target eq "edit" ) {      } elsif ($target eq "edit" ) {
       #&Apache::run::run($bodytext,$safeeval);        #&Apache::run::run($bodytext,$safeeval);
       #$result="<br /> &lt;$token->[1]&gt; output: <br />$bodytext<br />Source:<br />";        #$result="<br /> &lt;$token->[1]&gt; output: <br />$bodytext<br />Source:<br />";
  my $bodytext=&Apache::lonxml::get_all_text("/script",$parser);   my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
  $result=&Apache::edit::tag_start($target,$token,'Script');   $result=&Apache::edit::tag_start($target,$token,'Script');
  $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4);   $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4);
       } elsif ($target eq 'meta') {
    my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
     }      }
   } else {    } else {
     if ($target ne "meta") {        my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
       $result = $token->[4];        if ($target ne "meta") {
       my $bodytext=&Apache::lonxml::get_all_text("/script",$parser);    $result = $token->[4];
       $result.=$bodytext;    $result.=$bodytext;
     }        }
   }    }
   return $result;    return $result;
 }  }
Line 169  sub start_display { Line 172  sub start_display {
   } elsif ( $target eq 'web' || $target eq 'tex' ||    } elsif ( $target eq 'web' || $target eq 'tex' ||
     $target eq 'grade' || $target eq 'answer' ||      $target eq 'grade' || $target eq 'answer' ||
       $target eq 'analyze') {        $target eq 'analyze') {
       my $bodytext=&Apache::lonxml::get_all_text("/display",$parser);        my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/display",$parser);
       if (!$Apache::lonxml::default_homework_loaded) {        if (!$Apache::lonxml::default_homework_loaded) {
   &Apache::lonxml::default_homework_load($safeeval);    &Apache::lonxml::default_homework_load($safeeval);
       }        }
Line 180  sub start_display { Line 183  sub start_display {
       }        }
       $Apache::lonxml::post_evaluate=0;        $Apache::lonxml::post_evaluate=0;
   } elsif ($target eq "edit" ) {    } elsif ($target eq "edit" ) {
     my $bodytext=&Apache::lonxml::get_all_text("/display",$parser);      my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/display",$parser);
     #$result =       #$result = 
     #  "<br /> &lt;$token->[1]&gt; output: <br />$bodytext<br />Source:<br />";      #  "<br /> &lt;$token->[1]&gt; output: <br />$bodytext<br />Source:<br />";
     #$result.=&Apache::edit::editfield($token->[1],$bodytext,'',40,1);      #$result.=&Apache::edit::editfield($token->[1],$bodytext,'',40,1);
     $result=&Apache::edit::tag_start($target,$token,'Script With Display');      $result=&Apache::edit::tag_start($target,$token,'Script With Display');
     $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,1)      $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,1)
     } elsif ($target eq 'meta') {
         my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/display",$parser);
   }    }
   return $result;    return $result;
 }  }
Line 202  sub start_scriptlib { Line 207  sub start_scriptlib {
   my $result ='';    my $result ='';
   my $error='';    my $error='';
   
   if ($target eq 'web' || $target eq 'grade' || $target eq 'meta' ||     if ($target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
       $target eq 'edit' || $target eq 'answer' || $target eq 'analyze') {        $target eq 'meta' || $target eq 'edit' || $target eq 'answer' ||
         $target eq 'analyze') {
     $bodytext=$$parser[$#$parser]->get_text("/scriptlib");      $bodytext=$$parser[$#$parser]->get_text("/scriptlib");
     $bodytext=&Apache::run::evaluate($bodytext,$safeeval,      $bodytext=&Apache::run::evaluate($bodytext,$safeeval,
      $$parstack[$#$parstack]);       $$parstack[$#$parstack]);
Line 247  sub start_parserlib { Line 253  sub start_parserlib {
   my $bodytext;    my $bodytext;
   my $result ="";    my $result ="";
   my $error='';    my $error='';
   if ($target eq 'web' || $target eq 'grade' || $target eq 'meta' ||    if ($target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
       $target eq 'edit' || $target eq 'answer' || $target eq 'analyze') {        $target eq 'meta' || $target eq 'edit' || $target eq 'answer' ||
         $target eq 'analyze') {
     $bodytext=$$parser[$#$parser]->get_text("/parserlib");      $bodytext=$$parser[$#$parser]->get_text("/parserlib");
     $bodytext=&Apache::run::evaluate($bodytext,$safeeval,      $bodytext=&Apache::run::evaluate($bodytext,$safeeval,
      $$parstack[$#$parstack]);       $$parstack[$#$parstack]);
Line 287  sub end_parserlib { Line 294  sub end_parserlib {
 }  }
   
 sub start_window {  sub start_window {
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   my $result = '';      my $result = '';
   if ($target eq 'web') {      if ($target eq 'web') {
     &Apache::lonxml::startredirection;   &Apache::lonxml::startredirection;
   }  elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
        $result = '\unskip\footnote{';   $result = '\unskip\footnote{';
    }      } elsif ($target eq 'edit') {
   return $result;     $result.=&Apache::edit::tag_start($target,$token);
    $result.=&Apache::edit::text_arg('Text of Link:','linktext',$token,70);
    $result.=&Apache::edit::text_arg('Height:','width',$token,5);
    $result.=&Apache::edit::text_arg('Width:','height',$token,5);
    $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
       } elsif ($target eq 'modified') {
    my $constructtag=&Apache::edit::get_new_args($token,$parstack,
        $safeeval,'linttext',
        'width','height');
    if ($constructtag) { $result=&Apache::edit::rebuild_tag($token); }
       }
       return $result;  
 }  }
   
 sub end_window {  sub end_window {
Line 464  sub end_comment { Line 482  sub end_comment {
   
 sub xmlparse {  sub xmlparse {
   my ($string) = @_;    my ($string) = @_;
 #  &Apache::lonxml::debug("Got $string");    &Apache::lonxml::debug("xmlparse recursion starting with $string");
     # Apache::run::evaluate does an 'eval' on the name of the subroutine
     # if it detects something that looks like a subroutine, this ends up calling
     # things without any arguments and since perl is nice enough to pass
     # along the default arguments when you don't explicitly say no arguments
     # if you call &xmlparse, it gets &xmlparse passed as it argument.
     # Same thing soccurs with &chemparse.
     if ($string eq '&xmlparse') { return '&xmlparse'; }
     if ($string eq '&chemparse') { return '&chemparse'; }
   my ($target,$token,$tagstack,$parstack,$oldparser,$safeeval,$style)=    my ($target,$token,$tagstack,$parstack,$oldparser,$safeeval,$style)=
     @Apache::scripttag::parser_env;      @Apache::scripttag::parser_env;
   my @parser;    my @parser;
Line 472  sub xmlparse { Line 498  sub xmlparse {
   my $result=&Apache::lonxml::inner_xmlparse($target,$tagstack,    my $result=&Apache::lonxml::inner_xmlparse($target,$tagstack,
      $parstack,\@parser,       $parstack,\@parser,
      $safeeval,$style);       $safeeval,$style);
     &Apache::lonxml::debug("xmlparse recursion ending with $result");
   return $result;    return $result;
 }  }
   

Removed from v.1.103  
changed lines
  Added in v.1.113


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