[LON-CAPA-cvs] cvs: loncom /publisher loncfile.pm lonconstruct.pm lonpubdir.pm

taceyjo1 lon-capa-cvs@mail.lon-capa.org
Wed, 19 Nov 2003 14:57:32 -0000


taceyjo1		Wed Nov 19 09:57:32 2003 EDT

  Modified files:              
    /loncom/publisher	loncfile.pm lonconstruct.pm lonpubdir.pm 
  Log:
  loncfile includes the new decompression system integrated, a lot better than the old way lonconstruct and lonpubdir just support
  
  
Index: loncom/publisher/loncfile.pm
diff -u loncom/publisher/loncfile.pm:1.43 loncom/publisher/loncfile.pm:1.44
--- loncom/publisher/loncfile.pm:1.43	Sat Nov  8 05:48:33 2003
+++ loncom/publisher/loncfile.pm	Wed Nov 19 09:57:32 2003
@@ -9,7 +9,7 @@
 #  and displays a page showing the results of the action.
 #
 #
-# $Id: loncfile.pm,v 1.43 2003/11/08 10:48:33 albertel Exp $
+# $Id: loncfile.pm,v 1.44 2003/11/19 14:57:32 taceyjo1 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -73,7 +73,7 @@
 use Apache::lonnet;
 use Apache::loncommon();
 
-my $DEBUG=0;
+my $DEBUG=2;
 my $r;				# Needs to be global for some stuff RF.
 
 =pod
@@ -110,12 +110,31 @@
   # Put out the indicated message butonly if DEBUG is true.
   
   if ($DEBUG) {
-    $log->debug($message);
+   $r->log_reason($message);
   }
 }
 
 =pod
 
+=item checksuffix($old, $new)
+        
+  Determine if a resource filename suffix (the stuff after the .) would change
+as a result of this operation.
+
+ Parameters:
+
+=over 4
+
+=item  $old   = string [in]  Previous filename.
+
+=item  $new   = string [in]  Resultant filename.
+
+=back
+
+=cut
+
+=pod
+
 =item URLToPath($url)
 
   Convert a URL to a file system path.
@@ -579,6 +598,17 @@
   }
 }
 
+
+sub Decompress1 {
+   my ($request, $user, $domain, $fn) = @_;
+   if( -e $fn) {
+   	$request->print('<input type="hidden" name="newfilename" value="'.$fn.'"/>');
+   	$request->print('<p>Decompress '.&display($fn).'?</p>');
+   	&CloseForm1($request, $fn);
+   	} else {
+       		$request->print('<p>No such file: '.&display($fn).'</p></form>');
+     	  }
+}
 =pod
 
 =item NewFile1
@@ -687,7 +717,7 @@
   
   my $newfilename=&cleanDest($r,$ENV{'form.newfilename'});
   $newfilename=&relativeDest($fn,$newfilename,$uname);
-
+	&Debug($r, "Newfile: $newfilename");
   $r->print('<form action="/adm/cfile" method="post">'.
       '<input type="hidden" name="qualifiedfilename" value="'.$fn.'" />'.
       '<input type="hidden" name="phase" value="two" />'.
@@ -697,6 +727,9 @@
       &Rename1($r, $uname, $udom, $fn, $newfilename);
   } elsif ($ENV{'form.action'} eq 'delete') { 
       &Delete1($r, $uname, $udom, $fn);
+  } elsif ($ENV{'form.action'} eq 'decompress') {
+	&Apache::lonnet::appenv('cgi.path' => $newfilename); 
+      &Decompress1($r, $uname, $udom, $fn);
   } elsif ($ENV{'form.action'} eq 'copy') { 
       if($newfilename) {
 	  &Copy1($r, $uname, $udom, $fn, $newfilename);
@@ -935,7 +968,16 @@
   }
   return 1;
 }
-
+sub decompress2 {
+	my ($r, $user, $dir, $file) = @_;
+	&Apache::lonnet::appenv('cgi.file' => $file);
+	&Apache::lonnet::appenv('cgi.dir' => $dir);
+	my $result=&Apache::lonnet::ssi_body('/cgi-bin/decompress.pl');
+	$r->print($result);
+	&Apache::lonnet::delenv('cgi.file');
+	&Apache::lonnet::delenv('cgi.dir');
+	return 1;
+}
 =pod
 
 =item phasetwo($r, $fn, $uname, $udom)
@@ -1001,8 +1043,16 @@
 	   "loncfie::phase2 action is $ENV{'form.action'}");
     
     # Select the appropriate processing sub.
