--- loncom/interface/londocs.pm 2012/01/29 19:50:53 1.475
+++ loncom/interface/londocs.pm 2012/03/28 12:58:42 1.479
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.475 2012/01/29 19:50:53 raeburn Exp $
+# $Id: londocs.pm,v 1.479 2012/03/28 12:58:42 goltermann Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -26,8 +26,6 @@
# http://www.lon-capa.org/
#
-
-
package Apache::londocs;
use strict;
@@ -1109,6 +1107,24 @@ sub process_file_upload {
$$upload_output .= &mt('No embedded items identified').'
';
}
$$upload_output = '
'.&mt('Resources').' | '. + "$lt{'mr'} | ". + "$lt{'ve'} | ". + "$lt{'vu'} | ". + ''.&mt('History').' | '. + ''); foreach my $key (sort(keys(%changes))) { if ($changes{$key}>$starttime) { my ($root,$extension)=($key=~/^(.*)\.(\w+)$/); my $currentversion=&Apache::lonnet::getversion($key); if ($currentversion<0) { - $currentversion=&mt('Could not be determined.'); + $currentversion=''.&mt('Could not be determined.').''; } my $linkurl=&Apache::lonnet::clutter($key); - $r->print( - '||||
---|---|---|---|---|---|---|---|---|
'. - &Apache::lonnet::gettitle($linkurl). - ' | ||||||||
'. - ' | '. - ''.$linkurl. - ' | |||||||
'. - ' | '. - &Apache::lonlocal::locallocaltime( - &Apache::lonnet::metadata($root.'.'.$extension, - 'lastrevisiondate') - ). - ' | '. - 'Most Recent: '. - ''.$currentversion.''. - ' | '. - 'In '.$crstype.': '. - ''); + $r->print( + &Apache::loncommon::end_data_table_header_row(). + &Apache::loncommon::start_data_table_row(). + ' | '.&Apache::lonnet::gettitle($linkurl).' '. + ''.$linkurl.' | '.
+ ''.$currentversion.' ('. + &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate')).') | '.
+ ''); # Used in course my $usedversion=$hash{'version_'.$linkurl}; if (($usedversion) && ($usedversion ne 'mostrecent')) { - $r->print($usedversion); + if($usedversion != $currentversion){ + $r->print(''.$usedversion.''); + }else{ + $r->print($usedversion); + } } else { $r->print($currentversion); } - $r->print(' | '. - 'Use: '); + $r->print(' | '); # Set version $r->print(&Apache::loncommon::select_form($setversions{$linkurl}, 'set_version_'.$linkurl, @@ -1827,7 +1872,6 @@ ENDHEADERS '' => '', 'mostrecent' => &mt('most recent'), map {$_,$_} (1..$currentversion)})); - $r->print(' |
'); my $lastold=1; for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { my $url=$root.'.'.$prevvers.'.'.$extension; @@ -1841,13 +1885,13 @@ ENDHEADERS # each of the four columns my $entries_per_col = 0; my $num_entries = ($currentversion-$lastold); - if ($num_entries % 4 == 0) { - $entries_per_col = $num_entries/4; + if ($num_entries % $num_ver_col == 0) { + $entries_per_col = $num_entries/$num_ver_col; } else { - $entries_per_col = $num_entries/4 + 1; + $entries_per_col = $num_entries/$num_ver_col + 1; } my $entries_count = 0; - $r->print(' | '); + $r->print(' | ');
my $cols_output = 1;
for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
my $url=$root.'.'.$prevvers.'.'.$extension;
@@ -1866,21 +1910,21 @@ ENDHEADERS
}
$r->print(' '); if (++$entries_count % $entries_per_col == 0) { - $r->print(' | ');
- if ($cols_output != 4) {
- $r->print(''); + $r->print(' | '); + if ($cols_output != $num_ver_col) { + $r->print(''); $cols_output++; } } } - while($cols_output++ < 4) { - $r->print(' | ') + while($cols_output++ < $num_ver_col) { + $r->print(' | '); } - $r->print(' |
'.&mt('Done').'
'); + $r->print(''.&Apache::loncommon::end_data_table_row(). + &Apache::loncommon::end_data_table(). + ''); &untiehash(); } @@ -2363,6 +2407,14 @@ sub handler { $docuname,$docudom,undef, $dir_root). &return_to_editor()); + } elsif ($env{'form.phase'} eq 'decompress_uploaded') { + $uploadphase = 'decompress_phase_one'; + $r->print(&decompression_phase_one(). + &return_to_editor()); + } elsif ($env{'form.phase'} eq 'decompress_cleanup') { + $uploadphase = 'decompress_phase_two'; + $r->print(&decompression_phase_two(). + &return_to_editor()); } } @@ -2933,6 +2985,96 @@ sub return_to_editor { ''; } +sub decompression_info { + my ($destination,$dir_root) = &embedded_destination(); + my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'}; + my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; + my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; + my $container='sequence'; + my $hiddenelem; + if ($env{'form.pagepath'}) { + $container='page'; + $hiddenelem = ''."\n"; + } else { + $hiddenelem = ''."\n"; + } + if ($env{'form.newidx'}) { + $hiddenelem .= ''."\n"; + } + if ($env{'form.comment'}) { + $hiddenelem .= ''."\n"; + } + return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container, + $hiddenelem); +} + +sub decompression_phase_one { + my ($dir,$file,$warning,$error,$output); + my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)= + &decompression_info(); + if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/docs/\E(?:default|supplemental|\d+).*/([^/]+)$}) { + $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'}); + } else { + my $file = $1; + $output = &Apache::loncommon::process_decompression($docudom,$docuname,$file,$destination,$dir_root,$hiddenelem); + if ($env{'form.archivedelete'}) { + my $map = $env{'form.folder'}.'.'.$container; + my ($delwarning,$delresult); + my ($errtext,$fatal) = &mapread($docuname,$docudom,$map); + if ($fatal) { + if ($container eq 'page') { + $delwarning = &mt('An error occurred retrieving the contents of the current page.'); + } else { + $delwarning = &mt('An error occurred retrieving the contents of the current folder.'); + } + $delwarning .= &mt('As a result the archive file has not been removed.'); + } else { + my $currcmd = $env{'form.cmd'}; + $env{'form.cmd'} = 'del_'.$env{'form.position'}; + if (&handle_edit_cmd($docuname,$docudom)) { + ($errtext,$fatal) = &storemap($docuname,$docudom,$map); + if ($fatal) { + if ($container eq 'page') { + $delwarning = &mt('An error occurred updating the contents of the current page.'); + } else { + $delwarning = &mt('An error occurred updating the contents of the current folder.'); + } + } + } + $env{'form.cmd'} = $currcmd; + $delresult = &mt('Archive file removed after extracting files.'); + } + if ($delwarning) { + $output .= ''. + $delwarning. + '
'; + } + if ($delresult) { + $output .= ''. + $delresult. + '
'; + } + } + } + if ($error) { + $output .= ''.&mt('Not extracted.').'
'.
+ $error.'
'.$warning.'
'."\n"; + } + return $output; +} + +sub decompression_phase_two { + my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)= + &decompression_info(); + my $output = + &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname, + $destination,$dir_root,$hiddenelem); + return $output; +} + sub generate_admin_options { my ($help_ref,$env_ref) = @_; my %lt=&Apache::lonlocal::texthash( @@ -3048,7 +3190,8 @@ sub editing_js { p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!', p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.', p_ctr2a => 'Cut[_98]', - p_ctr2b => '?[_98]' + p_ctr2b => '?[_98]', + rpck => 'Enter number to pick (e.g., 3)', ); my $crstype = &Apache::loncommon::course_type(); @@ -3242,6 +3385,37 @@ this.document.forms.renameform.pagesymb. this.document.forms.renameform.submit(); } +function updatePick(targetform,index,caller) { + var pickitem = document.getElementById('rpick_'+index); + var picknumitem = document.getElementById('rpicknum_'+index); + if (pickitem.checked) { + var picknum=prompt('$lt{"rpck"}',picknumitem.value); + if (picknum == '' || picknum == null) { + if (caller == 'check') { + pickitem.checked=false; + return; + } + } else { + picknum.toString(); + var regexdigit=/^\\d+\$/; + if (regexdigit.test(picknum)) { + picknumitem.value = picknum; + targetform.changeparms.value='randompick'; + targetform.submit(); + } else { + if (caller == 'check') { + pickitem.checked=false; + } + return; + } + } + } else { + picknumitem.value = 0; + targetform.changeparms.value='randompick'; + targetform.submit(); + } +} + function unselectInactive(nav) { currentNav = document.getElementById(nav); currentLis = currentNav.getElementsByTagName('LI');