Diff for /loncom/xml/scripttag.pm between versions 1.40 and 1.42

version 1.40, 2001/06/02 03:59:59 version 1.42, 2001/07/06 19:50:02
Line 6  package Apache::scripttag; Line 6  package Apache::scripttag;
   
 use strict;  use strict;
 use Apache::lonnet;  use Apache::lonnet;
   use Apache::style;
   
 sub BEGIN {  sub BEGIN {
   &Apache::lonxml::register('Apache::scripttag',('script','scriptlib',    &Apache::lonxml::register('Apache::scripttag',('script','scriptlib',
  'parserlib','import',   'parserlib','import',
                                                  'window','display'));                                                   'window','display',
                                                    'storetc','physnet'));
 }  }
   
 sub start_script {  sub start_script {
Line 20  sub start_script { Line 22  sub start_script {
   &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[$#$parser]);      my $bodytext=&Apache::lonxml::get_all_text("/script",$$parser[$#$parser]);
       
     if ( $target eq "modified" ) {      if ( $target eq "modified" ) {
       $result=$token->[4].$bodytext;        $result=$token->[4].&Apache::edit::modifiedfield();
     } elsif ( $target eq "web" || $target eq "grade" ) {      } elsif ( $target eq "web" || $target eq "grade" ) {
       &Apache::run::run($bodytext,$safeeval);        &Apache::run::run($bodytext,$safeeval);
     } 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::editfield($token->[1],$bodytext,'',50,5);        $result=&Apache::edit::tag_start($target,$token,'Script');
         $result.=&Apache::edit::editfield($token->[1],$bodytext,'',50,4);
     }      }
   } else {    } else {
     if ($target ne "meta") { $result = $token->[4]; }      if ($target ne "meta") { $result = $token->[4]; }
Line 43  sub end_script { Line 45  sub end_script {
   my $result='';    my $result='';
   #other script blocks need to survive    #other script blocks need to survive
   if ($type ne "loncapa/perl") { return $token->[2]; }    if ($type ne "loncapa/perl") { return $token->[2]; }
     if ($target eq 'edit' ) { return &Apache::edit::end_table(); }
   return '';    return '';
 }  }
   
Line 168  sub start_window { Line 171  sub start_window {
   if ($target eq 'web') {    if ($target eq 'web') {
     &Apache::lonxml::startredirection;      &Apache::lonxml::startredirection;
   }  elsif ($target eq 'tex') {    }  elsif ($target eq 'tex') {
        $result = '\footnote{';         $result = '\unskip\footnote{';
    }     }
   return $result;      return $result;  
 }  }
Line 231  sub start_meta { Line 234  sub start_meta {
 sub end_meta {  sub end_meta {
 }  }
   
   sub editfield {
     my ($tag,$data)=@_;
     
     my $count=0;
     my $maxlength=-1;
     map { $count++;
    if (length($_) > $maxlength) { $maxlength = length ($_); }
         } split ("\n", $data);
     
     return "<br />\n&lt;$tag&gt;<br />\n&nbsp;&nbsp;&nbsp;<textarea rows=\"$count\" cols=\"$maxlength\" name=homework_edit_".$Apache::lonxml::curdepth.">$data</textarea><br />\n&lt;/$tag&gt;<br />\n";
   }
   
   sub getfilenothere {
     my ($filename) = @_;
     my $a="";
     
     $filename=~ s/^\s*(\S+)\s*$/$1/; ## strip off leading and trailing spaces
     $filename="/home/httpd/html/res".$filename;
     if (! -e $filename ) {
       &Apache::lonnet::subscribe($filename);
       &Apache::lonnet::repcopy($filename);
     }
     if (! -e $filename ) { return -1; };
     my $fh=Apache::File->new($filename);
     while (<$fh>) {
         $a .=$_;
     }
     return $a
   }
   
   
   sub start_storetc {
     my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
     my $result = '';
     &Apache::lonxml::startredirection;
     return $result; 
   }
   
   sub end_storetc {
       my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
       my $result;
       my $output=&Apache::lonxml::endredirection;
       $output =~ s/\"/\&quot\;/g;
       $result = "{\bf $output.}}\write\tcfile{\protect\tcpc{ $output.}{\the\value{relpage}}}";
       return $result; 
   }
   
   
   sub start_physnet {
   
       my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
       my $cbistylefile = &Apache::lonnet::getfile('/home/httpd/res/msu/physnet/cbi.sty');
       %$style = (%$style,&Apache::style::styleparser($target,$cbistylefile));
       &Apache::lonxml::newparser($parser$$style{'physnet'});
   
       return "";
   }
   
   
 1;  1;
 __END__  __END__

Removed from v.1.40  
changed lines
  Added in v.1.42


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