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

foxr lon-capa-cvs@mail.lon-capa.org
Mon, 27 May 2002 03:18:46 -0000


foxr		Sun May 26 23:18:46 2002 EDT

  Modified files:              
    /loncom/publisher	loncfile.pm 
  Log:
  Add a sub for URL -> Path conversion, use it in handler...
    still must look for applications eleswhere in the module.
  
  
  
  
Index: loncom/publisher/loncfile.pm
diff -u loncom/publisher/loncfile.pm:1.9 loncom/publisher/loncfile.pm:1.10
--- loncom/publisher/loncfile.pm:1.9	Fri May 24 01:11:40 2002
+++ loncom/publisher/loncfile.pm	Sun May 26 23:18:46 2002
@@ -10,7 +10,7 @@
 #
 
 #
-# $Id: loncfile.pm,v 1.9 2002/05/24 05:11:40 foxr Exp $
+# $Id: loncfile.pm,v 1.10 2002/05/27 03:18:46 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -63,8 +63,8 @@
 use Apache::loncacc;
 use Apache::Log ();
 
-my $DEBUG=1;
-
+my $DEBUG=0;
+my $r;				# Needs to be global for some stuff RF.
 #
 #  Debug
 #    If debugging is enabled puts out a debuggin message determined by the
@@ -83,7 +83,26 @@
 	$log->debug($message);    
     }
 }
-
+#
+#   URLToPath
+#     Convert a URL to a file system path.
+#
+#   In order to manipulate the construction space objects, it's necessary
+#   to access url identified objects a filespace objects.  This function
+#   translates a construction space URL to a file system path.
+# Parameters:
+#    Url    - string [in] The url to convert.
+# Returns:
+#    The corresponing file system path.
+sub URLToPath
+{
+    my $Url = shift;
+    &Debug($r, "UrlToPath got: $Url");
+    $Url=~ s/^http\:\/\/[^\/]+\/\~(\w+)/\/home\/$1\/public_html/;
+    $Url=~ s/^http\:\/\/[^\/]+//;
+    &Debug($r, "Returning $Url \n");
+    return $Url;
+}
 sub exists {
     my ($uname,$udom,$dir,$newfile)=@_;
     my $published='/home/httpd/html/res/'.$udom.'/'.$uname.'/'.$dir.'/'.
@@ -265,7 +284,7 @@
 
 sub handler {
 
-  my $r=shift;
+  $r=shift;
 
 
   &Debug($r, "loncfile.pm - handler entered");
@@ -275,8 +294,9 @@
   if ($ENV{'form.filename'}) {
       $fn=$ENV{'form.filename'};
       &Debug($r, "loncfile::handler - raw url: $fn");
-      $fn=~s/^http\:\/\/[^\/]+\/\~(\w+)/\/home\/$1\/public_html/;
-      $fn=~s/^http\:\/\/[^\/]+//;
+#      $fn=~s/^http\:\/\/[^\/]+\/\~(\w+)/\/home\/$1\/public_html/;
+#      $fn=~s/^http\:\/\/[^\/]+//;
+      $fn=URLToPath($fn);
       &Debug($r, "loncfile::handler - doctored url: $fn");
 
   } else {