-    
-    if ($ENV{'form.action'} eq 'rename') { # Rename.
+    if ($ENV{'form.action'} eq 'decompress') { 
+	$main .= '.';
+	$main .= $suffix;
+	    if(!&decompress2($r, $uname, $dir, $main)) {
+		return ;
+		}
+	    $dest = $dir."/.";
+     
+	
+    } elsif ($ENV{'form.action'} eq 'rename') { # Rename.
 	if($ENV{'form.newfilename'}) {
 	    if (!defined($dir)) {
 		$fn=~m:^(.*)/:;
@@ -1024,7 +1074,7 @@
     } elsif ($ENV{'form.action'} eq 'copy') { 
 	if($ENV{'form.newfilename'}) {
 	    if(!&Copy2($r, $uname, $dir, $fn, $ENV{'form.newfilename'})) {
-		return
+		return ;
 		}
 	    $dest = $ENV{'form.newfilename'};
      
@@ -1059,9 +1109,19 @@
   my $fn;
 
   if ($ENV{'form.filename'}) {
+	
+	&Debug($r, "test: $ENV{'form.filename'}");
       $fn=&Apache::lonnet::unescape($ENV{'form.filename'});
       $fn=&URLToPath($fn);
-  } elsif ($ENV{'form.qualifiedfilename'}) {
+  }  
+    elsif($ENV{'QUERY_STRING'} && $ENV{'form.phase'} ne 'two') {
+	  &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['decompress']);
+	 $fn=&Apache::lonnet::unescape($ENV{'form.decompress'});
+	$fn=&URLToPath($fn);
+	$ENV{'form.action'}="decompress";
+  }
+
+    elsif ($ENV{'form.qualifiedfilename'}) {
       $fn=$ENV{'form.qualifiedfilename'};
   } else {
       &Debug($r, "loncfile::handler - no form.filename");
@@ -1118,6 +1178,8 @@
       $r->print('<h3>Rename</h3>');
   } elsif ($ENV{'form.action'} eq 'newdir') {
       $r->print('<h3>New Directory</h3>');
+  } elsif ($ENV{'form.action'} eq 'decompress') {
+      $r->print('<h3>Decompress</h3>');
   } elsif ($ENV{'form.action'} eq 'copy') {
       $r->print('<h3>Copy</h3>');
   } elsif ($ENV{'form.action'} eq 'newfile' ||
Index: loncom/publisher/lonconstruct.pm
diff -u loncom/publisher/lonconstruct.pm:1.19 loncom/publisher/lonconstruct.pm:1.20
--- loncom/publisher/lonconstruct.pm:1.19	Mon Nov 17 23:08:15 2003
+++ loncom/publisher/lonconstruct.pm	Wed Nov 19 09:57:32 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construction Space Page Wrapper for Construction
 #
-# $Id: lonconstruct.pm,v 1.19 2003/11/18 04:08:15 taceyjo1 Exp $
+# $Id: lonconstruct.pm,v 1.20 2003/11/19 14:57:32 taceyjo1 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -118,13 +118,6 @@
         ($ENV{'QUERY_STRING'},['forceColoredit']);
    if ($ENV{'form.forceColoredit'}) {
        $lowerframe.='?editmode=Edit&problemmode=Edit';
-   }
-   &Apache::loncommon::get_unprocessed_cgi
-	($ENV{'QUERY_STRING'},['decompress']);
-   if ($ENV{'form.decompress'}) {
-	&Apache::lonnet::appenv('cgi.path' => $r->path_info);
-	$lowerframe="http://$ENV{SERVER_NAME}/cgi-bin/decompress.pl";
-	
    }
    $r->print(<<ENDPAGE);
 <html>
Index: loncom/publisher/lonpubdir.pm
diff -u loncom/publisher/lonpubdir.pm:1.45 loncom/publisher/lonpubdir.pm:1.46
--- loncom/publisher/lonpubdir.pm:1.45	Mon Nov 17 23:08:15 2003
+++ loncom/publisher/lonpubdir.pm	Wed Nov 19 09:57:32 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construction Space Directory Lister
 #
-# $Id: lonpubdir.pm,v 1.45 2003/11/18 04:08:15 taceyjo1 Exp $
+# $Id: lonpubdir.pm,v 1.46 2003/11/19 14:57:32 taceyjo1 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -337,8 +337,8 @@
 	$editlink2=' (<a href="'.$linkdir.'/'.$filename.'?forceColoredit=1" target="_top">'.&mt('Edit').'</a>)';
     }
     if ($filename=~/\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/) {
-	&Apache::lonnet::appenv('cgi.file' => $filename);
-	$editlink=' (<a href="'.$linkdir.'/'.$filename.'?decompress=1" target="_top">'.&mt('Decompress').'</a>)';
+	$editlink=' (<a target="_parent" href="/adm/cfile?decompress=/~'.
+	      $uname.$thisdisfn.'/'.$filename.'">'.&mt('Decompress').'</a>)';
     }
     $r->print('<tr bgcolor="'.$bgcolor.'">'.
 	      '<td><a target="_parent" href="/adm/publish?filename=/~'.