Diff for /loncom/publisher/lonretrieve.pm between versions 1.22 and 1.23

version 1.22, 2003/05/19 21:53:03 version 1.23, 2003/09/22 15:39:53
Line 50  use File::Copy; Line 50  use File::Copy;
 use Apache::Constants qw(:common :http :methods);  use Apache::Constants qw(:common :http :methods);
 use Apache::loncacc;  use Apache::loncacc;
 use Apache::loncommon();  use Apache::loncommon();
   use Apache::lonlocal;
   
 # ------------------------------------ Interface for selecting previous version  # ------------------------------------ Interface for selecting previous version
 sub phaseone {  sub phaseone {
Line 71  sub phaseone { Line 72  sub phaseone {
     $r->print('<form action=/adm/retrieve method=post>'.      $r->print('<form action=/adm/retrieve method=post>'.
       '<input type=hidden name=filename value="/~'.$uname.$fn.'">'.        '<input type=hidden name=filename value="/~'.$uname.$fn.'">'.
               '<input type=hidden name=phase value=two>'.                '<input type=hidden name=phase value=two>'.
               '<table border=2><tr><th>Select</th><th>Version</th>'.                '<table border=2><tr><th>'.&mt('Select').'</th><th>'.
               '<th>Became this version on ...</th>'.        &mt('Version').'</th>'.
               '<th>Metadata</th></tr>');                '<th>'.&mt('Became this version on ...').'</th>'.
                 '<th>'.&mt('Metadata').'</th></tr>');
     my $filename;      my $filename;
     opendir(DIR,$resdir);      opendir(DIR,$resdir);
     while ($filename=readdir(DIR)) {      while ($filename=readdir(DIR)) {
Line 87  sub phaseone { Line 89  sub phaseone {
                      $version.'"></td><th>'.$version.'</th><td>'.                       $version.'"></td><th>'.$version.'</th><td>'.
                      localtime($rmtime).'</td><td>'.                       localtime($rmtime).'</td><td>'.
                      '<a href="'.$urldir.$filename.'.meta" target=cat>'.                       '<a href="'.$urldir.$filename.'.meta" target=cat>'.
                      'Metadata Version '.$version.'</a>');                       &mt('Metadata Version').' '.$version.'</a>');
            if (&Apache::loncommon::fileembstyle($suffix) eq 'ssi') {             if (&Apache::loncommon::fileembstyle($suffix) eq 'ssi') {
                $r->print(                 $r->print(
                     '&nbsp;&nbsp;<a target=cat href="/adm/diff?filename=/~'.                      '&nbsp;&nbsp;<a target=cat href="/adm/diff?filename=/~'.
                         $uname.$fn.                          $uname.$fn.
                         '&versiontwo=priv&versiontwo='.$version.                          '&versiontwo=priv&versiontwo='.$version.
                         '">Diffs with Version '.$version.'</a>');                          '">'.&mt('Diffs with Version').' '.$version.'</a>');
            }             }
            $r->print('</a></td></tr>');             $r->print('</a></td></tr>');
         }          }
Line 104  sub phaseone { Line 106  sub phaseone {
         $ratime,$rmtime,$rctime,          $ratime,$rmtime,$rctime,
         $rblksize,$rblocks)=stat($resfn);          $rblksize,$rblocks)=stat($resfn);
     $r->print('<tr><td><input type=radio name=version value="new"></td>'.      $r->print('<tr><td><input type=radio name=version value="new"></td>'.
               '<th>Current</th><td>'.localtime($rmtime).                '<th>'.&mt('Current').'</th><td>'.localtime($rmtime).
            '</td><td><a href="'.$urldir.$main.'.'.$suffix.'.meta" target=cat>'.             '</td><td><a href="'.$urldir.$main.'.'.$suffix.'.meta" target=cat>'.
               'Metadata current version</a>');                           &mt('Metadata current version').'</a>');           
            if (&Apache::loncommon::fileembstyle($suffix) eq 'ssi') {             if (&Apache::loncommon::fileembstyle($suffix) eq 'ssi') {
                $r->print(                 $r->print(
                     '&nbsp;&nbsp;<a target=cat href="/adm/diff?filename=/~'.                      '&nbsp;&nbsp;<a target=cat href="/adm/diff?filename=/~'.
                         $uname.$fn.                          $uname.$fn.
                         '&versiontwo=priv'.                          '&versiontwo=priv'.
                         '">Diffs with current Version</a>');                          '">'.&mt('Diffs with current Version').'</a>');
            }             }
            $r->print('</td></tr></table><p>'.             $r->print('</td></tr></table><p>'.
            '<font size=+1 color=red>Retrieval of an old version will '.             '<font size=+1 color=red>'.
            'overwrite the file currently in construction space</font><p>'.  &mt('Retrieval of an old version will overwrite the file currently in construction space').'</font><p>'.
            '<input type=submit value="Retrieve version"></form>');             '<input type=submit value="'.&mt('Retrieve version').'"></form>');
 } else {  } else {
     $r->print('<h3>No previous versions published.</h3>');      $r->print('<h3>'.&mt('No previous versions published.').'</h3>');
 }  }
 }  }
   
