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','parserlib'));
12: }
13:
14: sub start_script {
15: my ($target,$token,$parstack,$parser,$safeeval)=@_;
16:
17: my $result="";
18: my $bodytext=$$parser[$#$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[$#$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 start_parserlib {
45: my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
46: my $bodytext="/home/httpd/html/".$$parser[$#$parser]->get_text("/parserlib");
47: %$style = ( %$style , &Apache::style::styleparser($target, &getfile($bodytext)));
48: }
49:
50: sub end_parserlib {
51: }
52:
53: sub getfile {
54: my ($filename) = @_;
55: my $a="";
56: &Apache::lonnet::repcopy($filename);
57: {
58: my $fh=Apache::File->new($filename);
59: while (<$fh>) {
60: $a .=$_;
61: }
62: }
63: return $a
64: }
65:
66: 1;
67: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>