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

banghart lon-capa-cvs@mail.lon-capa.org
Tue, 27 Jul 2004 05:29:01 -0000


banghart		Tue Jul 27 01:29:01 2004 EDT

  Modified files:              
    /loncom/interface	portfolio.pm 
  Log:
  
  	Still full of debug code, (and not yet functional) but showing 
  	entire directory structure from /userfiles/portfolio on down 
  	(recursively), with path information appended to array elements
  	returned by lonnet::dirlist
  	To do: combine returned directory array with user display prefs
  		to allow navigation of directory struture 
  
  
  
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.16 loncom/interface/portfolio.pm:1.17
--- loncom/interface/portfolio.pm:1.16	Thu Jul 22 21:25:56 2004
+++ loncom/interface/portfolio.pm	Tue Jul 27 01:29:00 2004
@@ -56,14 +56,14 @@
             $upPath = $1;
         }
         
-        $displayOut = $displayOut.'<a href="/adm/portfolio?selectfile='.$upPath.'&currentpath='.$upPath.'">..</a><br />';
+        # $displayOut = $displayOut.'<a href="/adm/portfolio?selectfile='.$upPath.'&currentpath='.$upPath.'">..</a><br />';
     } else {
-        $displayOut = $displayOut.'at root '.$currentPath.'<br />';
+        # $displayOut = $displayOut.'at root '.$currentPath.'<br />';
     }
     foreach my $line (@dirList) {
     	#$strip holds directory/file name
     	#$dom 
-    	my ($fileName,$dom,undef,$testdir,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,$obs,undef,$path)=split(/\&/,$line,17); 
+    	my ($fileName,$dom,undef,$testdir,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,$obs,undef,$path,$debug)=split(/\&/,$line,18); 
     	$path =~ m:/:;
     	my $dirDepth = @-;
         if (($fileName ne '.') && ($fileName ne '..')){
@@ -73,15 +73,15 @@
             if ($testdir =~ m:^1:){
                 # handle directories different from files
                 if ($fileName eq $currentFile){ #checks to bold the selected file
-                    $displayOut.= '<strong>'.(makeAnchor($fileName.'/', $path.$fileName.'/').'</strong><br />'."\n");
+                    $displayOut.= $debug.'<strong>'.(makeAnchor($fileName.'/', $path.$fileName.'/').'</strong><br />'."\n");
                 }else{
-                    $displayOut.= (makeAnchor($fileName.'/', $path.$fileName.'/').'<br />'."\n");
+                    $displayOut.= $debug.(makeAnchor($fileName.'/', $path.$fileName.'/').'<br />'."\n");
                 }
             }else{
                 if ($fileName eq $currentFile){ #checks to bold the selected file
-                    $displayOut.='<strong>'.(makeAnchor($fileName, $currentPath).'</strong><br />'."\n");
+                    $displayOut.=$debug.'<strong>'.(makeAnchor($fileName, $currentPath).'</strong><br />'."\n");
                 }else{
-                    $displayOut.=(makeAnchor($fileName, $currentPath).'<br />'."\n");
+                    $displayOut.=$debug.(makeAnchor($fileName, $currentPath).'<br />'."\n");
                 }
             }
         	for (my $i = 0; $i <= $dirDepth; $i += 1){
@@ -243,22 +243,29 @@
         if ($readDirectory){ # is true the first time through, then true if dirlist line is a subdir
             # $r->print('<br />reading '.$portfolio_root.$subdir);
             my @list = &Apache::lonnet::dirlist($currentPath,  $ENV{'user.domain'}, $ENV{'user.name'}, $portfolio_root.$subdir);
-            foreach my $line(@list){
-                $line = $line.'&'.$subdir; # append the subdirectory information
+            $r->print('value in @list = '.@list);
+            for (my $i = 0; $i <= @list; $i++ ){
+                my $line = pop @list;
+                $line = $line.'&'.$subdir.'&'.$loopCounter; # append the subdirectory information and loopcounter for debug
                 my ($fileName,$dom,undef,$testdir,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,$obs,undef,$subpath)=split(/\&/,$line,17); 
                 if (($fileName ne '.') && ($fileName ne '..')){ # we throw away the current and parent directories
-                    $r->print('<br />'.$line);
-                    # should this be shift?
-                    push @workinglist, $line; # add the line to the working list array
+                    $r->print('<br />'.$line); #for debugging
+                    unshift @workinglist, $line; # add the line to the working list array
+                    
+                }else{
+                    $r->print('<br /> parent or current '.$line); #for debugging
                 }
             }
         }
+        $r->print('<br />'.@workinglist.' lines in workinglist');
         my $line = shift @workinglist; #take one off the working list
+        $r->print('<br />'.@workinglist.' lines in workinglist');
         if ($line eq '') { # if the working list is empty
             $done = 1;
         }else{
+            my ($fileName,$dom,undef,$testdir,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,$obs,undef,$subpath,$debug)=split(/\&/,$line,18); 
+            $r->print('<br />'.$fileName.' is '.$testdir);
             push @dirList, $line; # and put it in the display list
-            my ($fileName,$dom,undef,$testdir,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,$obs,undef,$subpath)=split(/\&/,$line,17); 
             if ($testdir =~ m:^1:) { # true if this is a directory
                 # $r->print('<br />added subdir '.$fileName);
                 $subdir = $subpath.'/'.$fileName;