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

bowersj2 lon-capa-cvs@mail.lon-capa.org
Thu, 03 Oct 2002 19:40:33 -0000


bowersj2		Thu Oct  3 15:40:33 2002 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm 
  Log:
  Folders default to being closed, allowing us to save the time processing
  the non-showing information.
  
  Putting off displaying the current position because it's hard to find the 
  current position; I need to be able to scan up the maps backwards and I don't
  think I can do that with the data in the nav hash (not sure).
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.62 loncom/interface/lonnavmaps.pm:1.63
--- loncom/interface/lonnavmaps.pm:1.62	Thu Oct  3 15:10:28 2002
+++ loncom/interface/lonnavmaps.pm	Thu Oct  3 15:40:33 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.62 2002/10/03 19:10:28 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.63 2002/10/03 19:40:33 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -888,11 +888,19 @@
         }
     }
 
+    my $currenturl = $ENV{'form.postdata'};
+    $currenturl=~s/^http\:\/\///;
+    $currenturl=~s/^[^\/]+//;
+    my $queryAdd = "postdata=" . &Apache::lonnet::escape($currenturl);
+
+    $r->print("$currenturl<br/>");
+    
+
     # Begin the HTML table
     # four cols: resource + indent, chat+feedback, icon, text string
     $r->print('<table cellspacing="3" cellpadding="0" bgcolor="#FFFFFF">' ."\n");
 
-    my $mapIterator = $navmap->getIterator(undef, undef, \%filterHash);
+    my $mapIterator = $navmap->getIterator(undef, undef, \%filterHash, 0);
     my $curRes = $mapIterator->next();
     undef $res; # so we don't accidentally use it later
     my $indentLevel = -1;
@@ -1028,13 +1036,13 @@
                     my $mapId = $curRes->map_pc();
                     my $nowOpen = !defined($filterHash{$mapId});
                     $icon = $nowOpen ?
-                        "folder_opened.gif" : "folder_closed.gif";
+                        "folder_closed.gif" : "folder_opened.gif";
 		    $icon = "<img src=\"/adm/lonIcons/$icon\" alt=\"\" border=\"0\" />";
                     $linkopen = "<a href=\"/adm/navmaps?filter=";
                     $linkopen .= $nowOpen ? 
                         addToFilter(\%filterHash, $mapId) :
                         removeFromFilter(\%filterHash, $mapId);
-                    $linkopen .= "\">";
+                    $linkopen .= "&$queryAdd\">";
                     $linkclose = "</a>";
                     
                 }
@@ -1428,7 +1436,7 @@
 sub getIterator {
     my $self = shift;
     my $iterator = Apache::lonnavmaps::iterator->new($self, shift, shift,
-                                                     shift, shift);
+                                                     shift, undef, shift);
     return $iterator;
 }
 
@@ -1637,7 +1645,7 @@
 
 =over 4
 
-=item B<getIterator>(nav_map, firstResource, finishResource, filterHash): All parameters are optional. firstResource is a resource reference corresponding to where the iterator should start. It defaults to navmap->firstResource() for the corresponding nav map. finishResource corresponds to where you want the iterator to end, defaulting to navmap->finishResource(). It is your responsibility to ensure that the iterator will actually get there. filterHash is a hash used as a set containing strings representing the resource IDs, defaulting to empty. Condition is a 1 or 0 that sets what to do with the filter hash: If a 1, then only resource that exist IN the filterHash will be recursed on. If it is a 0, only resources NOT in the filterHash will be recursed on. Defaults to 0.
+=item B<getIterator>(nav_map, firstResource, finishResource, filterHash, condition): All parameters are optional. firstResource is a resource reference corresponding to where the iterator should start. It defaults to navmap->firstResource() for the corresponding nav map. finishResource corresponds to where you want the iterator to end, defaulting to navmap->finishResource(). It is your responsibility to ensure that the iterator will actually get there. filterHash is a hash used as a set containing strings representing the resource IDs, defaulting to empty. Condition is a 1 or 0 that sets what to do with the filter hash: If a 0, then only resource that exist IN the filterHash will be recursed on. If it is a 1, only resources NOT in the filterHash will be recursed on. Defaults to 0, which is to say, do not recurse unless explicitly asked to.
 
 Thus, by default, all resources will be shown. Change the condition to a 1 without changing the hash, and only the top level of the map will be shown. Changing the condition to 1 and including some values in the hash will allow you to selectively examine parts of the navmap, while leaving it on 0 and adding things to the hash will allow you to selectively ignore parts of the nav map. See the handler code for examples.
 
@@ -1689,6 +1697,7 @@
     # A hash, used as a set, of resource already seen
     $self->{ALREADY_SEEN} = shift;
     if (!defined($self->{ALREADY_SEEN})) { $self->{ALREADY_SEEN} = {} };
+    $self->{CONDITION} = shift;
 
     # Flag: Have we started yet? If not, the first action is to return BEGIN_MAP.
     $self->{STARTED} = 0;
@@ -1859,7 +1868,7 @@
 
     # If this is a map and we want to recurse down it... (not filtered out)
     if ($self->{HERE}->is_map() && 
-         !defined($self->{FILTER}->{$self->{HERE}->map_pc()})) { 
+         (defined($self->{FILTER}->{$self->{HERE}->map_pc()}) xor $self->{CONDITION})) { 
         $self->{RECURSIVE_ITERATOR_FLAG} = 1;
         my $firstResource = $self->{HERE}->map_start();
         my $finishResource = $self->{HERE}->map_finish();
@@ -1869,9 +1878,8 @@
         # isn't MAIN::new, __PACKAGE__::new or Apache::lonnavmaps::iterator->new
         $self->{RECURSIVE_ITERATOR} =
           Apache::lonnavmaps::iterator->new ($self->{NAV_MAP}, $firstResource, 
-                     $finishResource, $self->{FILTER}, $self->{ALREADY_SEEN});
-        # prime the new iterator with the first resource
-        #push @{$self->{RECURSIVE_ITERATOR}->{BRANCH_STACK}}, $firstResource;
+                     $finishResource, $self->{FILTER}, $self->{ALREADY_SEEN},
+					     $self->{CONDITION});
     }
 
     return $self->{HERE};