Diff for /loncom/publisher/londiff.pm between versions 1.11 and 1.15

version 1.11, 2003/02/03 18:03:53 version 1.15, 2004/03/11 22:44:01
Line 54  use Apache::Constants qw(:common :http : Line 54  use Apache::Constants qw(:common :http :
 use Apache::loncacc;  use Apache::loncacc;
 use Apache::lonnet();  use Apache::lonnet();
 use Apache::loncommon();  use Apache::loncommon();
   use Apache::lonlocal;
   
   
   sub get_split_file {
       my ($fn,$style)=@_;
       my $f1;
       my @f1;
       if ($style='local') {
    if (-e $fn) {
       my $fh=Apache::File->new($fn);
       my $line;
       while($line=<$fh>) {
    $f1.=$line;
       }
    }
       } elsif ($style eq 'remote') {
    my $f1=&Apache::lonnet::getfile($fn);
       }
       if ($f1=~/\r/) {
    @f1=split(/\r/,&Apache::lonnet::getfile($fn));      
    foreach my $line (@f1) {
       $line=~s/\n//g;
    }
       } else {
    @f1=split(/\n/,&Apache::lonnet::getfile($fn));      
       }
       return @f1;
   }
   
 sub handler {  sub handler {
   
Line 90  sub handler { Line 118  sub handler {
   my @f1=();    my @f1=();
   my @f2=();    my @f2=();
   
   $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 Diffs</title></head>');    $r->print('<html><head><title>LON-CAPA Construction Diffs</title></head>');
Line 98  sub handler { Line 126  sub handler {
   $r->print(&Apache::loncommon::bodytag('Resource Differences'));    $r->print(&Apache::loncommon::bodytag('Resource Differences'));
   
       
   $r->print('<h1>Compare versions of <tt>'.$efn.'</tt></h1>');    $r->print('<h1>'.&mt('Compare versions of').' <tt>'.$efn.'</tt></h1>');
         
        if (($cuname ne $ENV{'user.name'}) || ($cudom ne $ENV{'user.domain'})) {         if (($cuname ne $ENV{'user.name'}) || ($cudom ne $ENV{'user.domain'})) {
           $r->print('<h3><font color=red>Co-Author: '.$cuname.' at '.$cudom.            $r->print('<h3><font color=red>Co-Author: '.$cuname.' at '.$cudom.
Line 111  sub handler { Line 139  sub handler {
   $r->print('<p><font color="red">');    $r->print('<p><font color="red">');
   if ($ENV{'form.versionone'} eq 'priv') {    if ($ENV{'form.versionone'} eq 'priv') {
       my $fn='/home/'.$cuname.'/public_html/'.$efn;        my $fn='/home/'.$cuname.'/public_html/'.$efn;
       if (-e $fn) {        @f1=&get_split_file($fn,'local');
   my $fh=Apache::File->new($fn);        $r->print('<b>'.&mt('Construction Space Version').'</b>');
           my $line;  
           while($line=<$fh>) {  
              chomp($line);  
              $f1[$#f1+1]=$line;  
  }  
       }  
       $r->print('<b>Construction Space Version</b>');  
   } else {    } else {
       my $fn=        my $fn=
        '/home/httpd/html//res/'.$cudom.'/'.$cuname.'/';         '/home/httpd/html//res/'.$cudom.'/'.$cuname.'/';
       if ($ENV{'form.versionone'}) {        if ($ENV{'form.versionone'}) {
          my ($main,$suffix)=($efn=~/^(.+)\.(\w+)$/);           my ($main,$suffix)=($efn=~/^(.+)\.(\w+)$/);
          $fn.=$main.'.'.$ENV{'form.versionone'}.'.'.$suffix;           $fn.=$main.'.'.$ENV{'form.versionone'}.'.'.$suffix;
  $r->print('<b>Version '.$ENV{'form.versionone'}.'</b>');   $r->print('<b>'.&mt('Version').' '.$ENV{'form.versionone'}.'</b>');
       } else {        } else {
          $fn.=$efn;           $fn.=$efn;
  $r->print('<b>Current Version</b>');   $r->print('<b>'.&mt('Current Version').'</b>');
       }        }
       @f1=split(/\n/,&Apache::lonnet::getfile($fn));              @f1=&get_split_file($fn,'remote');
   }    }
   
   $r->print('</font><br />versus<br /><font color="green">');    $r->print('</font><br />'.&mt('versus').'<br /><font color="green">');
   
   if ($ENV{'form.versiontwo'} eq 'priv') {    if ($ENV{'form.versiontwo'} eq 'priv') {
       my $fn='/home/'.$cuname.'/public_html/'.$efn;        my $fn='/home/'.$cuname.'/public_html/'.$efn;
       if (-e $fn) {        @f2=&get_split_file($fn,'local');
   my $fh=Apache::File->new($fn);        $r->print('<b>'.&mt('Construction Space Version').'</b>');
           my $line;  
           while($line=<$fh>) {  
              chomp($line);  
              $f2[$#f2+1]=$line;  
  }  
       }  
       $r->print('<b>Construction Space Version</b>');  
   } else {    } else {
       my $fn=        my $fn=
        '/home/httpd/html/res/'.$cudom.'/'.$cuname.'/';         '/home/httpd/html/res/'.$cudom.'/'.$cuname.'/';
       if ($ENV{'form.versiontwo'}) {        if ($ENV{'form.versiontwo'}) {
          my ($main,$suffix)=($efn=~/^(.+)\.(\w+)$/);           my ($main,$suffix)=($efn=~/^(.+)\.(\w+)$/);
          $fn.=$main.'.'.$ENV{'form.versiontwo'}.'.'.$suffix;           $fn.=$main.'.'.$ENV{'form.versiontwo'}.'.'.$suffix;
  $r->print('<b>Version '.$ENV{'form.versiontwo'}.'</b>');   $r->print('<b>'.&mt('Version').' '.$ENV{'form.versiontwo'}.'</b>');
       } else {        } else {
          $fn.=$efn;           $fn.=$efn;
  $r->print('<b>Current Version</b>');   $r->print('<b>'.&mt('Current Version').'</b>');
       }        }
       @f2=split(/\n/,&Apache::lonnet::getfile($fn));              @f2=&get_split_file($fn,'remote');
   }    }
   $r->print('</font></p>');    $r->print('</font></p>');
 # Run diff  # Run diff
Line 187  sub handler { Line 201  sub handler {
   $r->print('</pre>');    $r->print('</pre>');
   
 } else {  } else {
     $r->print('<h1><font color=red>Binary File</font></h1>');      $r->print('<h1><font color=red>'.&mt('Binary File').'</font></h1>');
 }  }
   $r->print('</body></html>');    $r->print('<center><a href="javascript:window.close();">'.&mt('Close This Window').'</a></center></body></html>'); 
   return OK;      return OK;  
 }  }
   

Removed from v.1.11  
changed lines
  Added in v.1.15


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