--- loncom/interface/londocs.pm 2010/03/18 13:48:45 1.422
+++ loncom/interface/londocs.pm 2010/12/07 17:33:36 1.443
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.422 2010/03/18 13:48:45 onken Exp $
+# $Id: londocs.pm,v 1.443 2010/12/07 17:33:36 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -121,7 +121,7 @@ sub dumpbutton {
if ($home+$other==0) { return ''; }
if ($home) {
my $link =
- ""
.&mt('Dump '.$crstype.' Documents to Construction Space')
@@ -268,7 +268,7 @@ sub dumpcourse {
sub exportbutton {
my $crstype = &Apache::loncommon::course_type();
- return "".&mt('IMS Export')."".
+ return "".&mt('IMS Export')."".
&Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'
';
}
@@ -1607,13 +1607,12 @@ sub editor {
my $shown=0;
if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
$r->print('
'.&mt('Parameters:'). - '
' .&mt('Caution: this folder is set to randomly pick a subset' @@ -1637,7 +1636,9 @@ sub editor { $r->print('
'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'
'; + return; } my $destination = 'docs/'; if ($folder =~ /^supplemental/) { @@ -1713,13 +1716,23 @@ sub process_file_upload { } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { $destination .= $2.'/'; } -# this is for a course, not a user, so set coursedoc flag -# probably the only place in the system where this should be "1" +# this is for a course, not a user, so set context to coursedoc. my $newidx=&LONCAPA::map::getresidx(); $destination .= $newidx; - my $url=&Apache::lonnet::userfileupload('uploaddoc',1,$destination, + my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination, $parseaction,$allfiles, - $codebase); + $codebase,undef,undef,undef,undef, + undef,undef,\$mimetype); + if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) { + my $stored = $1; + $showupload = ''.&mt('Uploaded [_1]',''. + $stored.'').'
'; + } else { + my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$}); + + $$upload_output = ''.&mt('Unable to save file [_1].',''.$filename.'').'
'; + return; + } my $ext='false'; if ($url=~m{^http://}) { $ext='true'; } $url = &LONCAPA::map::qtunescape($url); @@ -1736,51 +1749,37 @@ sub process_file_upload { ($errtext,$fatal)=&storemap($coursenum,$coursedom, $folder.'.'.$container); if ($fatal) { - $$upload_output .= ''.$errtext.'
'; - return 'failed'; + $$upload_output = ''.$errtext.'
'; + return; } else { - if ($parseaction eq 'parse') { + if ($parseaction eq 'parse' && $mimetype eq 'text/html') { + $$upload_output = $showupload; my $total_embedded = scalar(keys(%{$allfiles})); if ($total_embedded > 0) { - my $num = 0; - my $state = ' - - - - - '; - $phase_status = 'phasetwo'; - - $$upload_output .= - 'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'
'.$embedded; + $nextphase = $uploadphase; + } else { + $$upload_output .= $embedded; + } + } else { + $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').''.&mt('Done').'
' - .'' - .&mt('Back to Course Editor') - .'
' - ); + $r->print(''.&mt('Done').'
'); } @@ -2303,6 +2295,8 @@ sub checkversions { my $crstype = &Apache::loncommon::course_type(); $r->print(&Apache::loncommon::start_page("Check $crstype Document Versions")); $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Document Versions")); + &startContentScreen($r,'tools'); + my $header=''; my $startsel=''; my $monthsel=''; @@ -2480,11 +2474,11 @@ ENDHEADERS # Set version $r->print(&Apache::loncommon::select_form($setversions{$linkurl}, 'set_version_'.$linkurl, - ('select_form_order' => + {'select_form_order' => ['',1..$currentversion,'mostrecent'], '' => '', 'mostrecent' => &mt('most recent'), - map {$_,$_} (1..$currentversion)))); + map {$_,$_} (1..$currentversion)})); $r->print('
@@ -2995,14 +3004,15 @@ SEDFFORM
SEDFFORM
- my $extresourcesform=(< '.$error.' '.$error.' '.$error.' '.$error.' '.$error.' '.
@@ -3476,9 +3447,45 @@ $r->print('');
return OK;
}
+sub embedded_form_elems {
+ my ($phase,$primaryurl,$newidx) = @_;
+ my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
+ return <
');
+
+#
+# Decide whether this should display supplemental or main content
+# supplementalflag=1: show supplemental documents
+# supplementalflag=0: show standard documents
+
+ my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
+ if (($standard) && ($allowed) && (($env{'form.folderpath'}=~/^default/) || $env{'form.folderpath'} eq "" || ($env{'form.pagepath'}))) {
+ $supplementalflag=0;
}
- $r->print('
' . $fileuploadform;
+
push @specialdocumentsforma, ({''=>$newnavform},
{''=>$newsmppageform},
{''=>$newsmpproblemform},
@@ -3283,9 +3263,10 @@ NGFFORM
{''=>$newbulform},
{''=>$newaboutmeform},
{''=>$newaboutsomeoneform},
- {''=>$newrosterform},);
+ {''=>$newrosterform},);
- $specialdocumentsform = create_form_ul(create_list_elements(@specialdocumentsforma));
+ $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
+ }
if($env{'form.pagepath'}) {
@@ -3293,52 +3274,45 @@ if($env{'form.pagepath'}) {
{''=>$newsmpproblemform},
{''=>$newexuploadform}
);
- $specialdocumentsform= create_form_ul(create_list_elements(@specialdocumentsforma));
+ $specialdocumentsform= &create_form_ul(&create_list_elements(@specialdocumentsforma));
}
my @tools = (
# {''=>$extresourcesform},
# {''=>$imspform},
- {''=>$recoverform},
+ {''=>$recoverform},
);
-my @importdoc = (
- {''=>$extresourcesform},
- {''=>$imspform},
-);
-$fileuploadform = create_form_ul(create_list_elements(@importdoc)) . '
' . $fileuploadform;
my %orderhash = (
- '00' => ['Newfolder',$newfolderform],
'aa' => ['Import Documents',$fileuploadform],
'bb' => ['Published Resources',$simpleeditdefaultform],
'cc' => ['Special Documents',$specialdocumentsform],
- 'dd' => ['Tools', create_form_ul(create_list_elements(@tools)).&generate_admin_options($containertag,$uploadtag,\%help,\%env)],
+ 'dd' => ['Tools', &create_form_ul(&create_list_elements(@tools)).&generate_admin_options(\%help,\%env)],
);
-my $tid='1';
+unless($env{'form.pagepath'}) {
+ $orderhash{'00'} = ['Newfolder',$newfolderform];
+}
+
$hadchanges=0;
- my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype);
- if ($error) {
- $r->print('
' . $supupdocform;
+$supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)) . '
' . $supupdocform;
my %suporderhash = (
'00' => ['Supnewfolder', $supnewfolderform],
'ee' => ['Import Documents',$supupdocform],
- 'ff' => ['Special Documents',create_form_ul(create_list_elements(@specialdocs))]
+ 'ff' => ['Special Documents',&create_form_ul(&create_list_elements(@specialdocs))]
);
-
- my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype);
- if ($error) {
- $r->print('".&mt('Uploaded Document').' - '.
&Apache::lonnet::gettitle($r->uri).'