Diff for /loncom/interface/lonnavmaps.pm between versions 1.62 and 1.63

version 1.62, 2002/10/03 19:10:28 version 1.63, 2002/10/03 19:40:33
Line 888  sub new_handle { Line 888  sub new_handle {
         }          }
     }      }
   
       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      # Begin the HTML table
     # four cols: resource + indent, chat+feedback, icon, text string      # four cols: resource + indent, chat+feedback, icon, text string
     $r->print('<table cellspacing="3" cellpadding="0" bgcolor="#FFFFFF">' ."\n");      $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();      my $curRes = $mapIterator->next();
     undef $res; # so we don't accidentally use it later      undef $res; # so we don't accidentally use it later
     my $indentLevel = -1;      my $indentLevel = -1;
Line 1028  sub new_handle { Line 1036  sub new_handle {
                     my $mapId = $curRes->map_pc();                      my $mapId = $curRes->map_pc();
                     my $nowOpen = !defined($filterHash{$mapId});                      my $nowOpen = !defined($filterHash{$mapId});
                     $icon = $nowOpen ?                      $icon = $nowOpen ?
                         "folder_opened.gif" : "folder_closed.gif";                          "folder_closed.gif" : "folder_opened.gif";
     $icon = "<img src=\"/adm/lonIcons/$icon\" alt=\"\" border=\"0\" />";      $icon = "<img src=\"/adm/lonIcons/$icon\" alt=\"\" border=\"0\" />";
                     $linkopen = "<a href=\"/adm/navmaps?filter=";                      $linkopen = "<a href=\"/adm/navmaps?filter=";
                     $linkopen .= $nowOpen ?                       $linkopen .= $nowOpen ? 
                         addToFilter(\%filterHash, $mapId) :                          addToFilter(\%filterHash, $mapId) :
                         removeFromFilter(\%filterHash, $mapId);                          removeFromFilter(\%filterHash, $mapId);
                     $linkopen .= "\">";                      $linkopen .= "&$queryAdd\">";
                     $linkclose = "</a>";                      $linkclose = "</a>";
                                           
                 }                  }
Line 1428  sub courseMapDefined { Line 1436  sub courseMapDefined {
 sub getIterator {  sub getIterator {
     my $self = shift;      my $self = shift;
     my $iterator = Apache::lonnavmaps::iterator->new($self, shift, shift,      my $iterator = Apache::lonnavmaps::iterator->new($self, shift, shift,
                                                      shift, shift);                                                       shift, undef, shift);
     return $iterator;      return $iterator;
 }  }
   
Line 1637  getIterator behaves as follows: Line 1645  getIterator behaves as follows:
   
 =over 4  =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.  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.
   
Line 1689  sub new { Line 1697  sub new {
     # A hash, used as a set, of resource already seen      # A hash, used as a set, of resource already seen
     $self->{ALREADY_SEEN} = shift;      $self->{ALREADY_SEEN} = shift;
     if (!defined($self->{ALREADY_SEEN})) { $self->{ALREADY_SEEN} = {} };      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.      # Flag: Have we started yet? If not, the first action is to return BEGIN_MAP.
     $self->{STARTED} = 0;      $self->{STARTED} = 0;
Line 1859  sub next { Line 1868  sub next {
   
     # If this is a map and we want to recurse down it... (not filtered out)      # If this is a map and we want to recurse down it... (not filtered out)
     if ($self->{HERE}->is_map() &&       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;          $self->{RECURSIVE_ITERATOR_FLAG} = 1;
         my $firstResource = $self->{HERE}->map_start();          my $firstResource = $self->{HERE}->map_start();
         my $finishResource = $self->{HERE}->map_finish();          my $finishResource = $self->{HERE}->map_finish();
Line 1869  sub next { Line 1878  sub next {
         # isn't MAIN::new, __PACKAGE__::new or Apache::lonnavmaps::iterator->new          # isn't MAIN::new, __PACKAGE__::new or Apache::lonnavmaps::iterator->new
         $self->{RECURSIVE_ITERATOR} =          $self->{RECURSIVE_ITERATOR} =
           Apache::lonnavmaps::iterator->new ($self->{NAV_MAP}, $firstResource,             Apache::lonnavmaps::iterator->new ($self->{NAV_MAP}, $firstResource, 
                      $finishResource, $self->{FILTER}, $self->{ALREADY_SEEN});                       $finishResource, $self->{FILTER}, $self->{ALREADY_SEEN},
         # prime the new iterator with the first resource       $self->{CONDITION});
         #push @{$self->{RECURSIVE_ITERATOR}->{BRANCH_STACK}}, $firstResource;  
     }      }
   
     return $self->{HERE};      return $self->{HERE};

Removed from v.1.62  
changed lines
  Added in v.1.63


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>