File:  [LON-CAPA] / loncom / xml / scripttag.pm
Revision 1.6: download - view: text, annotated - select for diffs
Mon Aug 7 21:26:21 2000 UTC (23 years, 10 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- <import> tag done

    1: # The LearningOnline Network with CAPA
    2: # <script> definiton
    3: 
    4: 
    5: package Apache::scripttag; 
    6: 
    7: use strict;
    8: use Apache::lonnet;
    9: 
   10: sub BEGIN {
   11:   &Apache::lonxml::register('Apache::scripttag',('script','scriptlib',
   12: 						 'parserlib','import'));
   13: }
   14: 
   15: sub start_script {
   16:   my ($target,$token,$parstack,$parser,$safeeval)=@_;
   17:   
   18:   my $result="";
   19:   my $bodytext=$$parser[$#$parser]->get_text("/script");
   20:   if ($target ne "edit" ) {
   21:     $result = &Apache::run::run($bodytext,$safeeval);
   22:   } else {
   23:     $result="<textarea>$bodytext</textarea>\n";
   24:   }
   25:   return $result;
   26: }
   27: 
   28: sub end_script {}
   29: 
   30: sub start_scriptlib {
   31:   my ($target,$token,$parstack,$parser,$safeeval)=@_;
   32:   my $bodytext=$$parser[$#$parser]->get_text("/scriptlib");
   33:   my $result ="";
   34:   if ($target ne "edit" ) {
   35:     &Apache::run::run(&getfile("/home/httpd/html".$bodytext),$safeeval);
   36:     #print "ran $bodytext:<br>".&getfile($bodytext)."<br>";
   37:   } else {
   38:     $result="<textarea>$bodytext</textarea>\n";
   39:   }
   40:   return $result;
   41: }
   42: 
   43: sub end_scriptlib {}
   44: 
   45: sub start_parserlib {
   46:   my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
   47:   my $bodytext=$$parser[$#$parser]->get_text("/parserlib");
   48:   %$style = ( %$style , &Apache::style::styleparser($target, 
   49:              &getfile("/home/httpd/html/".$bodytext)));
   50: }
   51: 
   52: sub end_parserlib {
   53: }
   54: 
   55: sub start_import {
   56:   my ($target,$token,$parstack,$parser)=@_;
   57:   my $bodytext=$$parser[$#$parser]->get_text("/import");
   58:   print "going after".$bodytext."\n";
   59:   my $file=&getfile("/home/httpd/html/".$bodytext);
   60:   my $tempparser=HTML::TokeParser->new(\$file);
   61:   push (@$parser,$tempparser);
   62: }
   63: 
   64: sub end_import {
   65: }
   66: 
   67: sub getfile {
   68:   my ($filename) = @_;
   69:   my $a="";
   70:   &Apache::lonnet::repcopy($filename);
   71:   {
   72:     my $fh=Apache::File->new($filename);
   73:     while (<$fh>) {
   74:       $a .=$_;
   75:     }
   76:   }
   77:   return $a
   78: }
   79: 
   80: 1;
   81: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.