--- loncom/interface/londocs.pm 2003/09/21 21:40:06 1.82 +++ loncom/interface/londocs.pm 2003/10/28 21:50:02 1.91 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.82 2003/09/21 21:40:06 www Exp $ +# $Id: londocs.pm,v 1.91 2003/10/28 21:50:02 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -138,7 +138,7 @@ sub dumpcourse { # Do the dumping unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; } my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'}); - $r->print('

Copying Files

'); + $r->print('

'.&mt('Copying Files').'

'); my $title=$ENV{'form.authorfolder'}; $title=~s/[^\w\/]+/\_/g; my %replacehash=(); @@ -395,27 +395,31 @@ sub entryline { ) { $foldertitle=&Apache::lontexconvert::msgtexconverted($4); $renametitle=$4; - $title=''.localtime($1).' '. - &Apache::loncommon::plainname($2,$3).':
'. + $title=''.&Apache::lonlocal::locallocaltime($1).' '. + &Apache::loncommon::plainname($2,$3).':
'. $foldertitle; } $renametitle=~s/\"\;/\\\"/g; my $line=''; # Edit commands - if ($allowed) { - $line.=(< 'Move Up', + 'dw' => 'Move Down', + 'rm' => 'Remove', + 'rn' => 'Rename'); + $line.=(< +$lt{ +$lt{
-UP
-DOWN
-Remove +$lt{'rm'} -Rename +$lt{'rn'} END } # Figure out what kind of a resource this is @@ -490,7 +494,7 @@ sub checkonthis { my $result=&Apache::lonnet::repcopy( &Apache::lonnet::filelocation('',$url)); if ($result==OK) { - $r->print('ok'); + $r->print(''.&mt('ok').''); $r->rflush(); &Apache::lonnet::countacc($url); $url=~/\.(\w+)$/; @@ -500,7 +504,7 @@ sub checkonthis { for (my $i=0;$i<=$level*5;$i++) { $r->print(' '); } - $r->print('- Rendering: '); + $r->print('- '.&mt('Rendering').': '); my $oldpath=$ENV{'request.filename'}; $ENV{'request.filename'}=&Apache::lonnet::filelocation('',$url); &Apache::lonxml::xmlparse($r,'web', @@ -511,14 +515,16 @@ sub checkonthis { ($Apache::lonxml::warningcount)) { if ($Apache::lonxml::errorcount) { $r->print(''. - $Apache::lonxml::errorcount.' error(s) '); + $Apache::lonxml::errorcount.' '. + &mt('error(s)').' '); } if ($Apache::lonxml::warningcount) { $r->print(''. - $Apache::lonxml::warningcount.' warning(s)'); + $Apache::lonxml::warningcount.' '. + &mt('warning(s)').''); } } else { - $r->print('ok'); + $r->print(''.&mt('ok').''); } $r->rflush(); } @@ -530,11 +536,11 @@ sub checkonthis { } } } elsif ($result==HTTP_SERVICE_UNAVAILABLE) { - $r->print('connection down'); + $r->print(''.&mt('connection down').''); } elsif ($result==HTTP_NOT_FOUND) { - $r->print('not found'); + $r->print(''.&mt('not found').''); } else { - $r->print('access denied'); + $r->print(''.&mt('access denied').''); } } } @@ -568,97 +574,181 @@ sub verifycontent { sub checkversions { my $r=shift; - $r->print('Check Versions'. + $r->print('Check Versions'. &Apache::loncommon::bodytag('Check Course Document Versions')); - $hashtied=0; - &tiehash(); - my %changes=&Apache::lonnet::dump - ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + my $header=''; + my $startsel=''; + my $monthsel=''; + my $weeksel=''; + my $daysel=''; + my $allsel=''; + my %changes=(); + my $starttime=0; + my $haschanged=0; + if ($ENV{'form.setmostrecent'}) { + $haschanged=1; + } elsif ($ENV{'form.setcurrent'}) { + $haschanged=1; + } elsif ($ENV{'form.setversions'}) { + $haschanged=1; + } + if ($haschanged) { + $r->print('

'.&mt('Your Version Settings have been Stored').'

'); + &changewarning($r,''); + return; + } + $hashtied=0; + &tiehash(); + if ($ENV{'form.timerange'} eq 'all') { +# show all documents + $header=&mt('All Documents in Course'); + $allsel=1; + foreach (keys %hash) { + if ($_=~/^ids\_(\/res\/.+)$/) { + my $src=$1; + $changes{$src}=1; + } + } + } else { +# show documents which changed + %changes=&Apache::lonnet::dump + ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); - my $firstkey=(keys %changes)[0]; - unless ($firstkey=~/^error\:/) { - unless ($ENV{'form.timerange'}) { - $ENV{'form.timerange'}=604800; - } - my $seltext='during the last '.$ENV{'form.timerange'}.' seconds'; - my $startsel=''; - my $monthsel=''; - my $weeksel=''; - my $daysel=''; - if ($ENV{'form.timerange'}==-1) { - $seltext='since start of course'; - $startsel='selected'; - $ENV{'form.timerange'}=time; - } - my $starttime=time-$ENV{'form.timerange'}; - if ($ENV{'form.timerange'}==2592000) { - $seltext='during the last month ('.localtime($starttime).')'; - $monthsel='selected'; - } elsif ($ENV{'form.timerange'}==604800) { - $seltext='during the last week ('.localtime($starttime).')'; - $weeksel='selected'; - } elsif ($ENV{'form.timerange'}==86400) { - $seltext='since yesterday ('.localtime($starttime).')'; - $daysel='selected'; - } - - $r->print(< 'Version changes since start of Course', + 'lm' => 'Version changes since last Month', + 'lw' => 'Version changes since last Week', + 'sy' => 'Version changes since Yesterday', + 'al' => 'All Resources (possibly large output)', + 'sd' => 'Display', + 'fi' => 'File', + 'md' => 'Modification Date', + 'mr' => 'Most recently published Version', + 've' => 'Version used in Course', + 'vu' => 'Set Version to be used in Course', +'sv' => 'Set Versions to be used in Course according to Selections below', +'sm' => 'Keep all Resources up-to-date with most recent Versions (default)', +'sc' => 'Set all Resource Versions to current Version (Fix Versions)', + 'di' => 'Differences'); + $r->print(< + + +
- + -

