[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm londocs.pm portfolio.pm /lonnet/perl lonnet.pm

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Mon, 09 Jun 2008 22:35:01 -0000


This is a MIME encoded message

--raeburn1213050901
Content-Type: text/plain

raeburn		Mon Jun  9 18:35:01 2008 EDT

  Modified files:              
    /loncom/interface	londocs.pm loncommon.pm portfolio.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Move &ask_for_embedded_content() from londocs.pm to loncommon.pm
  - &lonnet::extract_embedded_items() - argument change.
    - Path to file to be parsed to look for embedded objects now in a single argunment (first arg), instead of as separate $filepath and $fname.
  
  
--raeburn1213050901
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20080609183501.txt"

Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.307 loncom/interface/londocs.pm:1.308
--- loncom/interface/londocs.pm:1.307	Wed May 28 10:21:30 2008
+++ loncom/interface/londocs.pm	Mon Jun  9 18:34:55 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.307 2008/05/28 14:21:30 www Exp $
+# $Id: londocs.pm,v 1.308 2008/06/09 22:34:55 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -818,7 +818,7 @@
         $dirpath = $url;
         $container = '';
     }
-    &Apache::lonnet::extract_embedded_items(undef,undef,\%allfiles,\%codebase,$content);
+    &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,$content);
     foreach my $embed_file (keys(%allfiles)) {
         my $filename;
         if ($embed_file =~ m#([^/]+)$#) {
@@ -1571,8 +1571,8 @@
 
                     $$upload_output .= 
 			'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br />'.
-			&ask_for_embedded_content('/adm/coursedocs',
-						  $state,$allfiles,$codebase);
+			&Apache::loncommon::ask_for_embedded_content(
+                            '/adm/coursedocs',$state,$allfiles,$codebase);
                 } else {
                     $$upload_output .= 'No embedded items identified<br />';
                 }
@@ -1582,55 +1582,6 @@
     return $phase_status;
 }
 
