[LON-CAPA-cvs] cvs: loncom /interface londocs.pm

www lon-capa-cvs@mail.lon-capa.org
Tue, 28 Oct 2003 00:31:02 -0000


This is a MIME encoded message

--www1067301062
Content-Type: text/plain

www		Mon Oct 27 19:31:02 2003 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  Work on screen to set resource versions.
  
  
--www1067301062
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20031027193102.txt"

Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.88 loncom/interface/londocs.pm:1.89
--- loncom/interface/londocs.pm:1.88	Wed Oct 22 17:41:11 2003
+++ loncom/interface/londocs.pm	Mon Oct 27 19:31:02 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.88 2003/10/22 21:41:11 www Exp $
+# $Id: londocs.pm,v 1.89 2003/10/28 00:31:02 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -570,58 +570,68 @@
 
 sub checkversions {
     my $r=shift;
-   $r->print('<html><head><title>Check Versions</title></head>'.
+    $r->print('<html><head><title>Check Versions</title></head>'.
               &Apache::loncommon::bodytag('Check Course Document Versions'));
-   $hashtied=0;
-   &tiehash();
-   my %changes=&Apache::lonnet::dump
-    ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+    $hashtied=0;
+    &tiehash();
+    my $header='';
+    my $startsel='';
+    my $monthsel='';
+    my $weeksel='';
+    my $daysel='';
+    my $allsel='';
+    my %changes=();
+    my $starttime=0;
+    if ($ENV{'form.timerange'} eq 'all') {
+# show all documents
+	$header=&mt('All Documents in Course');
+    } 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=&mt('during the last').' '.$ENV{'form.timerange'}.' '
-	   .&mt('seconds');
-       my $startsel='';
-       my $monthsel='';
-       my $weeksel='';
-       my $daysel='';
-       my $allsel='';
-       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=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
-           $monthsel='selected';
-       } elsif ($ENV{'form.timerange'}==604800) {
-           $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
-           $weeksel='selected';
-       } elsif ($ENV{'form.timerange'}==86400) {
-           $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
-           $daysel='selected';
-       } elsif ($ENV{'form.timerange'} eq 'all') {
-	   $allsel='all';
-       }
-       my %lt=&Apache::lonlocal::texthash
+	my $firstkey=(keys %changes)[0];
+	unless ($firstkey=~/^error\:/) {
+	    unless ($ENV{'form.timerange'}) {
+		$ENV{'form.timerange'}=604800;
+	    }
+	    my $seltext=&mt('during the last').' '.$ENV{'form.timerange'}.' '
+		.&mt('seconds');
+	    if ($ENV{'form.timerange'}==-1) {
+		$seltext='since start of course';
+		$startsel='selected';
+		$ENV{'form.timerange'}=time;
+	    }
+	    $starttime=time-$ENV{'form.timerange'};
+	    if ($ENV{'form.timerange'}==2592000) {
+		$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
+		$monthsel='selected';
+	    } elsif ($ENV{'form.timerange'}==604800) {
+		$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
+		$weeksel='selected';
+	    } elsif ($ENV{'form.timerange'}==86400) {
+		$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
+		$daysel='selected';
+	    }
+	    $header=&mt('Content changed').' '.$seltext;
+	} else {
+	    $header=&mt('No content modifications yet.');
+	}
+    }
+    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',
 	       'sd' => 'Display',
-               'cc' => 'Content changed',
 	       'fi' => 'File',
 	       'md' => 'Modification Date',
                'mr' => 'Most recently published Version',
 	       've' => 'Version used in Course',
                'vu' => 'Set Version to be used in Course', 
 	       'di' => 'Differences');
-       $r->print(<<ENDHEADERS);
+    $r->print(<<ENDHEADERS);
 <form action="/adm/coursedocs" method="post">
 <select name="timerange">
 <option value='all' $allsel>$lt{'al'}</option>
@@ -632,69 +642,67 @@
 </select>
 <input type="submit" name="versions" value="$lt{'sd'}" />
 </form>