Content changed $seltext

+

$header

+ - - + + ENDHEADERS - foreach (keys %changes) { - if ($changes{$_}>$starttime) { - my ($root,$extension)=($_=~/^(.*)\.(\w+)$/); - my $currentversion=&Apache::lonnet::getversion($_); - my $linkurl=&Apache::lonnet::clutter($_); - $r->print( - ''. - ''); - } - } - $r->print('
FileModification DateVersionDifferences
$lt{'fi'}$lt{'md'}$lt{'mr'}$lt{'ve'}$lt{'vu'}$lt{'di'}
'.$linkurl. - ''. - localtime($changes{$_}).''.$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; - } - } + foreach (sort keys %changes) { + if ($changes{$_}>$starttime) { + my ($root,$extension)=($_=~/^(.*)\.(\w+)$/); + my $currentversion=&Apache::lonnet::getversion($_); + my $linkurl=&Apache::lonnet::clutter($_); + $r->print( + '
'. + &Apache::lonnet::gettitle($linkurl). + '
'.$linkurl. + '
'. + &Apache::lonlocal::locallocaltime($changes{$_}). + ''. + $currentversion.''); +# Used in course + my $usedversion=$hash{'version_'.$linkurl}; + if ($usedversion) { + $r->print($usedversion); + } else { + $r->print($currentversion); + } + $r->print(''); +# Set version + $r->print(&Apache::loncommon::select_form($usedversion, + 'set_version_'.$linkurl, + ('' => '', + 'current' => 'most recent', + map {$_,$_} (1..$currentversion)))); + $r->print('
    '); + my $lastold=1; + for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { + my $url=$root.'.'.$prevvers.'.'.$extension; + if (&Apache::lonnet::metadata($url,'lastrevisiondate')< + $starttime) { + $lastold=$prevvers; + } + } for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) { - my $url=$root.'.'.$prevvers.'.'.$extension; - $r->print('Version '.$prevvers.' ('. - localtime(&Apache::lonnet::metadata($url,'lastrevisiondate')). - ')'); - if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') { + my $url=$root.'.'.$prevvers.'.'.$extension; + $r->print('
  • '.&mt('Version').' '.$prevvers.' ('. + &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($url,'lastrevisiondate')). + ')'); + if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') { $r->print(' Diffs'); - } - $r->print('
    '); - } - $r->print('
'); - $r->print('

'.&mt('Done').'.

'); - } else { - $r->print('

'.&mt('No content modifications yet.').'

'); - } - &untiehash(); + &Apache::lonnet::clutter($root.'.'.$extension). + '&versionone='.$prevvers. + '">'.&mt('Diffs').''); + } + $r->print(''); + } + $r->print(''); + } + } + $r->print(''); + $r->print('

'.&mt('Done').'.

'); + + &untiehash(); +} + +sub changewarning { + my ($r,$postexec)=@_; + $r->print( +''. +'
'. +'

'. +&mt('Changes will become active for your current session after'). +' '.&mt(', or the next time you log in.'). +$help{'Caching'}.'

'); } # ================================================================ Main Handler @@ -682,6 +772,8 @@ sub handler { 'Docs_About_Syllabus,Docs_Editing_Templated_Pages'); $help{'Simple Page'} = &Apache::loncommon::help_open_topic( 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages'); + $help{'Simple Problem'} = &Apache::loncommon::help_open_topic( + 'Option_Response_Simple'); $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic( 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages'); $help{'My Personal Info'} = &Apache::loncommon::help_open_topic( @@ -863,6 +955,10 @@ ENDNEWSCRIPT # ----------------------------------------------------------------------------- if ($allowed) { my $dumpbut=&dumpbutton(); + my %lt=&Apache::lonlocal::texthash( + 'vc' => 'Verify Content', + 'cv' => 'Check/Set Resource Versions', + ); $r->print(< @@ -876,9 +972,9 @@ ENDNEWSCRIPT
- + - + $dumpbut
@@ -902,15 +998,7 @@ ENDCOURSEVERIFY $hadchanges=0; &editor($r,$coursenum,$coursedom,$folder,$allowed); if ($hadchanges) { - $r->print( -''. -'
'. -'

'. -&mt('Changes will become active for your current session after'). -' '.&mt(', or the next time you log in.'). -$help{'Caching'}.'

'); + &changewarning($r,$postexec); } my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. '.sequence'; @@ -1097,7 +1185,7 @@ ENDFORM +value="$lt{'selm'}">$help{'Load_Map'}