Diff for /loncom/xml/scripttag.pm between versions 1.36 and 1.37

version 1.36, 2001/03/27 18:19:29 version 1.37, 2001/05/04 21:17:24
Line 24  sub start_script { Line 24  sub start_script {
     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;
     } 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.=&editfield($token->[1],$bodytext);        $result.=&Apache::edit::editfield($token->[1],$bodytext);
     }      }
   } else {    } else {
     if ($target ne "meta") { $result = $token->[4]; }      if ($target ne "meta") { $result = $token->[4]; }
Line 67  sub start_display { Line 68  sub start_display {
   if ($target eq "edit" ) {    if ($target eq "edit" ) {
     $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.=&editfield($token->[1],$bodytext);      $result.=&Apache::edit::editfield($token->[1],$bodytext);
   }    }
   return $result;    return $result;
 }  }
Line 76  sub end_display { Line 77  sub end_display {
 }  }
   
 sub start_scriptlib {  sub start_scriptlib {
   my ($target,$token,$parstack,$parser,$safeeval)=@_;    my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
   my $bodytext=$$parser[$#$parser]->get_text("/scriptlib");    my $bodytext;
   my $result ="";    my $result ='';
     my $error='';
   $bodytext=&Apache::run::evaluate($bodytext,$safeeval,  
    $$parstack[$#$parstack]);    if ($target eq 'web' || $target eq 'grade' || $target eq 'meta' || $target eq 'edit') {
   my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],      $bodytext=$$parser[$#$parser]->get_text("/scriptlib");
      $bodytext);      $bodytext=&Apache::run::evaluate($bodytext,$safeeval,
   my $script=&Apache::lonnet::getfile($location);       $$parstack[$#$parstack]);
   if ($script == -1) {      my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],
     &Apache::lonxml::error("<b> Unable to find <i>$location</i> for scriptlib</b>");         $bodytext);
     return "";      my $script=&Apache::lonnet::getfile($location);
       if ($script == -1) {
         if ($target eq 'edit') {
           $error='</tr><tr><td>Errors</td><td colspan="2"><b> Unable to find <i>'.$location.'</i></b></td>'."\n";
         } else {
    &Apache::lonxml::error("<b> Unable to find <i>$location</i> for scriptlib</b>");
    return "";
         }
       }
       &Apache::run::run($script,$safeeval);
       #&Apache::lonxml::debug("ran $bodytext:<br />".&Apache::lonnet::getfile($bodytext)."<br />");
   }    }
   &Apache::run::run($script,$safeeval);  
   #&Apache::lonxml::debug("ran $bodytext:<br />".&Apache::lonnet::getfile($bodytext)."<br />");  
   
   if ($target eq "edit" ) {    if ($target eq "edit" ) {
     $result.=&editfield($token->[1],$bodytext);      $result=
         &Apache::edit::tag_start($token->[1]).
    &Apache::edit::editfield($token->[1],$bodytext,'New Script Functions').
     $error;
     }
     if ($target eq "modified" ) {
       $bodytext=$$parser[$#$parser]->get_text("/scriptlib");
       $result=&Apache::edit::modifiedfield($token);
       &Apache::lonxml::debug($result);
   }    }
   return $result;    return $result;
 }  }
   
 sub end_scriptlib {}  sub end_scriptlib {
     my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
     my $result='';
   #  if ($target eq "edit" ) { $result=" "; }
     return $result;
   }
   
 sub start_parserlib {  sub start_parserlib {
   my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;    my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
   my $bodytext=$$parser[$#$parser]->get_text("/parserlib");    my $bodytext;
   my $result ="";    my $result ="";
     my $error='';
   
   $bodytext=&Apache::run::evaluate($bodytext,$safeeval,    if ($target eq 'web' || $target eq 'grade' || $target eq 'meta' || $target eq 'edit') {
   $$parstack[$#$parstack]);      $bodytext=$$parser[$#$parser]->get_text("/parserlib");
   my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],      $bodytext=&Apache::run::evaluate($bodytext,$safeeval,
      $bodytext);       $$parstack[$#$parstack]);
   my $styletext=&Apache::lonnet::getfile($location);      my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],
   #&Apache::lonxml::debug("found :$bodytext: in :$location: with :$styletext:");         $bodytext);
   if ($styletext == -1) {      my $styletext=&Apache::lonnet::getfile($location);
     &Apache::lonxml::error("<b> Unable to find <i>$location</i> for parserlib</b>");      #&Apache::lonxml::debug("found :$bodytext: in :$location: with :$styletext:");
     return "";      if ($styletext == -1) {
         if ($target eq 'edit') {
    $error='</tr><tr><td>Errors</td><td colspan="2"><b> Unable to find <i>'.$location.'</i></b></td>'."\n";
         } else {
    &Apache::lonxml::error("<b> Unable to find <i>$location</i> for parserlib</b>");
    return "";
         }
       }
       %$style = ( %$style , &Apache::style::styleparser($target,$styletext));
   }    }
   %$style = ( %$style , &Apache::style::styleparser($target,$styletext));  
   
   if ($target eq "edit" ) {    if ($target eq "edit" ) {
     $result=&editfield($token->[1],$bodytext);      $result=
         &Apache::edit::tag_start($token->[1]).
    &Apache::edit::editfield($token->[1],$bodytext,"New Tag Definitions").
     $error;
     }
     if ($target eq "modified" ) {
       $bodytext=$$parser[$#$parser]->get_text("/parserlib");
       $result=&Apache::edit::modifiedfield($token);
       &Apache::lonxml::debug($result);
   }    }
   return $result;    return $result;
 }  }
   
 sub end_parserlib {  sub end_parserlib {
     my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
     my $result='';
   #  if ($target eq "edit" ) { 
   #    $result=&Apache::edit::tag_end($target,$token,$parstack,$parser,
   #   $safeeval,$style);
   #  }
     return $result;
 }  }
   
 sub start_window {  sub start_window {
Line 171  sub start_import { Line 214  sub start_import {
   &Apache::lonxml::newparser($parser,\$file,$dir);    &Apache::lonxml::newparser($parser,\$file,$dir);
   
   if ($target eq "edit" ) {    if ($target eq "edit" ) {
     $result.=&editfield($token->[1],$bodytext);      $result.=&Apache::edit::editfield($token->[1],$bodytext);
     $result.="Click<a href=\"/res/$bodytext\">here</a> to edit<br />"      $result.="Click<a href=\"/res/$bodytext\">here</a> to edit<br />"
   }    }
   return '';    return '';
Line 195  sub start_meta { Line 238  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);  
   if ($maxlength > 80) { $maxlength = 80; }  
   return "<br />\n&nbsp;&nbsp;&nbsp;<textarea rows=\"$count\" cols=\"$maxlength\" name=homework_edit_".$Apache::lonxml::curdepth.">$data</textarea>\n";  
 #  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 {  sub getfilenothere {
   my ($filename) = @_;    my ($filename) = @_;
   my $a="";    my $a="";

Removed from v.1.36  
changed lines
  Added in v.1.37


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