[LON-CAPA-cvs] cvs: loncom /cgi decompress.pl

raeburn raeburn@source.lon-capa.org
Fri, 28 Nov 2008 20:42:20 -0000


raeburn		Fri Nov 28 20:42:20 2008 EDT

  Modified files:              
    /loncom/cgi	decompress.pl 
  Log:
  - Add localization.
  - Use LONCAPA::loncgi::missing_cookie_msg() to generate missing cookie message. 
  
  
Index: loncom/cgi/decompress.pl
diff -u loncom/cgi/decompress.pl:1.16 loncom/cgi/decompress.pl:1.17
--- loncom/cgi/decompress.pl:1.16	Fri May  5 21:07:19 2006
+++ loncom/cgi/decompress.pl	Fri Nov 28 20:42:20 2008
@@ -31,6 +31,8 @@
 ####
 use strict;
 use lib '/home/httpd/lib/perl';
+use Apache::lonnet;
+use Apache::lonlocal;
 use LONCAPA::loncgi;
 
 my %location_of;
@@ -43,22 +45,28 @@
     }
 }
 
+print("Content-type: text/html\n\n");
+
 if (!&LONCAPA::loncgi::check_cookie_and_load_env()) {
-    print("Content-type: text/html\n\n");
-    print(<<END);
-    <html><body>NO COOKIE!</body></html>
-END
+    &Apache::lonlocal::get_language_handle();
+    print(&LONCAPA::loncgi::missing_cookie_msg());
 } else {
-    print "Content-type: text/html\n\n";
+    &Apache::lonlocal::get_language_handle();
+    my %lt = &Apache::lonlocal::texthash (
+                                            bade => 'Bad Environment!',
+                                            outo => 'Output of decompress:',
+                                            comp => 'Decompress complete.', 
+                                            erro => 'An error occurred',
+                                         );
     my $file=$Apache::lonnet::env{'cgi.file'};
     my $dir=$Apache::lonnet::env{'cgi.dir'}; 
     if(! $file || ! $dir) {
         print(<<END);
-        <html><body>Bad Enviroment!</body></html>
+        <html><body><span class="LC_error">$lt{'bade'}</span></body></html>
 END
     } else {
         print(<<END);
-	<html><body><p><b>Output of decompress:</b></p>
+	<html><body><p><b>$lt{'outo'}</b></p>
 END
         chdir($dir);
 	my @cmd;
@@ -76,7 +84,7 @@
         } elsif ($file =~ m|\.tar$|) {
             @cmd = ($location_of{'tar'},"-xpvf");
         } else {
-            print("There has been an error in determining the file type of $file, please check name");
+            print('<span class="LC_error">'.&Apache::lonlocal::mt('There has been an error in determining the file type of [_1], please check the name',$file).'</span>');
         }
 	if (@cmd) {
 	    undef($!);
@@ -84,12 +92,12 @@
 	    open(OUTPUT,"-|", @cmd, $file);
 	    while (my $line = <OUTPUT>) { print("$line<br />"); }
 	    close(OUTPUT);
-	    print("<p><b>Decompress complete.</b></p>");
+	    print("<p><b>$lt{'comp'}</b></p>");
 	    if ($! || $@) {
-		print("<p><b>An error occurred</b></p><p>$!</p><p>$@</p>");
+		print('<p><span class="LC_error">'.$lt{'erro'}.'<br />'.$!.'<br />'.$@.'</span></p>');
 	    }
-	    print("</body></html>");
 	}
+        print('</body></html>');
     }
 }