--- loncom/interface/londocs.pm 2003/10/28 00:31:02 1.89 +++ loncom/interface/londocs.pm 2003/12/30 20:47:23 1.97 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.89 2003/10/28 00:31:02 www Exp $ +# $Id: londocs.pm,v 1.97 2003/12/30 20:47:23 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -402,33 +402,34 @@ sub entryline { $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 my ($extension)=($url=~/\.(\w+)$/); my $uploaded=($url=~/^\/*uploaded\//); - my $icon='unknown'; - if (-e "/home/httpd/html/adm/lonIcons/$extension.gif") { - $icon=$extension; - } + my $icon=&Apache::loncommon::icon($url); my $isfolder=0; if ($uploaded) { if ($extension eq 'sequence') { - $icon='folder_closed'; + $icon=$iconpath.'/folder_closed.gif'; $url=~/\/(\w+)\.sequence/; $url='/adm/coursedocs?folder='.$1; $isfolder=1; @@ -450,8 +451,7 @@ END if ($isfolder) { $url.='&foldername='. &Apache::lonnet::escape($foldertitle); } $line.=''. + '">'. "$title"; return $line; } @@ -506,6 +506,7 @@ sub checkonthis { &Apache::lonxml::xmlparse($r,'web', &Apache::lonnet::getfile( &Apache::lonnet::filelocation('',$url))); + undef($Apache::lonhomework::parsing_a_problem); $ENV{'request.filename'}=$oldpath; if (($Apache::lonxml::errorcount) || ($Apache::lonxml::warningcount)) { @@ -572,8 +573,6 @@ sub checkversions { my $r=shift; $r->print('Check Versions'. &Apache::loncommon::bodytag('Check Course Document Versions')); - $hashtied=0; - &tiehash(); my $header=''; my $startsel=''; my $monthsel=''; @@ -582,9 +581,63 @@ sub checkversions { my $allsel=''; my %changes=(); my $starttime=0; + my $haschanged=0; + my %setversions=&Apache::lonnet::dump('resourceversions', + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + + $hashtied=0; + &tiehash(); + my %newsetversions=(); + if ($ENV{'form.setmostrecent'}) { + $haschanged=1; + foreach (keys %hash) { + if ($_=~/^ids\_(\/res\/.+)$/) { + $newsetversions{$1}='mostrecent'; + } + } + } elsif ($ENV{'form.setcurrent'}) { + $haschanged=1; + foreach (keys %hash) { + if ($_=~/^ids\_(\/res\/.+)$/) { + my $getvers=&Apache::lonnet::getversion($1); + if ($getvers>0) { + $newsetversions{$1}=$getvers; + } + } + } + } elsif ($ENV{'form.setversions'}) { + $haschanged=1; + foreach (keys %ENV) { + if ($_=~/^form\.set_version_(.+)$/) { + my $src=$1; + &Apache::lonnet::logthis('Found: '.$1.' '.$ENV{$_}); + if (($ENV{$_}) && ($ENV{$_} ne $setversions{$src})) { + $newsetversions{$src}=$ENV{$_}; + } + } + } + } + if ($haschanged) { + if (&Apache::lonnet::put('resourceversions',\%newsetversions, + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}) eq 'ok') { + $r->print('

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

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

'.&mt('An Error Occured while Attempting to Store your Version Settings').'

'); + } + &changewarning($r,''); + } 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 @@ -618,21 +671,30 @@ sub checkversions { $header=&mt('No content modifications yet.'); } } + %setversions=&Apache::lonnet::dump('resourceversions', + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); my %lt=&Apache::lonlocal::texthash ('st' => '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', + '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', + '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(< + + +
- - +

$header

+ ENDHEADERS - foreach (keys %changes) { + foreach (sort keys %changes) { if ($changes{$_}>$starttime) { my ($root,$extension)=($_=~/^(.*)\.(\w+)$/); my $currentversion=&Apache::lonnet::getversion($_); + if ($currentversion<0) { + $currentversion=&mt('Could not be determined.'); + } my $linkurl=&Apache::lonnet::clutter($_); $r->print( - ''); + $r->print(''); } } - $r->print('
$lt{'fi'}$lt{'md'}$lt{'mr'} $lt{'ve'}$lt{'vu'}$lt{'di'}
'.$linkurl. + '
'. + &Apache::lonnet::gettitle($linkurl). + '
'.$linkurl. '
'. &Apache::lonlocal::locallocaltime($changes{$_}). ''. $currentversion.''); # Used in course my $usedversion=$hash{'version_'.$linkurl}; - if ($usedversion) { + if (($usedversion) && ($usedversion ne 'mostrecent')) { $r->print($usedversion); } else { $r->print($currentversion); } $r->print(''); # Set version - $r->print(&Apache::loncommon::select_form($usedversion, + $r->print(&Apache::loncommon::select_form($setversions{$linkurl}, 'set_version_'.$linkurl, ('' => '', - 'current' => 'current', + 'mostrecent' => 'most recent', map {$_,$_} (1..$currentversion)))); - $r->print(''); + $r->print('
    '); my $lastold=1; for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { my $url=$root.'.'.$prevvers.'.'.$extension; @@ -684,27 +751,40 @@ ENDHEADERS } for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) { my $url=$root.'.'.$prevvers.'.'.$extension; - $r->print(''.&mt('Version').' '.$prevvers.' ('. + $r->print('
  • '.&mt('Version').' '.$prevvers.' ('. &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($url,'lastrevisiondate')). - ')'); + ')'); if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') { $r->print(' '.&mt('Diffs').''); } - $r->print('
    '); + $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 sub handler { my $r = shift; @@ -712,7 +792,6 @@ sub handler { $r->send_http_header; return OK if $r->header_only; - &Apache::lonlocal::clearreroutetrans(); # --------------------------------------------- Initialize help topics for this foreach ('Adding_Course_Doc','Main_Course_Documents', 'Adding_External_Resource','Navigate_Content', @@ -904,7 +983,10 @@ ENDNEWSCRIPT 'sipr' => 'Simple Problem', 'scuf' => 'Score Upload Form', 'bull' => 'Bulletin Board', - 'mypi' => 'My Personal Info' + 'mypi' => 'My Personal Info', + 'file' => 'File', + 'title' => 'Title', + 'comment' => 'Comment' ); # ----------------------------------------------------------------------------- if ($allowed) { @@ -934,7 +1016,7 @@ $dumpbut ENDCOURSEVERIFY $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc', - 'Editing the Table of Contents for your Course')); + &mt('Editing the Table of Contents for your Course'))); } # --------------------------------------------------------- Standard documents $r->print(''); @@ -952,15 +1034,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'; @@ -971,11 +1045,11 @@ $help{'Caching'}.'');
$lt{'spec'}
-File:
+$lt{'file'}:

-Title:
+$lt{'title'}:
@@ -1121,7 +1195,7 @@ ENDFORM
-
Comment:
+
$lt{'comment'}:
@@ -1207,7 +1281,7 @@ ENDSUPFORM &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'

'); } } - $r->print(&Apache::lonlocal::endreroutetrans().''); + $r->print(''); return OK; }