version 1.14, 2005/06/23 23:51:32
|
version 1.18, 2007/07/11 20:32:15
|
Line 40 use Apache::lonmeta;
|
Line 40 use Apache::lonmeta;
|
use Apache::File; |
use Apache::File; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use HTML::Entities; |
use HTML::Entities; |
|
use LONCAPA; |
|
|
sub make_link { |
sub make_link { |
my ($filename, $listname) = @_; |
my ($filename, $listname) = @_; |
my $sourcelink = "/adm/source?filename=".$filename."&listname=".$listname; |
my $sourcelink = "/adm/source?inhibitmenu=yes&filename=".$filename."&listname=".$listname; |
|
|
return $sourcelink; |
return $sourcelink; |
} |
} |
Line 54 sub stage_2 {
|
Line 55 sub stage_2 {
|
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
my ($uname, $udom) = &Apache::loncacc::constructaccess('/~'.$author.'/',$r->dir_config('lonDefDomain')); |
my ($uname, $udom) = &Apache::loncacc::constructaccess('/~'.$author.'/',$r->dir_config('lonDefDomain')); |
$r->send_http_header; |
$r->send_http_header; |
my $html=&Apache::lonxml::xmlbegin(); |
$r->print(&Apache::loncommon::start_page('Problem source code moving operation')); |
$r->print($html.'<head><title>LON-CAPA Move source to construction space</title>'); |
|
$r->print(&Apache::loncommon::bodytag('Problem source code moving operation')); |
|
$r->print("Please enter the directory that you would like the source code to go into, a default has also been provided <br />"); |
$r->print("Please enter the directory that you would like the source code to go into, a default has also been provided <br />"); |
$r->print("Also note, the path is in reference to the root of your construction space, and new directories will be automatically created. <br /><br />"); |
$r->print("Also note, the path is in reference to the root of your construction space, and new directories will be automatically created. <br /><br />"); |
$r->print('<form name="copy" action="/adm/source" target="_parent" method="post"> |
$r->print('<form name="copy" action="/adm/source" target="_parent" method="post"> |
Line 94 sub copy_stage {
|
Line 93 sub copy_stage {
|
} |
} |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
my $html=&Apache::lonxml::xmlbegin(); |
$r->print(&Apache::loncommon::start_page('Copying Source')); |
$r->print($html.'<head><title>LON-CAPA Move source to construction space</title>'); |
|
$r->print(&Apache::loncommon::bodytag('Copying Source')); |
|
my $result = &Apache::loncfile::exists($uname, $udom, $path_to_new_file); |
my $result = &Apache::loncfile::exists($uname, $udom, $path_to_new_file); |
$r->print($result); |
$r->print($result); |
if(($result) && ($result =~ m|published|) ) { |
if(($result) && ($result =~ m|published|) ) { |
Line 170 sub copy_file {
|
Line 167 sub copy_file {
|
} |
} |
$r->print("<br /><b>Copying File</b>"); |
$r->print("<br /><b>Copying File</b>"); |
my $problem_filename = $Apache::lonnet::perlvar{'lonDocRoot'}.$filename; |
my $problem_filename = $Apache::lonnet::perlvar{'lonDocRoot'}.$filename; |
my $file_output = &Apache::lonnet::getfile($problem_filename); |
my $file_output = &includemeta(&Apache::lonnet::getfile($problem_filename),$filename); |
my $fs=Apache::File->new(">$path_to_new_file"); |
my $fs=Apache::File->new(">$path_to_new_file"); |
if (defined($fs)) { |
if (defined($fs)) { |
print $fs $file_output; |
print $fs $file_output; |
Line 182 sub copy_file {
|
Line 179 sub copy_file {
|
|
|
sub print_item { |
sub print_item { |
my ($r, $filename) = @_; |
my ($r, $filename) = @_; |
$filename = $Apache::lonnet::perlvar{'lonDocRoot'}.$filename; |
my $file_output = &includemeta(&Apache::lonnet::getfile($Apache::lonnet::perlvar{'lonDocRoot'}.$filename),$filename); |
&Apache::lonnet::logthis("print_item filename = $filename"); |
|
my $file_output = &Apache::lonnet::getfile($filename); |
|
my $count=0; |
my $count=0; |
my $maxlength=-1; |
my $maxlength=-1; |
foreach (split ("\n", $file_output)) { |
foreach (split ("\n", $file_output)) { |
Line 202 sub print_item {
|
Line 197 sub print_item {
|
|
|
} |
} |
|
|
|
sub includemeta { |
|
my ($file_output,$orgfilename)=@_; |
|
my $escfilename=&escape($orgfilename); |
|
my $copytime=time; |
|
if ($file_output=~/\<meta\s*name\=\"isbasedonres\"/i) { |
|
$file_output=~s/(\<meta\s*name\=\"isbasedonres\"\s*content\=\"[^\"]*)\"/$1\,\Q$escfilename\E\"/i; |
|
} else { |
|
$file_output=~s/(\<(?:html|problem)[^\>]*\>)/$1\n\<meta name=\"isbasedonres\" content=\"\Q$escfilename\E\" \/\>/i; |
|
} |
|
if ($file_output=~/\<meta\s*name\=\"isbasedontime\"/i) { |
|
$file_output=~s/(\<meta\s*name\=\"isbasedontime\"\s*content\=\"[^\"]*)\"/$1\,\Q$copytime\E\"/i; |
|
} else { |
|
$file_output=~s/(\<(?:html|problem)[^\>]*\>)/$1\n\<meta name=\"isbasedontime\" content=\"\Q$copytime\E\" \/\>/i; |
|
} |
|
return $file_output; |
|
} |
|
|
sub handler { |
sub handler { |
my $r=shift; |
my $r=shift; |
Line 214 sub handler {
|
Line 225 sub handler {
|
$env{'user.error.msg'}="$filename:cre:1:1:Source code not available"; |
$env{'user.error.msg'}="$filename:cre:1:1:Source code not available"; |
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
} |
} |
unless (&Apache::lonnet::allowed('bre',$filename)) { |
unless ((&Apache::lonnet::allowed('bre',$filename)) && |
|
(&Apache::lonnet::allowed('cre','/'))) { |
$env{'user.error.msg'}="$filename:bre:1:1:Access to resource denied"; |
$env{'user.error.msg'}="$filename:bre:1:1:Access to resource denied"; |
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
} |
} |