--- loncom/interface/londocs.pm 2013/04/03 02:00:19 1.543 +++ loncom/interface/londocs.pm 2013/12/18 23:03:43 1.572 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.543 2013/04/03 02:00:19 raeburn Exp $ +# $Id: londocs.pm,v 1.572 2013/12/18 23:03:43 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,6 +41,8 @@ use Apache::lonclonecourse; use Apache::lonnavmaps; use Apache::lonnavdisplay(); use Apache::lonextresedit(); +use Apache::lontemplate(); +use Apache::lonsimplepage(); use HTML::Entities; use HTML::TokeParser; use GDBM_File; @@ -56,6 +58,7 @@ my $hashtied; my %alreadyseen=(); my $hadchanges; +my $suppchanges; my %help=(); @@ -79,7 +82,11 @@ sub storemap { $map,1,$report); if ($errtext) { return ($errtext,2); } - $hadchanges=1; + if ($map =~ /^default/) { + $hadchanges=1; + } else { + $suppchanges=1; + } return ($errtext,0); } @@ -136,8 +143,28 @@ sub clean { sub dumpcourse { my ($r) = @_; my $crstype = &Apache::loncommon::course_type(); - $r->print(&Apache::loncommon::start_page('Dump '.$crstype.' Content to Authoring Space')."\n". - &Apache::lonhtmlcommon::breadcrumbs('Dump '.$crstype.' Content to Authoring Space')."\n"); + my ($starthash,$js); + unless (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) { + $js = <<"ENDJS"; + +ENDJS + $starthash = { + add_entries => {'onload' => "hide_searching();"}, + }; + } + $r->print(&Apache::loncommon::start_page('Copy '.$crstype.' Content to Authoring Space',$js,$starthash)."\n". + &Apache::lonhtmlcommon::breadcrumbs('Copy '.$crstype.' Content to Authoring Space')."\n"); $r->print(&startContentScreen('tools')); my ($home,$other,%outhash)=&authorhosts(); unless ($home) { @@ -156,118 +183,407 @@ sub dumpcourse { $r->print('
'
+ my $toolslink;
+ if ($allowed || &Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
+ $toolslink = '
'; + } if ($shown) { if ($allowed) { $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll') @@ -2703,7 +3028,7 @@ sub editor { } $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll') .' '
- .&mt('Currently no documents.')
+ .&mt('Currently empty')
.' '
.&Apache::loncommon::end_scrollbox();
}
@@ -2716,7 +3041,7 @@ sub editor {
.'';
} else {
$to_show = ''
- .&mt('Currently no documents.')
+ .&mt('Currently empty')
.' '
}
}
@@ -2801,8 +3126,30 @@ sub multiple_check_form {
}
sub process_file_upload {
- my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_;
+ my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_;
# upload a file, if present
+ my $filesize = length($env{'form.uploaddoc'});
+ if (!$filesize) {
+ $$upload_output = ''.
+ &mt('Unable to upload [_1]. (size = [_2] bytes)',
+ ''.$env{'form.uploaddoc.filename'}.'',
+ $filesize).' ';
+ return;
+ }
+ my $quotatype = 'unofficial';
+ if ($crstype eq 'Community') {
+ $quotatype = 'community';
+ } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.instcode'}) {
+ $quotatype = 'official';
+ }
+ if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
+ $filesize = int($filesize/1000); #expressed in kb
+ $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course',
+ $env{'form.uploaddoc.filename'},$filesize,'upload');
+ return if ($$upload_output);
+ }
my ($parseaction,$showupload,$nextphase,$mimetype);
if ($env{'form.parserflag'}) {
$parseaction = 'parse';
@@ -3122,11 +3469,9 @@ ENDREM
push(@{$filtersref->{'canremove'}},$orderidx);
}
}
- unless ($isexternal) {
- $renamelink=(<'. + &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').' '. + '
@@ -3259,7 +3604,7 @@ $form_common."\n".
push(@{$filtersref->{'randomorder'}},$orderidx);
}
}
- my $formname = 'edit_rorder_'.$orderidx;
+ $formname = 'edit_rorder_'.$orderidx;
$rand_order_text =
' ';
}
@@ -3650,8 +3996,8 @@ sub list_symbs {
sub verifycontent {
my ($r) = @_;
my $crstype = &Apache::loncommon::course_type();
- $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Documents'));
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Documents'));
+ $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
$r->print(&startContentScreen('tools'));
$r->print(''.&mt($crstype.' content verification').''); $hashtied=0; @@ -3687,8 +4033,8 @@ sub devalidateversioncache { sub checkversions { my ($r) = @_; 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")); + $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions")); + $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions")); $r->print(&startContentScreen('tools')); my $header=''; @@ -3753,7 +4099,7 @@ sub checkversions { &changewarning($r,''); if ($env{'form.timerange'} eq 'all') { # show all documents - $header=&mt('All Documents in '.$crstype); + $header=&mt('All content in '.$crstype); $allsel=' selected="selected"'; foreach my $key (keys(%hash)) { if ($key=~/^ids\_(\/res\/.+)$/) { @@ -3844,10 +4190,30 @@ $lt{'sc'}:$lt{'vers'}- ENDHEADERS #number of columns for version history + my %changedbytime; + foreach my $key (keys(%changes)) { + #excludes not versionable problems from resource version history: + next if ($key =~ /^\/res\/lib\/templates/); + my $chg; + if ($env{'form.timerange'} eq 'all') { + my ($root,$extension)=($key=~/^(.*)\.(\w+)$/); + $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate'); + } else { + $chg = $changes{$key}; + next if ($chg < $starttime); + } + push(@{$changedbytime{$chg}},$key); + } + if (keys(%changedbytime) == 0) { + &untiehash(); + $r->print(&mt('No content changes in imported content in specified time frame'). + &endContentScreen()); + return; + } $r->print( + ''. &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). ''.&mt('Resources').' | '.
@@ -3857,26 +4223,25 @@ ENDHEADERS
''.&mt('History').' | '.
&Apache::loncommon::end_data_table_header_row()
);
- foreach my $key (sort(keys(%changes))) {
- #excludes not versionable problems from resource version history:
- next unless ($changes{$key}>$starttime && $key !~ /^\/res\/lib\/templates/);
- my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
- my $currentversion=&Apache::lonnet::getversion($key);
- if ($currentversion<0) {
- $currentversion=''.&mt('Could not be determined.').'';
- }
- my $linkurl=&Apache::lonnet::clutter($key);
- $r->print(
- &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')) {
+ foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) {
+ foreach my $key (sort(@{$changedbytime{$chg}})) {
+ my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
+ my $currentversion=&Apache::lonnet::getversion($key);
+ if ($currentversion<0) {
+ $currentversion=''.&mt('Could not be determined.').'';
+ }
+ my $linkurl=&Apache::lonnet::clutter($key);
+ $r->print(
+ &Apache::loncommon::start_data_table_row().
+ ' | '.&Apache::lonnet::gettitle($linkurl).' | '.
+ ''. + ''.$linkurl.' '.$currentversion.' | '.
+ '('. + &Apache::lonlocal::locallocaltime($chg).') '
+ );
+ # Used in course
+ my $usedversion=$hash{'version_'.$linkurl};
+ if (($usedversion) && ($usedversion ne 'mostrecent')) {
if ($usedversion != $currentversion) {
$r->print(''.$usedversion.'');
} else {
@@ -3885,44 +4250,45 @@ ENDHEADERS
} else {
$r->print($currentversion);
}
- $r->print(' | ');
- # Set version
- $r->print(&Apache::loncommon::select_form(
- $setversions{$linkurl},
- 'set_version_'.$linkurl,
- {'select_form_order' => ['',1..$currentversion,'mostrecent'],
- '' => '',
- 'mostrecent' => &mt('most recent'),
- map {$_,$_} (1..$currentversion)}));
- my $lastold=1;
- for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
- my $url=$root.'.'.$prevvers.'.'.$extension;
- if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
- $lastold=$prevvers;
- }
- }
- $r->print(' | ');
- # List all available versions
- $r->print('');
- for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
- my $url=$root.'.'.$prevvers.'.'.$extension;
- $r->print(
- ''
- .''
- .&mt('Version [_1]',$prevvers).''
- .' ('.&Apache::lonlocal::locallocaltime(
- &Apache::lonnet::metadata($url,'lastrevisiondate'))
- .')');
- if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
+ $r->print(' | ');
+ # Set version
+ $r->print(&Apache::loncommon::select_form(
+ $setversions{$linkurl},
+ 'set_version_'.$linkurl,
+ {'select_form_order' => ['',1..$currentversion,'mostrecent'],
+ '' => '',
+ 'mostrecent' => &mt('most recent'),
+ map {$_,$_} (1..$currentversion)}));
+ my $lastold=1;
+ for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
+ my $url=$root.'.'.$prevvers.'.'.$extension;
+ if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
+ $lastold=$prevvers;
+ }
+ }
+ $r->print(' | ');
+ # List all available versions
+ $r->print('');
+ for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
+ my $url=$root.'.'.$prevvers.'.'.$extension;
$r->print(
- ' &').
- '" target="diffs">'.&mt('Diffs').'');
+ ''
+ .''
+ .&mt('Version [_1]',$prevvers).''
+ .' ('.&Apache::lonlocal::locallocaltime(
+ &Apache::lonnet::metadata($url,'lastrevisiondate'))
+ .')');
+ if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
+ $r->print(
+ ' &').
+ '" target="diffs">'.&mt('Diffs').'');
+ }
+ $r->print(' | '.&Apache::loncommon::end_data_table_row());
}
- $r->print(''); } - $r->print(' '); + $r->print(' | '.&Apache::loncommon::end_data_table_row());
}
$r->print(
&Apache::loncommon::end_data_table().
@@ -3932,6 +4298,7 @@ ENDHEADERS
&untiehash();
$r->print(&endContentScreen());
+ return;
}
sub mark_hash_old {
@@ -3986,13 +4353,13 @@ $help{'Caching'}.''."\n\n");
sub init_breadcrumbs {
- my ($form,$text)=@_;
+ my ($form,$text,$help)=@_;
&Apache::lonhtmlcommon::clear_breadcrumbs();
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
text=>&Apache::loncommon::course_type().' Editor',
faq=>273,
bug=>'Instructor Interface',
- help => 'Docs_Adding_Course_Doc'});
+ help => $help});
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
text=>$text,
faq=>273,
@@ -4031,7 +4398,7 @@ sub startContentScreen {
$output .= '