Diff for /loncom/xml/scripttag.pm between versions 1.99 and 1.108

version 1.99, 2003/06/18 21:04:42 version 1.108, 2004/02/11 15:10:05
Line 45  BEGIN { Line 45  BEGIN {
      'window','display','storetc','physnet',       'window','display','storetc','physnet',
      'standalone','comment',       'standalone','comment',
      'LONCAPA_INTERNAL_TURN_STYLE_ON',       'LONCAPA_INTERNAL_TURN_STYLE_ON',
        'LONCAPA_INTERNAL_TURN_STYLE_OFF',
      'LONCAPA_INTERNAL_LONHTTPD_PORT'));       'LONCAPA_INTERNAL_LONHTTPD_PORT'));
 }  }
   
Line 63  sub end_LONCAPA_INTERNAL_TURN_STYLE_ON { Line 64  sub end_LONCAPA_INTERNAL_TURN_STYLE_ON {
     return ('','no');      return ('','no');
 }  }
   
   sub start_LONCAPA_INTERNAL_TURN_STYLE_OFF {
       my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
       $Apache::lonxml::usestyle=0;
       my $end=&Apache::lonxml::get_param('end',$parstack,$safeeval);
       if (!$end) {
    $Apache::lonxml::style_values=$$parstack[-1];
    $Apache::lonxml::style_end_values=$$parstack[-1];
       } else {
    $Apache::lonxml::style_values=$Apache::lonxml::style_end_values;
    $Apache::lonxml::style_end_values='';
       }
       return ('','no');
   }
   
   sub end_LONCAPA_INTERNAL_TURN_STYLE_OFF {
       return ('','no');
   }
   
 sub start_LONCAPA_INTERNAL_LONHTTPD_PORT {  sub start_LONCAPA_INTERNAL_LONHTTPD_PORT {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     if ($target eq 'web') {      if ($target eq 'web') {
Line 85  sub start_script { Line 104  sub start_script {
   my $type= &Apache::lonxml::get_param('type',$parstack,$safeeval);    my $type= &Apache::lonxml::get_param('type',$parstack,$safeeval);
   &Apache::lonxml::debug("found type of $type");    &Apache::lonxml::debug("found type of $type");
   if ($type eq "loncapa/perl") {    if ($type eq "loncapa/perl") {
     my $bodytext=&Apache::lonxml::get_all_text("/script",$parser);  
     if ( $target eq "modified" ) {      if ( $target eq "modified" ) {
       $result=$token->[4].&Apache::edit::modifiedfield();   $result=$token->[4].&Apache::edit::modifiedfield('/script',$parser);
     } 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_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 99  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>";      $result.="<script type=\"text/javascript\"> function LONCAPA_scriptvars_$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;
Line 110  sub start_script { Line 129  sub start_script {
     } 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 />";
       $result=&Apache::edit::tag_start($target,$token,'Script');   my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
       $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4);   $result=&Apache::edit::tag_start($target,$token,'Script');
    $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") {      if ($target ne "meta") {
       $result = $token->[4];        $result = $token->[4];
       my $bodytext=&Apache::lonxml::get_all_text("/script",$parser);        my $bodytext=&Apache::lonxml::get_all_text_unbalanced("/script",$parser);
       $result.=$bodytext;        $result.=$bodytext;
     }      }
   }    }
Line 143  sub start_display { Line 165  sub start_display {
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;    my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   
   my $result;    my $result;
   my $bodytext=&Apache::lonxml::get_all_text("/display",$parser);  
   
   if ( $target eq "modified" ) {    if ( $target eq "modified" ) {
     $result=$token->[4].&Apache::edit::modifiedfield();        $result=$token->[4].&Apache::edit::modifiedfield("/display",$parser);
   } 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_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 158  sub start_display { Line 180  sub start_display {
   $target eq 'analyze') {    $target eq 'analyze') {
   $result=''; # grade should produce no output    $result=''; # grade should produce no output
       }        }
         $Apache::lonxml::post_evaluate=0;
   } elsif ($target eq "edit" ) {    } elsif ($target eq "edit" ) {
       my $bodytext=&Apache::lonxml::get_all_text_unblanced("/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 180  sub start_scriptlib { Line 206  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 208  sub start_scriptlib { Line 235  sub start_scriptlib {
     &Apache::edit::end_table();      &Apache::edit::end_table();
   }    }
   if ($target eq "modified" ) {    if ($target eq "modified" ) {
     $bodytext=$$parser[$#$parser]->get_text("/scriptlib");        $result=$token->[4].&Apache::edit::modifiedfield("/scriptlib",$parser);
     $result=$token->[4].&Apache::edit::modifiedfield($token);  
     &Apache::lonxml::debug($result);  
   }    }
   return $result;    return $result;
 }  }
Line 227  sub start_parserlib { Line 252  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 254  sub start_parserlib { Line 280  sub start_parserlib {
     &Apache::edit::end_table();      &Apache::edit::end_table();
   }    }
   if ($target eq "modified" ) {    if ($target eq "modified" ) {
     $bodytext=$$parser[$#$parser]->get_text("/parserlib");        $result=$token->[4].&Apache::edit::modifiedfield("/parserlib",$parser);
     $result=$token->[4].&Apache::edit::modifiedfield($token);  
     &Apache::lonxml::debug($result);  
   }    }
   return $result;    return $result;
 }  }
Line 269  sub end_parserlib { Line 293  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 338  sub start_import { Line 373  sub start_import {
     #my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);      #my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext);
     #$result.="Click<a href=\"$location\">here</a> to edit<br />"      #$result.="Click<a href=\"$location\">here</a> to edit<br />"
   } elsif ($target eq 'modified') {    } elsif ($target eq 'modified') {
     $bodytext=$$parser[$#$parser]->get_text("/import");        $result=$token->[4].&Apache::edit::modifiedfield("/import",$parser);
     $result=$token->[4].&Apache::edit::modifiedfield($token);  
     &Apache::lonxml::debug($result);  
   } elsif ($target eq 'meta') {    } elsif ($target eq 'meta') {
     my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);      my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
     $result.='<import part="'.$Apache::inputtags::part;      $result.='<import part="'.$Apache::inputtags::part;
Line 430  sub start_comment { Line 463  sub start_comment {
     my $bodytext=&Apache::lonxml::get_all_text("/comment",$parser);      my $bodytext=&Apache::lonxml::get_all_text("/comment",$parser);
     $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4)      $result.=&Apache::edit::editfield($token->[1],$bodytext,'',80,4)
   } elsif ( $target eq 'modified') {    } elsif ( $target eq 'modified') {
     $result=$token->[4].&Apache::edit::modifiedfield($token);      $result=$token->[4].&Apache::edit::modifiedfield("/comment",$parser);
   } elsif ( $target eq 'web' || $target eq 'tex' || $target eq 'grade' ||    } elsif ( $target eq 'web' || $target eq 'tex' || $target eq 'grade' ||
     $target eq 'answer' || $target eq 'meta' || $target eq 'analyze') {      $target eq 'answer' || $target eq 'meta' || $target eq 'analyze') {
     #normally throw away comments      #normally throw away comments

Removed from v.1.99  
changed lines
  Added in v.1.108


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