Annotation of loncom/xml/scripttag.pm, revision 1.6
1.1 albertel 1: # The LearningOnline Network with CAPA
2: # <script> definiton
3:
4:
5: package Apache::scripttag;
6:
7: use strict;
1.3 albertel 8: use Apache::lonnet;
1.1 albertel 9:
10: sub BEGIN {
1.6 ! albertel 11: &Apache::lonxml::register('Apache::scripttag',('script','scriptlib',
! 12: 'parserlib','import'));
1.1 albertel 13: }
14:
15: sub start_script {
1.2 albertel 16: my ($target,$token,$parstack,$parser,$safeeval)=@_;
1.1 albertel 17:
1.2 albertel 18: my $result="";
1.5 albertel 19: my $bodytext=$$parser[$#$parser]->get_text("/script");
1.2 albertel 20: if ($target ne "edit" ) {
1.3 albertel 21: $result = &Apache::run::run($bodytext,$safeeval);
1.2 albertel 22: } else {
23: $result="<textarea>$bodytext</textarea>\n";
24: }
25: return $result;
1.1 albertel 26: }
27:
1.3 albertel 28: sub end_script {}
29:
30: sub start_scriptlib {
31: my ($target,$token,$parstack,$parser,$safeeval)=@_;
1.5 albertel 32: my $bodytext=$$parser[$#$parser]->get_text("/scriptlib");
1.3 albertel 33: my $result ="";
34: if ($target ne "edit" ) {
1.6 ! albertel 35: &Apache::run::run(&getfile("/home/httpd/html".$bodytext),$safeeval);
1.3 albertel 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 {}
1.4 albertel 44:
45: sub start_parserlib {
46: my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
1.6 ! albertel 47: my $bodytext=$$parser[$#$parser]->get_text("/parserlib");
! 48: %$style = ( %$style , &Apache::style::styleparser($target,
! 49: &getfile("/home/httpd/html/".$bodytext)));
1.4 albertel 50: }
51:
52: sub end_parserlib {
1.6 ! albertel 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 {
1.4 albertel 65: }
1.3 albertel 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
1.1 albertel 78: }
1.3 albertel 79:
1.1 albertel 80: 1;
81: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>