Select | Version | '.
- 'Became this version on ... | '.
- 'Metadata |
');
+ ''.&mt('Select').' | '.
+ &mt('Version').' | '.
+ ''.&mt('Became this version on ...').' | '.
+ ''.&mt('Metadata').' |
');
my $filename;
opendir(DIR,$resdir);
while ($filename=readdir(DIR)) {
- if ($filename=~/^$main\.(\d+)\.$suffix$/) {
+ if ($filename=~/^\Q$main\E\.(\d+)\.\Q$suffix\E$/) {
my $version=$1;
my ($rdev,$rino,$rmode,$rnlink,
$ruid,$rgid,$rrdev,$rsize,
@@ -81,13 +89,13 @@ sub phaseone {
$version.'">'.$version.' | '.
localtime($rmtime).' | '.
''.
- 'Metadata Version '.$version.'');
- if (&Apache::lonnet::fileembstyle($suffix) eq 'ssi') {
+ &mt('Metadata Version').' '.$version.'');
+ if (&Apache::loncommon::fileembstyle($suffix) eq 'ssi') {
$r->print(
' Diffs with Version '.$version.'');
+ '&versiontwo=priv&versionone='.$version.
+ '">'.&mt('Diffs with Version').' '.$version.'');
}
$r->print(' | ');
}
@@ -98,33 +106,34 @@ sub phaseone {
$ratime,$rmtime,$rctime,
$rblksize,$rblocks)=stat($resfn);
$r->print(' | '.
- 'Current | '.localtime($rmtime).
+ ' | '.&mt('Current').' | '.localtime($rmtime).
' | '.
- 'Metadata current version');
- if (&Apache::lonnet::fileembstyle($suffix) eq 'ssi') {
+ &mt('Metadata current version').'');
+ if (&Apache::loncommon::fileembstyle($suffix) eq 'ssi') {
$r->print(
' Diffs with current Version');
+ '&versiontwo=priv'.
+ '">'.&mt('Diffs with current Version').'');
}
$r->print(' |
---|
'.
- 'Retrieval of an old version will '.
- 'overwrite the file currently in construction space
'.
- '');
+ ''.
+&mt('Retrieval of an old version will overwrite the file currently in construction space').'
'.
+ '');
} else {
- $r->print('
No previous versions published.
');
+ $r->print(''.&mt('No previous versions published.').'
');
}
}
+# ---------------------------------- Interface for presenting specified version
sub phasetwo {
my ($r,$fn,$uname,$udom)=@_;
if ($ENV{'form.version'}) {
my $version=$ENV{'form.version'};
if ($version eq 'new') {
- $r->print('Retrieving current (most recent) version
');
+ $r->print(''.&mt('Retrieving current (most recent) version').'
');
} else {
- $r->print('Retrieving old version '.$version.'
');
+ $r->print(''.&mt('Retrieving old version').' '.$version.'
');
}
my $logfile;
my $ctarget='/home/'.$uname.'/public_html'.$fn;
@@ -135,12 +144,12 @@ sub phasetwo {
my $csource=$r->dir_config('lonDocRoot').'/res/'.$udom.'/'.$uname.$vfn;
unless ($logfile=Apache::File->new('>>'.$ctarget.'.log')) {
$r->print(
- 'No write permission to user directory, FAIL');
+ ''.&mt('No write permission to user directory, FAIL').'');
}
print $logfile
"\n\n================= Retrieve ".localtime()." ================\n".
"Version: $version\nSource: $csource\nTarget: $ctarget\n";
- $r->print('Copying file: ');
+ $r->print('
'.&mt('Copying file').': ');
if (copy($csource,$ctarget)) {
$r->print('ok
');
print $logfile "Copied sucessfully.\n\n";
@@ -150,14 +159,15 @@ sub phasetwo {
print $logfile "Copy failed: $error\n\n";
}
$r->print('Back to '.$fn.'');
+ '">'.&mt('Back to').' '.$fn.'');
} else {
$r->print(
- 'Please pick a version to retrieve
');
+ ''.&mt('Please pick a version to retrieve').'
');
&phaseone($r,$fn,$uname,$udom);
}
}
+# ---------------------------------------------------------------- Main Handler
sub handler {
my $r=shift;
@@ -167,17 +177,8 @@ sub handler {
# Get query string for limited number of parameters
- map {
- my ($name, $value) = split(/=/,$_);
- $value =~ tr/+/ /;
- $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
- if ($name eq 'filename') {
- unless ($ENV{'form.'.$name}) {
- $ENV{'form.'.$name}=$value;
- }
- }
- } (split(/&/,$ENV{'QUERY_STRING'}));
-
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['filename']);
if ($ENV{'form.filename'}) {
$fn=$ENV{'form.filename'};
@@ -210,19 +211,19 @@ sub handler {
$fn=~s/\/\~(\w+)//;
- $r->content_type('text/html');
+ &Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
$r->print('
LON-CAPA Construction Space');
- $r->print(
- '');
+ $r->print(&Apache::loncommon::bodytag('Retrieve Published Resources'));
- $r->print('Retrieve previous versions of '.$fn.'
');
+ $r->print(''.&mt('Retrieve previous versions of').' '.$fn.'
');
if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {
- $r->print('Co-Author: '.$uname.' at '.$udom.
+ $r->print(''.&mt('Co-Author').': '.$uname.
+ &mt(' at ').$udom.
'
');
}
@@ -239,3 +240,68 @@ sub handler {
1;
__END__
+
+=head1 NAME
+
+Apache::lonretrieve - retrieves an old version of a file
+
+=head1 SYNOPSIS
+
+Invoked by /etc/httpd/conf/srm.conf:
+
+
+ PerlAccessHandler Apache::lonacc
+ SetHandler perl-script
+ PerlHandler Apache::lonretrieve
+ ErrorDocument 403 /adm/login
+ ErrorDocument 404 /adm/notfound.html
+ ErrorDocument 406 /adm/unauthorized.html
+ ErrorDocument 500 /adm/errorhandler
+
+
+=head1 INTRODUCTION
+
+This module retrieves an old published version of a file.
+
+This is part of the LearningOnline Network with CAPA project
+described at http://www.lon-capa.org.
+
+=head1 HANDLER SUBROUTINE
+
+This routine is called by Apache and mod_perl.
+
+=over 4
+
+=item *
+
+Get query string for limited number of parameters
+
+=item *
+
+Start page output
+
+=item *
+
+print phase relevant output
+
+=item *
+
+(phase one is to select version; phase two retrieves version)
+
+=back
+
+=head1 OTHER SUBROUTINES
+
+=over 4
+
+=item *
+
+phaseone() : Interface for selecting previous version.
+
+=item *
+
+phasetwo() : Interface for presenting specified version.
+
+=back
+
+=cut