--- loncom/interface/londocs.pm 2010/10/27 01:00:38 1.439 +++ loncom/interface/londocs.pm 2011/01/17 20:18:02 1.449 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.439 2010/10/27 01:00:38 raeburn Exp $ +# $Id: londocs.pm,v 1.449 2011/01/17 20:18:02 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1521,12 +1521,11 @@ sub editor { $LONCAPA::map::resources[$idx]=''; } - my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order); - if ($allowed) { - ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) = + my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) = &breadcrumbs($allowed,$crstype); $r->print($breadcrumbtrail); - } else { + + unless ($allowed) { $randompick = -1; } @@ -1653,7 +1652,8 @@ sub editor { &Apache::loncommon::end_data_table_count(); if ($shown) { - $r->print(&Apache::loncommon::start_data_table()); + $r->print(&Apache::loncommon::start_scrollbox('900px','880px','400px') + .&Apache::loncommon::start_data_table()); if ($allowed) { $r->print(&Apache::loncommon::start_data_table_header_row() .'
' @@ -1682,11 +1683,10 @@ sub editor { sub process_file_upload { my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_; # upload a file, if present - my $parseaction; - if ($env{'form.parserflag'}) { + my ($parseaction,$showupload,$nextphase,$mimetype); + if ($env{'form.parserflag'}) { $parseaction = 'parse'; } - my $phase_status; my $folder=$env{'form.folder'}; if ($folder eq '') { $folder='default'; @@ -1705,7 +1705,8 @@ sub process_file_upload { $LONCAPA::map::resources[1]=''; } if ($fatal) { - return 'failed'; + $$upload_output = '
'.&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/) { @@ -1716,13 +1717,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','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); @@ -1739,51 +1750,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').'
'); } @@ -2304,6 +2296,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=''; @@ -2614,8 +2608,66 @@ sub init_breadcrumbs { bug=>'Instructor Interface'}); } +# subroutine to list form elements +sub create_list_elements { + my @formarr = @_; + my $list = ''; + for my $button (@formarr){ + for my $picture(keys %$button) { + $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'}); + } + } + return $list; +} + +# subroutine to create ul from list elements +sub create_form_ul { + my $list = shift; + my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'}); + return $ul; +} + +# +# Start tabs +# + +sub startContentScreen { + my ($r,$mode)=@_; + $r->print(' '); + $r->print('
@@ -3009,14 +3016,15 @@ SEDFFORM
SEDFFORM
- my $extresourcesform=(< '.$error.' '.$error.' '.$error.' '.$error.' '.$error.' '.
@@ -3481,6 +3446,42 @@ $r->print('');
return OK;
}
+sub embedded_form_elems {
+ my ($phase,$primaryurl,$newidx) = @_;
+ my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
+ return <
');
- }
- $r->print('
' . $fileuploadform;
+ $fileuploadform = &create_form_ul(&create_list_elements(@importdoc)) . '
' . $fileuploadform;
push @specialdocumentsforma, ({''=>$newnavform},
{''=>$newsmppageform},
@@ -3293,7 +3265,7 @@ NGFFORM
{''=>$newaboutsomeoneform},
{''=>$newrosterform},);
- $specialdocumentsform = create_form_ul(create_list_elements(@specialdocumentsforma));
+ $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
}
if($env{'form.pagepath'}) {
@@ -3302,7 +3274,7 @@ if($env{'form.pagepath'}) {
{''=>$newsmpproblemform},
{''=>$newexuploadform}
);
- $specialdocumentsform= create_form_ul(create_list_elements(@specialdocumentsforma));
+ $specialdocumentsform= &create_form_ul(&create_list_elements(@specialdocumentsforma));
}
my @tools = (
@@ -3315,41 +3287,37 @@ my %orderhash = (
'aa' => ['Import Documents',$fileuploadform],
'bb' => ['Published Resources',$simpleeditdefaultform],
'cc' => ['Special Documents',$specialdocumentsform],
- 'dd' => ['Tools', create_form_ul(create_list_elements(@tools)).&generate_admin_options(\%help,\%env)],
+ 'dd' => ['Tools', &create_form_ul(&create_list_elements(@tools)).&generate_admin_options(\%help,\%env)],
);
unless($env{'form.pagepath'}) {
$orderhash{'00'} = ['Newfolder',$newfolderform];
}
-my $tid='1';
$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).'