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

banghart lon-capa-cvs@mail.lon-capa.org
Sun, 30 Jul 2006 19:38:14 -0000


banghart		Sun Jul 30 15:38:14 2006 EDT

  Modified files:              
    /loncom/interface	portfolio.pm 
  Log:
  	Can now see versioned files. Still need to make the display
  	more honest. 
  
  
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.139 loncom/interface/portfolio.pm:1.140
--- loncom/interface/portfolio.pm:1.139	Wed Jul 19 17:58:16 2006
+++ loncom/interface/portfolio.pm	Sun Jul 30 15:38:13 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # portfolio browser
 #
-# $Id: portfolio.pm,v 1.139 2006/07/19 21:58:16 albertel Exp $
+# $Id: portfolio.pm,v 1.140 2006/07/30 19:38:13 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -149,7 +149,7 @@
 sub display_directory_line {
     my ($r,$select_mode,$fullpath, $filename, $mtime, $size, $css_class,
 	$line, $access_controls, $curr_access, $now, $version_flag,
-	$href_location, $url, $current_path, $access_admin_text)=@_;
+	$href_location, $url, $current_path, $access_admin_text, $versions)=@_;
     # my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); 
     $r->print('<tr class="'.$css_class.'">');
     $r->print($line);
@@ -221,7 +221,7 @@
     my @dir_lines;
     my @version_lines;
     my %versioned;
-    foreach my $line (sort 
+    foreach my $dir_line (sort 
 		      { 
 			  my ($afile)=split('&',$a,2);
 			  my ($bfile)=split('&',$b,2);
@@ -229,7 +229,7 @@
 		      } (@$dir_list)) {
     	#$strip holds directory/file name
     	#$dom 
-    	my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); 
+    	my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16); 
     	$filename =~ s/\s+$//;
     	my ($fname,$version,$extension) = &Apache::grades::file_name_version_ext($filename);
     	if ($version) {
@@ -239,8 +239,8 @@
     	    push(@dir_lines, [$filename,$dom,$testdir,$size,$mtime,$obs]);
     	}
     }
-    foreach my $line (@dir_lines) {
-        my ($filename,$dom,$testdir,$size,$mtime,$obs) = @$line;
+    foreach my $dir_line (@dir_lines) {
+        my ($filename,$dom,$testdir,$size,$mtime,$obs) = @$dir_line;
         my ($fname,$version,$extension) = &Apache::grades::file_name_version_ext($filename);
     	if (($filename ne '.') && ($filename ne '..') && ($filename !~ /\.meta$/ ) && ($filename !~ /(.*)\.(\d+)\.([^\.]*)$/)) {
     	    my %version_flag;
@@ -332,27 +332,19 @@
 			$curr_access = join('+ ',@allaccesses);
 		    }
 		}
-                &display_directory_line($r,$select_mode,$fullpath, $filename, $mtime, $size, $css_class, $line, \%access_controls, $curr_access,
-                        $now, \%version_flag, $href_location, $url, $current_path, $access_admin_text);
-#		$r->print('<tr class="'.$css_class.'">');
-#		$r->print($line);
-#		$r->print('<td><img alt="" src="'.&Apache::loncommon::icon($filename).'" /></td>');
-#		$r->print('<td>'.$version_flag{$filename}.'<a href="'.$href_location.$filename.'">'.
-#			  $filename.'</a></td>'); 
-#		$r->print('<td>'.$size.'</td>');
-#		$r->print('<td>'.&Apache::lonlocal::locallocaltime($mtime).'</td>');
-#		if ($select_mode ne 'true') {
-#		    $r->print('<td><span style="white-space: nowrap">'.
-#			      &mt($curr_access).'&nbsp;&nbsp;&nbsp;');
-#		    $r->print('<a href="'.$url.'?access='.$filename.
-#			      '&amp;currentpath='.$current_path.&group_args().
-#			      '">'.$access_admin_text.'</a></span></td>');
-#		}
-#		$r->print('</tr>'.$/);
+                &display_directory_line($r,$select_mode,$fullpath, $filename, $mtime, $size, $css_class, $line, 
+                                        \%access_controls, $curr_access,$now, \%version_flag, $href_location, 
+                                        $url, $current_path, $access_admin_text);
 		if ($show_versions) {
-		    &display_directory_line($r,$select_mode,$fullpath, $css_class, $line, \%access_controls, 
-                        $now, \%version_flag, $href_location, $url, $current_path, $access_admin_text);
-
+		    foreach my $dir_line (@version_lines) {
+		        my ($v_filename,$dom,$testdir,$size,$mtime,$obs) = @$dir_line;
+                        my ($v_fname,$version,$v_extension) = &Apache::grades::file_name_version_ext($v_filename);
+                        if (($v_fname eq $fname)&&($v_extension eq $extension)) {
+		            &display_directory_line($r,$select_mode,$fullpath, $v_filename, $mtime, $size, 
+		                            $css_class, $line, \%access_controls, $curr_access, $now,
+		                             \%version_flag, $href_location, $url, $current_path, $access_admin_text, 1);
+		        }
+		    }
 		}
             }
         }