File:  [LON-CAPA] / loncom / xml / scripttag.pm
Revision 1.3: download - view: text, annotated - select for diffs
Tue Jul 25 21:28:22 2000 UTC (23 years, 10 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- added <scriptlib> tag
- changed lonxml to not evaluate emty strings

    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: }
   13: 
   14: sub start_script {
   15:   my ($target,$token,$parstack,$parser,$safeeval)=@_;
   16:   
   17:   my $result="";
   18:   my $bodytext=$parser->get_text("/script");
   19:   if ($target ne "edit" ) {
   20:     $result = &Apache::run::run($bodytext,$safeeval);
   21:   } else {
   22:     $result="<textarea>$bodytext</textarea>\n";
   23:   }
   24:   return $result;
   25: }
   26: 
   27: sub end_script {}
   28: 
   29: sub start_scriptlib {
   30:   my ($target,$token,$parstack,$parser,$safeeval)=@_;
   31:   my $bodytext=$parser->get_text("/scriptlib");
   32:   my $result ="";
   33:   if ($target ne "edit" ) {
   34:     &Apache::run::run(&getfile($bodytext),$safeeval);
   35:     #print "ran $bodytext:<br>".&getfile($bodytext)."<br>";
   36:   } else {
   37:     $result="<textarea>$bodytext</textarea>\n";
   38:   }
   39:   return $result;
   40: }
   41: 
   42: sub end_scriptlib {}
   43: 
   44: sub getfile {
   45:   my ($filename) = @_;
   46:   my $a="";
   47:   &Apache::lonnet::repcopy($filename);
   48:   {
   49:     my $fh=Apache::File->new($filename);
   50:     while (<$fh>) {
   51:       $a .=$_;
   52:     }
   53:   }
   54:   return $a
   55: }
   56: 
   57: 1;
   58: __END__

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