[LON-CAPA-cvs] cvs: loncom /interface londocs.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 09 Jan 2007 19:10:48 -0000
albertel Tue Jan 9 14:10:48 2007 EDT
Modified files:
/loncom/interface londocs.pm
Log:
- refactor out the embedded docs interface
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.268 loncom/interface/londocs.pm:1.269
--- loncom/interface/londocs.pm:1.268 Fri Jan 5 14:40:43 2007
+++ loncom/interface/londocs.pm Tue Jan 9 14:10:46 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.268 2007/01/05 19:40:43 www Exp $
+# $Id: londocs.pm,v 1.269 2007/01/09 19:10:46 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1562,38 +1562,18 @@
my $total_embedded = keys(%{$allfiles});
if ($total_embedded > 0) {
my $num = 0;
- $$upload_output .= 'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br />
- <form name="upload_embedded" action="/adm/coursedocs"
- method="post" enctype="multipart/form-data">
- <input type="hidden" name="folderpath" value="'.$env{'form.folderpath'}.'" /> <input type="hidden" name="cmd" value="upload_embedded" />
+ my $state = '
+ <input type="hidden" name="folderpath" value="'.$env{'form.folderpath'}.'" />
+ <input type="hidden" name="cmd" value="upload_embedded" />
<input type="hidden" name="newidx" value="'.$newidx.'" />
<input type="hidden" name="primaryurl" value="'.&escape($url).'" />
<input type="hidden" name="phasetwo" value="'.$total_embedded.'" />';
- $$upload_output .= '<b>Upload embedded files</b>:<br />
- <table>';
- foreach my $embed_file (keys(%{$allfiles})) {
- $$upload_output .= '<tr><td>'.$embed_file.
- '<input name="embedded_item_'.$num.'" type="file" />
- <input name="embedded_orig_'.$num.'" type="hidden" value="'.&escape($embed_file).'" />';
- my $attrib;
- if (@{$$allfiles{$embed_file}} > 1) {
- $attrib = join(':',@{$$allfiles{$embed_file}});
- } else {
- $attrib = $$allfiles{$embed_file}[0];
- }
- $$upload_output .=
- '<input name="embedded_attrib_'.$num.'" type="hidden" value="'.$attrib.'" />';
- if (exists($$codebase{$embed_file})) {
- $$upload_output .=
- '<input name="codebase_'.$num.'" type="hidden" value="'.&escape($$codebase{$embed_file}).'" />';
- }
- $$upload_output .= '</td></tr>';
- $num ++;
- }
- $phase_status = 'phasetwo';
- $$upload_output .= '</table><br />
- <input type ="submit" value="Complete upload" />
- </form>';
+ $phase_status = 'phasetwo';
+
+ $$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);
} else {
$$upload_output .= 'No embedded items identified<br />';
}
@@ -1603,6 +1583,41 @@
return $phase_status;
}
+sub ask_for_embedded_content {
+ my ($actionurl,$state,$allfiles,$codebase)=@_;
+ 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 />
+ <table>';
+
+ my $num = 0;
+ foreach my $embed_file (keys(%{$allfiles})) {
+ $upload_output .= '<tr><td>'.$embed_file.'</td><td>
+ <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></tr>';
+ $num++;
+ }
+ $upload_output .= '</table><br />
+ <input type ="hidden" name="number_embedded_items" value="'.$num.'" />
+ <input type ="submit" value="Complete upload" />
+ </form>';
+ return $upload_output;
+}
+
sub process_secondary_uploads {
my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_;
my $folder=$env{'form.folder'};