Line 129  sub phasetwo { Line 131  sub phasetwo {
     if ($ENV{'form.version'}) {      if ($ENV{'form.version'}) {
         my $version=$ENV{'form.version'};          my $version=$ENV{'form.version'};
  if ($version eq 'new') {   if ($version eq 'new') {
     $r->print('<h3>Retrieving current (most recent) version</h3>');      $r->print('<h3>'.&mt('Retrieving current (most recent) version').'</h3>');
         } else {          } else {
             $r->print('<h3>Retrieving old version '.$version.'</h3>');              $r->print('<h3>'.&mt('Retrieving old version').' '.$version.'</h3>');
         }          }
         my $logfile;          my $logfile;
         my $ctarget='/home/'.$uname.'/public_html'.$fn;          my $ctarget='/home/'.$uname.'/public_html'.$fn;
Line 142  sub phasetwo { Line 144  sub phasetwo {
         my $csource=$r->dir_config('lonDocRoot').'/res/'.$udom.'/'.$uname.$vfn;          my $csource=$r->dir_config('lonDocRoot').'/res/'.$udom.'/'.$uname.$vfn;
         unless ($logfile=Apache::File->new('>>'.$ctarget.'.log')) {          unless ($logfile=Apache::File->new('>>'.$ctarget.'.log')) {
   $r->print(    $r->print(
          '<font color=red>No write permission to user directory, FAIL</font>');           '<font color=red>'.&mt('No write permission to user directory, FAIL').'</font>');
         }          }
         print $logfile           print $logfile 
 "\n\n================= Retrieve ".localtime()." ================\n".  "\n\n================= Retrieve ".localtime()." ================\n".
 "Version: $version\nSource: $csource\nTarget: $ctarget\n";  "Version: $version\nSource: $csource\nTarget: $ctarget\n";
         $r->print('<p>Copying file: ');          $r->print('<p>'.&mt('Copying file').': ');
         if (copy($csource,$ctarget)) {          if (copy($csource,$ctarget)) {
     $r->print('ok<p>');      $r->print('ok<p>');
             print $logfile "Copied sucessfully.\n\n";              print $logfile "Copied sucessfully.\n\n";
Line 157  sub phasetwo { Line 159  sub phasetwo {
             print $logfile "Copy failed: $error\n\n";              print $logfile "Copy failed: $error\n\n";
         }          }
         $r->print('<font size=+2><a href="/priv/'.$uname.$fn.          $r->print('<font size=+2><a href="/priv/'.$uname.$fn.
                   '">Back to '.$fn.'</a></font>');                     '">'.&mt('Back to').' '.$fn.'</a></font>'); 
     } else {      } else {
        $r->print(         $r->print(
    '<font size=+1 color=red>Please pick a version to retrieve</font><p>');     '<font size=+1 color=red>'.&mt('Please pick a version to retrieve').'</font><p>');
        &phaseone($r,$fn,$uname,$udom);         &phaseone($r,$fn,$uname,$udom);
     }      }
 }  }
Line 209  sub handler { Line 211  sub handler {
   
   $fn=~s/\/\~(\w+)//;    $fn=~s/\/\~(\w+)//;
   
   $r->content_type('text/html');    &Apache::loncommon::content_type($r,'text/html');
   $r->send_http_header;    $r->send_http_header;
   
   $r->print('<html><head><title>LON-CAPA Construction Space</title></head>');    $r->print('<html><head><title>LON-CAPA Construction Space</title></head>');
Line 217  sub handler { Line 219  sub handler {
   $r->print(&Apache::loncommon::bodytag('Retrieve Published Resources'));    $r->print(&Apache::loncommon::bodytag('Retrieve Published Resources'));
   
       
   $r->print('<h1>Retrieve previous versions of <tt>'.$fn.'</tt></h1>');    $r->print('<h1>'.&mt('Retrieve previous versions of').' <tt>'.$fn.'</tt></h1>');
       
   if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {    if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {
           $r->print('<h3><font color=red>Co-Author: '.$uname.' at '.$udom.            $r->print('<h3><font color=red>'.&mt('Co-Author').': '.$uname.
       &mt(' at ').$udom.
                '</font></h3>');                 '</font></h3>');
   }    }
   

Removed from v.1.22  
changed lines
  Added in v.1.23


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>