[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm

raeburn raeburn at source.lon-capa.org
Tue Jan 31 19:18:30 EST 2012


raeburn		Wed Feb  1 00:18:30 2012 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Uploading archive files to a course.
    - Determine mime-type for file uploaded to course, regardless of whether
      "Upload embedded images/multimedia files if HTML file" checked.  
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1151 loncom/lonnet/perl/lonnet.pm:1.1152
--- loncom/lonnet/perl/lonnet.pm:1.1151	Sun Jan  8 23:23:58 2012
+++ loncom/lonnet/perl/lonnet.pm	Wed Feb  1 00:18:29 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1151 2012/01/08 23:23:58 raeburn Exp $
+# $Id: lonnet.pm,v 1.1152 2012/02/01 00:18:29 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2801,7 +2801,7 @@
 #        $resizewidth - width (pixels) to which to resize uploaded image
 #        $resizeheight - height (pixels) to which to resize uploaded image
 #        $mimetype - reference to scalar to accommodate mime type determined
-#                    from File::MMagic if $parser = parse.
+#                    from File::MMagic.
 # 
 # output: url of file in userspace, or error: <message> 
 #             or /adm/notfound.html if failure to upload occurse
@@ -2970,10 +2970,17 @@
             }  
 	}
     }
+    if (($context eq 'coursedoc') || ($parser eq 'parse')) {
+        if (ref($mimetype)) {
+            if ($$mimetype eq '') {
+                my $mm = new File::MMagic;
+                my $type = $mm->checktype_filename($filepath.'/'.$file);
+                $$mimetype = $type;
+            }
+        }
+    }
     if ($parser eq 'parse') {
-        my $mm = new File::MMagic;
-        my $type = $mm->checktype_filename($filepath.'/'.$file);
-        if ($type eq 'text/html') {
+        if ((ref($mimetype)) && ($$mimetype eq 'text/html')) {
             my $parse_result = &extract_embedded_items($filepath.'/'.$file,
                                                        $allfiles,$codebase);
             unless ($parse_result eq 'ok') {
@@ -2981,9 +2988,6 @@
 	   	         ' for embedded media: '.$parse_result); 
             }
         }
-        if (ref($mimetype)) {
-            $$mimetype = $type;
-        }
     }
     if (($thumbwidth =~ /^\d+$/) && ($thumbheight =~ /^\d+$/)) {
         my $input = $filepath.'/'.$file;




More information about the LON-CAPA-cvs mailing list