version 1.12, 2000/08/11 15:27:58
|
version 1.18, 2000/10/05 19:31:54
|
Line 12 sub BEGIN {
|
Line 12 sub BEGIN {
|
'parserlib','import')); |
'parserlib','import')); |
} |
} |
|
|
|
$Apache::scripttag::SCRIPT_RESULT=''; |
sub start_script { |
sub start_script { |
my ($target,$token,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$parstack,$parser,$safeeval)=@_; |
my $result=""; |
my $args =''; |
my $bodytext=$$parser[$#$parser]->get_text("/script"); |
if ( $#$parstack > -1 ) { |
if ($target ne "edit" ) { |
$args=$$parstack[$#$parstack]; |
$result = &Apache::run::run($bodytext,$safeeval); |
} |
|
my $type = &Apache::run::run("{$args;".'return $type}',$safeeval); |
|
#&Apache::lonxml::debug("found type of $type"); |
|
$Apache::scripttag::SCRIPT_RESULT=''; |
|
if ($type eq "loncapa/perl") { |
|
$safeeval->share('$SCRIPT_RESULT'); |
|
my $bodytext=&Apache::lonxml::get_all_text("script",$$parser[$#$parser]); |
|
|
|
if ( $target eq "modified" ) { |
|
} |
|
&Apache::run::run($bodytext,$safeeval); |
|
|
|
if ($target eq "edit" ) { |
|
$Apache::scripttag::SCRIPT_RESULT = |
|
"<br> <$token->[1]> output: <br>$bodytext<br>Source:<br>"; |
|
$Apache::scripttag::SCRIPT_RESULT.=&editfield($token->[1],$bodytext); |
|
} |
} else { |
} else { |
$result=&editfield($token->[1],$bodytext); |
$Apache::scripttag::SCRIPT_RESULT = $token->[4]; |
} |
} |
return $result; |
return $Apache::scripttag::SCRIPT_RESULT; |
} |
} |
|
|
sub end_script {} |
sub end_script { |
|
my ($target,$token,$parstack,$parser,$safeeval)=@_; |
|
return $token->[2]; |
|
} |
|
|
sub start_scriptlib { |
sub start_scriptlib { |
my ($target,$token,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$parstack,$parser,$safeeval)=@_; |
my $bodytext=$$parser[$#$parser]->get_text("/scriptlib"); |
my $bodytext=$$parser[$#$parser]->get_text("/scriptlib"); |
my $result =""; |
my $result =""; |
if ($target ne "edit" ) { |
|
$bodytext=Apache::run::evaluate($bodytext,$safeeval,$$parstack[$#$parstack]); |
$bodytext=&Apache::run::evaluate($bodytext,$safeeval, |
&Apache::run::run(&getfile($bodytext),$safeeval); |
$$parstack[$#$parstack]); |
#print "ran $bodytext:<br>".&getfile($bodytext)."<br>"; |
my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'], |
} else { |
$bodytext); |
$result=&editfield($token->[1],$bodytext); |
my $script=&Apache::lonnet::getfile($location); |
|
if ($script == -1) { |
|
&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>"); |
|
|
|
if ($target eq "edit" ) { |
|
$result.=&editfield($token->[1],$bodytext); |
} |
} |
return $result; |
return $result; |
} |
} |
Line 46 sub start_parserlib {
|
Line 75 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=$$parser[$#$parser]->get_text("/parserlib"); |
my $result =""; |
my $result =""; |
if ($target ne "edit" ) { |
|
$bodytext=Apache::run::evaluate($bodytext,$safeeval,$$parstack[$#$parstack]); |
$bodytext=&Apache::run::evaluate($bodytext,$safeeval, |
%$style = ( %$style , &Apache::style::styleparser($target, |
$$parstack[$#$parstack]); |
&getfile($bodytext))); |
my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'], |
} else { |
$bodytext); |
|
my $styletext=&Apache::lonnet::getfile($location); |
|
if ($styletext == -1) { |
|
&Apache::lonxml::error("<b> Unable to find <i>$location</i> for parserlib</b>"); |
|
return ""; |
|
} |
|
%$style = ( %$style , &Apache::style::styleparser($target,$styletext)); |
|
|
|
if ($target eq "edit" ) { |
$result=&editfield($token->[1],$bodytext); |
$result=&editfield($token->[1],$bodytext); |
} |
} |
return $result; |
return $result; |
Line 63 sub start_import {
|
Line 100 sub start_import {
|
my ($target,$token,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$parstack,$parser,$safeeval,$style)=@_; |
my $bodytext=$$parser[$#$parser]->get_text("/import"); |
my $bodytext=$$parser[$#$parser]->get_text("/import"); |
my $result =""; |
my $result =""; |
if ($target ne "edit" ) { |
|
$bodytext=Apache::run::evaluate($bodytext,$safeeval,$$parstack[$#$parstack]); |
$bodytext=Apache::run::evaluate($bodytext,$safeeval,$$parstack[$#$parstack]); |
my $file=&getfile($bodytext); |
my $location=&Apache::lonnet::filelocation($Apache::lonxml::pwd['-1'],$bodytext); |
my $tempparser=HTML::TokeParser->new(\$file); |
my $file=&Apache::lonnet::getfile($location); |
push (@$parser,$tempparser); |
if ($file == -1) { |
} else { |
&Apache::lonxml::error("<b> Unable to find <i>$bodytext $location</i> for import</b>"); |
$result=&editfield($token->[1],$bodytext); |
return ""; |
|
} |
|
|
|
my $dir=$location; |
|
$dir=~s:/[^/]*$::; |
|
&Apache::lonxml::newparser($parser,\$file,$dir); |
|
|
|
if ($target eq "edit" ) { |
|
$result.=&editfield($token->[1],$bodytext); |
$result.="Click<a href=\"/res/$bodytext\">here</a> to edit<br></br>" |
$result.="Click<a href=\"/res/$bodytext\">here</a> to edit<br></br>" |
} |
} |
} |
} |
Line 89 sub editfield {
|
Line 134 sub editfield {
|
return "<br></br>\n<$tag><br></br>\n <textarea rows=\"$count\" cols=\"$maxlength\" name=homework_edit_".$Apache::lonxml::curdepth.">$data</textarea><br></br>\n</$tag><br></br>\n"; |
return "<br></br>\n<$tag><br></br>\n <textarea rows=\"$count\" cols=\"$maxlength\" name=homework_edit_".$Apache::lonxml::curdepth.">$data</textarea><br></br>\n</$tag><br></br>\n"; |
} |
} |
|
|
sub getfile { |
sub getfilenothere { |
my ($filename) = @_; |
my ($filename) = @_; |
my $a=""; |
my $a=""; |
|
|
Line 99 sub getfile {
|
Line 144 sub getfile {
|
&Apache::lonnet::subscribe($filename); |
&Apache::lonnet::subscribe($filename); |
&Apache::lonnet::repcopy($filename); |
&Apache::lonnet::repcopy($filename); |
} |
} |
|
if (! -e $filename ) { return -1; }; |
my $fh=Apache::File->new($filename); |
my $fh=Apache::File->new($filename); |
while (<$fh>) { |
while (<$fh>) { |
$a .=$_; |
$a .=$_; |