-<h3>$lt{'cc'} $seltext</h3>
+<h3>$header</h3>
 <table border="2">
 <tr>
 <th>$lt{'fi'}</th><th>$lt{'md'}</th><th>$lt{'mr'}</th>
 <th>$lt{'ve'}</th><th>$lt{'vu'}</th><th>$lt{'di'}</th></tr>
 ENDHEADERS
-       foreach (keys %changes) {
-	  if ($changes{$_}>$starttime) {
-	     my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
-             my $currentversion=&Apache::lonnet::getversion($_);
-             my $linkurl=&Apache::lonnet::clutter($_);
-             $r->print(
-                 '<tr><td><a href="'.$linkurl.'" target="cat">'.$linkurl.
-                 '</a></td><td>'.
-                 &Apache::lonlocal::locallocaltime($changes{$_}).
+    foreach (keys %changes) {
+	if ($changes{$_}>$starttime) {
+	    my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
+	    my $currentversion=&Apache::lonnet::getversion($_);
+	    my $linkurl=&Apache::lonnet::clutter($_);
+	    $r->print(
+		      '<tr><td><a href="'.$linkurl.'" target="cat">'.$linkurl.
+		      '</a></td><td>'.
+		      &Apache::lonlocal::locallocaltime($changes{$_}).
                       '</td><td><font size="+2">'.
-		       $currentversion.'</font></td><td><font size="+2">');
+		      $currentversion.'</font></td><td><font size="+2">');
 # Used in course
-	     my $usedversion=$hash{'version_'.$linkurl};
-	     if ($usedversion) {
-		 $r->print($usedversion);
-	     } else {
-		 $r->print($currentversion);
-	     }
-	     $r->print('</font></td><td>');
+	    my $usedversion=$hash{'version_'.$linkurl};
+	    if ($usedversion) {
+		$r->print($usedversion);
+	    } else {
+		$r->print($currentversion);
+	    }
+	    $r->print('</font></td><td>');
 # Set version
-	     $r->print(&Apache::loncommon::select_form($usedversion,
-						       'set_version_'.$linkurl,
-                               ('' => '',
-                              'current' => 'current',
-                               map {$_,$_} (1..$currentversion))));
-	     $r->print('</td><td>');
-             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(&Apache::loncommon::select_form($usedversion,
+						      'set_version_'.$linkurl,
+						      ('' => '',
+						       'current' => 'current',
+						       map {$_,$_} (1..$currentversion))));
+	    $r->print('</td><td>');
+	    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('<a href="'.&Apache::lonnet::clutter($url).
-                   '">'.&mt('Version').' '.$prevvers.' ('.
-                 &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($url,'lastrevisiondate')).
-                 ')</a>');
-                 if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
+		my $url=$root.'.'.$prevvers.'.'.$extension;
+		$r->print('<a href="'.&Apache::lonnet::clutter($url).
+			  '">'.&mt('Version').' '.$prevvers.' ('.
+			  &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($url,'lastrevisiondate')).
+			  ')</a>');
+		if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
                     $r->print(' <a href="/adm/diff?filename='.
-                            &Apache::lonnet::clutter($root.'.'.$extension).
-                            '&versionone='.$prevvers.
-			     '">'.&mt('Diffs').'</a>');
-                 }
-                 $r->print('<br />');
-             }
-             $r->print('</td></tr>');
-          }
-       }
-       $r->print('</table>');
-       $r->print('<h1>'.&mt('Done').'.</h1>');
-   } else {
-       $r->print('<p>'.&mt('No content modifications yet.').'</p>');
-   }
-   &untiehash();
+			      &Apache::lonnet::clutter($root.'.'.$extension).
+			      '&versionone='.$prevvers.
+			      '">'.&mt('Diffs').'</a>');
+		}
+		$r->print('<br />');
+	    }
+	    $r->print('</td></tr>');
+	}
+    }
+    $r->print('</table>');
+    $r->print('<h1>'.&mt('Done').'.</h1>');
+
+    &untiehash();
 }
 
 # ================================================================ Main Handler

--www1067301062--