-sub ask_for_embedded_content {
-    my ($actionurl,$state,$allfiles,$codebase,$args)=@_;
-    my $upload_output = '
-   <form name="upload_embedded" action="'.$actionurl.'"
-                  method="post" enctype="multipart/form-data">';
-    $upload_output .= $state;
-    $upload_output .= '<b>Upload embedded files</b>:<br />'.
-	&Apache::loncommon::start_data_table();
-
-    my $num = 0;
-    foreach my $embed_file (sort {lc($a) cmp lc($b)} keys(%{$allfiles})) {
-	$upload_output .= &Apache::loncommon::start_data_table_row().
-	    '<td>'.$embed_file.'</td><td>';
-	if ($args->{'ignore_remote_references'}
-	    && $embed_file =~ m{^\w+://}) {
-	    $upload_output.='<span class="LC_warning">'.&mt("URL points to other server.").'</span>';
-	} elsif ($args->{'error_on_invalid_names'}
-	    && $embed_file ne &Apache::lonnet::clean_filename($embed_file,{'keep_path' => 1,})) {
-	    
-	    $upload_output.='<span class="LC_warning">'.&mt("Invalid characters").'</span>';
-	    
-	} else {
-
-	    $upload_output .='
-           <input name="embedded_item_'.$num.'" type="file" value="bob" />
-           <input name="embedded_orig_'.$num.'" type="hidden" value="'.&escape($embed_file).'" />';
-	    my $attrib = join(':',@{$$allfiles{$embed_file}});
-	    $upload_output .=
-		"\n\t\t".
-		'<input name="embedded_attrib_'.$num.'" type="hidden" value="'.
-		$attrib.'" />';
-	    if (exists($$codebase{$embed_file})) {
-		$upload_output .= 
-		    "\n\t\t".
-		    '<input name="codebase_'.$num.'" type="hidden" value="'.
-		    &escape($$codebase{$embed_file}).'" />';
-	    }
-	}
-	$upload_output .= '</td>'.&Apache::loncommon::end_data_table_row();
-	$num++;
-    }
-    $upload_output .= &Apache::loncommon::end_data_table().'<br />
-   <input type ="hidden" name="number_embedded_items" value="'.$num.'" />
-   <input type ="submit" value="'.&mt('Upload Listed Files').'" />
-   '.&mt('(only files for which a location has been provided will be uploaded)').'
-   </form>';
-    return $upload_output;
-}
-
 sub process_secondary_uploads {
     my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_;
     my $folder=$env{'form.folder'};
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.659 loncom/interface/loncommon.pm:1.660
--- loncom/interface/loncommon.pm:1.659	Sat May 31 19:53:18 2008
+++ loncom/interface/loncommon.pm	Mon Jun  9 18:34:55 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.659 2008/05/31 23:53:18 raeburn Exp $
+# $Id: loncommon.pm,v 1.660 2008/06/09 22:34:55 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -7035,6 +7035,54 @@
     return(@values);
 }
 
+sub ask_for_embedded_content {
+    my ($actionurl,$state,$allfiles,$codebase,$args)=@_;
+    my $upload_output = '
+   <form name="upload_embedded" action="'.$actionurl.'"
+                  method="post" enctype="multipart/form-data">';
+    $upload_output .= $state;
+    $upload_output .= '<b>Upload embedded files</b>:<br />'.start_data_table();
+
+    my $num = 0;
+    foreach my $embed_file (sort {lc($a) cmp lc($b)} keys(%{$allfiles})) {
+        $upload_output .= &start_data_table_row().
+            '<td>'.$embed_file.'</td><td>';
+        if ($args->{'ignore_remote_references'}
+            && $embed_file =~ m{^\w+://}) {
+            $upload_output.='<span class="LC_warning">'.&mt("URL points to other server.").'</span>';
+        } elsif ($args->{'error_on_invalid_names'}
+            && $embed_file ne &Apache::lonnet::clean_filename($embed_file,{'keep_path' => 1,})) {
+
+            $upload_output.='<span class="LC_warning">'.&mt("Invalid characters").'</span>';
+
+        } else {
+
+            $upload_output .='
+           <input name="embedded_item_'.$num.'" type="file" value="bob" />
+           <input name="embedded_orig_'.$num.'" type="hidden" value="'.&escape($embed_file).'" />';
+            my $attrib = join(':',@{$$allfiles{$embed_file}});
+            $upload_output .=
+                "\n\t\t".
+                '<input name="embedded_attrib_'.$num.'" type="hidden" value="'.
+                $attrib.'" />';
+            if (exists($$codebase{$embed_file})) {
+                $upload_output .=
+                    "\n\t\t".
+                    '<input name="codebase_'.$num.'" type="hidden" value="'.
+                    &escape($$codebase{$embed_file}).'" />';
+            }
+        }
+        $upload_output .= '</td>'.&Apache::loncommon::end_data_table_row();
+        $num++;
+    }
+    $upload_output .= &Apache::loncommon::end_data_table().'<br />
+   <input type ="hidden" name="number_embedded_items" value="'.$num.'" />
+   <input type ="submit" value="'.&mt('Upload Listed Files').'" />
+   '.&mt('(only files for which a location has been provided will be uploaded)').'
+   </form>';
+    return $upload_output;
+}
+
 
 =pod
 
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.193 loncom/interface/portfolio.pm:1.194
--- loncom/interface/portfolio.pm:1.193	Wed May 28 16:46:46 2008
+++ loncom/interface/portfolio.pm	Mon Jun  9 18:34:55 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # portfolio browser
 #
-# $Id: portfolio.pm,v 1.193 2008/05/28 20:46:46 raeburn Exp $
+# $Id: portfolio.pm,v 1.194 2008/06/09 22:34:55 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1846,7 +1846,7 @@
             $r->print("<h2>".&mt("Reference Warning")."</h2>");
             $r->print("<p>".&mt("Completed upload of the file. This file contained references to other files. You must upload the referenced files or else the uploaded file may not work properly.")."</p>");
             $r->print("<p>".&mt("Please select the locations from which the referenced files are to be uploaded.")."</p>");
-	    $r->print(&Apache::londocs::ask_for_embedded_content('/adm/portfolio',$state,\%allfiles,\%codebase,
+	    $r->print(&Apache::loncommon::ask_for_embedded_content('/adm/portfolio',$state,\%allfiles,\%codebase,
 				      {'error_on_invalid_names'   => 1,
 				       'ignore_remote_references' => 1,}));
 	    $r->print('<p>Or '.&done('Return to directory',$url).'</p>');
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.960 loncom/lonnet/perl/lonnet.pm:1.961
--- loncom/lonnet/perl/lonnet.pm:1.960	Fri Jun  6 00:53:51 2008
+++ loncom/lonnet/perl/lonnet.pm	Mon Jun  9 18:35:00 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.960 2008/06/06 04:53:51 raeburn Exp $
+# $Id: lonnet.pm,v 1.961 2008/06/09 22:35:00 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1890,7 +1890,7 @@
             print $fh $env{'form.'.$source};
             close($fh);
             if ($parser eq 'parse') {
-                my $parse_result = &extract_embedded_items($filepath,$fname,$allfiles,$codebase);
+                my $parse_result = &extract_embedded_items($filepath.'/'.$fname,$allfiles,$codebase);
                 unless ($parse_result eq 'ok') {
                     &logthis('Failed to parse '.$filepath.'/'.$fname.' for embedded media: '.$parse_result);
                 }
@@ -2098,7 +2098,7 @@
 	close(FH);
     }
     if ($parser eq 'parse') {
-        my $parse_result = &extract_embedded_items($filepath,$file,$allfiles,
+        my $parse_result = &extract_embedded_items($filepath.'/'.$file,$allfiles,
 						   $codebase);
         unless ($parse_result eq 'ok') {
             &logthis('Failed to parse '.$filepath.$file.
@@ -2138,7 +2138,7 @@
 }
 
 sub extract_embedded_items {
-    my ($filepath,$file,$allfiles,$codebase,$content) = @_;
+    my ($fullpath,$allfiles,$codebase,$content) = @_;
     my @state = ();
     my %javafiles = (
                       codebase => '',
@@ -2153,7 +2153,7 @@
     if ($content) {
         $p = HTML::LCParser->new($content);
     } else {
-        $p = HTML::LCParser->new($filepath.'/'.$file);
+        $p = HTML::LCParser->new($fullpath);
     }
     while (my $t=$p->get_token()) {
 	if ($t->[0] eq 'S') {

--raeburn1213050901--