version 1.1, 2004/06/12 01:08:11
|
version 1.3, 2004/06/18 15:13:07
|
Line 1
|
Line 1
|
# The LearningOnline Network with CAPA |
# The LearningOnline Network with CAPA |
# Publication Handler |
# Souce Code handler |
# |
# |
# $Id$ |
# $Id$ |
# |
# |
Line 42 use Apache::lonlocal;
|
Line 42 use Apache::lonlocal;
|
use HTML::Entities; |
use HTML::Entities; |
|
|
sub make_link { |
sub make_link { |
my ($filename) = @_; |
my ($filename) = @_; |
my $sourcelink = "http://".$ENV{'SERVER_NAME'}."/adm/source/?filename=".$filename; |
my $sourcelink = "http://".$ENV{'SERVER_NAME'}. |
|
"/adm/source/?filename=".$filename; |
|
|
return $sourcelink; |
return $sourcelink; |
|
|
} |
} |
|
|
sub stage_2 { |
sub stage_2 { |
my ($r, $filename) = @_; |
my ($r, $filename) = @_; |
$r->print("Comming Soon"); |
$r->print("Coming Soon"); |
return OK; |
return OK; |
} |
} |
|
|
sub print_item { |
sub print_item { |
my ($r, $filename) = @_; |
my ($r, $filename) = @_; |
$filename = "/home/httpd/html".$filename; |
$filename = "/home/httpd/html".$filename; |
my $file_output = &Apache::lonnet::getfile($filename); |
my $file_output = &Apache::lonnet::getfile($filename); |
my ($rows,$cols) = &Apache::edit::textarea_sizes(\$file_output); |
my ($rows,$cols) = &Apache::edit::textarea_sizes(\$file_output); |
$r->print('<textarea rows="'.$rows.'" cols="'.$cols.'" name="editxmltext">'. |
$r->print('<textarea rows="'.$rows.'" cols="'.$cols.'" name="editxmltext">'. |
&HTML::Entities::encode($file_output,'<>&"').'</textarea>'); |
&HTML::Entities::encode($file_output,'<>&"').'</textarea>'); |
|
return OK; |
return OK; |
|
|
|
} |
} |
|
|
|
|
sub handler { |
sub handler { |
my $r=shift; |
my $r=shift; |
if($ENV{'form.action'} eq 'stage2') { |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
&stage_2($r, $ENV{'form.filename'}); |
['filename']); |
} else { |
my $filename = $ENV{'form.filename'}; |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
my $source = &Apache::lonnet::metadata($filename,'sourceavail'); |
['filename']); |
if ($source ne 'open') { |
return FORBIDDEN if !&Apache::lonnet::allowed('cre',$ENV{'form.filename'}) |
$ENV{'user.error.msg'}="$filename:cre:1:1:Source code not available"; |
|
return HTTP_NOT_ACCEPTABLE; |
|
} |
|
if ((!&Apache::lonnet::allowed('cre')) || |
|
(!&Apache::lonnet::allowed('bre',$filename))) { |
|
$ENV{'user.error.msg'}="$filename:bre:1:1:Access to resource denied"; |
|
return HTTP_NOT_ACCEPTABLE; |
|
} |
|
if ($ENV{'form.action'} eq 'stage2') { |
|
&stage_2($r, $ENV{'form.filename'}); |
|
} else { |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
my $filename = $ENV{'form.filename'}; |
|
$r->send_http_header; |
$r->send_http_header; |
$r->print(' <form name="copy" action="/adm/source/" target="_parent" method="post"> |
$r->print(' <form name="copy" action="/adm/source/" target="_parent" method="post"> |
<input type="button" value="Close Window" name="close" onClick="window.close()"> |
<input type="button" value="Close Window" name="close" onClick="window.close()"> |
Line 88 sub handler {
|
Line 95 sub handler {
|
</form>'); |
</form>'); |
$r->print('<hr />'); |
$r->print('<hr />'); |
&print_item($r, $ENV{'form.filename'}); |
&print_item($r, $ENV{'form.filename'}); |
} |
} |
return OK; |
return OK; |
|
|
} |
} |
|
|
|
|
1; |
1; |
|
|
|
|
|
|
|
|