Diff for /loncom/interface/lonnavmaps.pm between versions 1.51 and 1.52

version 1.51, 2002/09/24 01:18:50 version 1.52, 2002/09/24 02:41:21
Line 870  sub new_handle { Line 870  sub new_handle {
   
     while ($curRes != $mapIterator->END_NAV_MAP) {      while ($curRes != $mapIterator->END_NAV_MAP) {
         if ($curRes == $mapIterator->BEGIN_MAP() ||          if ($curRes == $mapIterator->BEGIN_MAP() ||
     $curRes == $mapIterator->BEGIN_BRANCH()) {              $curRes == $mapIterator->BEGIN_BRANCH()) {
             $indentLevel++;              $indentLevel++;
         }          }
         if ($curRes == $mapIterator->END_MAP() ||          if ($curRes == $mapIterator->END_MAP() ||
     $curRes == $mapIterator->END_BRANCH()) {              $curRes == $mapIterator->END_BRANCH()) {
             $indentLevel--;              $indentLevel--;
         }          }
           if ($curRes == $mapIterator->BEGIN_BRANCH()) {
  if ($curRes == $mapIterator->BEGIN_BRANCH()) {              $isNewBranch = 1;
     $r->print("Begin branch<br/>");  
  }  
         if ($curRes == $mapIterator->END_BRANCH()) {  
             $r->print("End branch<br/>");  
         }          }
   
         if (ref($curRes) && $curRes->src()) {          if (ref($curRes) && $curRes->src()) {
Line 911  sub new_handle { Line 907  sub new_handle {
                     '"';                      '"';
                 my $title = $curRes->title();                  my $title = $curRes->title();
                 my $partLabel = "";                  my $partLabel = "";
                   my $newBranchText = "";
   
                   # If this is a new branch, label it so
                   # (temporary, this should be an icon w/ alt text)
                   if ($isNewBranch) {
                       $newBranchText = "NB -> ";
                       $isNewBranch = 0;
                   }
   
                 # links to open and close the folders                  # links to open and close the folders
                 my $linkopen = "<a href=\"$link\">";                  my $linkopen = "<a href=\"$link\">";
Line 927  sub new_handle { Line 931  sub new_handle {
                     my $nowOpen = !defined($filterHash{$mapId});                      my $nowOpen = !defined($filterHash{$mapId});
                     $icon = $nowOpen ?                      $icon = $nowOpen ?
                         "folder_opened.gif" : "folder_closed.gif";                          "folder_opened.gif" : "folder_closed.gif";
                     $linkopen = "<a href=\"/adm/navmaps?jtest=1&filter=";                      $linkopen = "<a href=\"/adm/navmaps?filter=";
                     $linkopen .= $nowOpen ?                       $linkopen .= $nowOpen ? 
                         addToFilter(\%filterHash, $mapId) :                          addToFilter(\%filterHash, $mapId) :
                         removeFromFilter(\%filterHash, $mapId);                          removeFromFilter(\%filterHash, $mapId);
Line 952  sub new_handle { Line 956  sub new_handle {
                     $r->print($indentString);                      $r->print($indentString);
                 }                  }
   
                 $r->print("  ${linkopen}<img border=\"0\" src=\"" .                  $r->print("  ${newBranchText}${linkopen}<img border=\"0\" src=\"" .
                           "/adm/lonIcons/$icon\" alt=\"\">${linkclose}\n");                            "/adm/lonIcons/$icon\" alt=\"\">${linkclose}\n");
   
                 if ($curRes->is_problem() && $part != "0") { $partLabel = " (Part $part)"; }                  if ($curRes->is_problem() && $part != "0") { $partLabel = " (Part $part)"; }
Line 1460  sub next { Line 1464  sub next {
     if (scalar(@{$self->{BRANCH_STACK}}) == 0) {      if (scalar(@{$self->{BRANCH_STACK}}) == 0) {
         if ($self->{BRANCH_DEPTH} > 0) {          if ($self->{BRANCH_DEPTH} > 0) {
             $self->{FORCE_NEXT} = $self->END_MAP();              $self->{FORCE_NEXT} = $self->END_MAP();
     $self->{BRANCH_DEPTH}--;              $self->{BRANCH_DEPTH}--;
             return $self->END_BRANCH();              return $self->END_BRANCH();
         } else {          } else {
             return $self->END_MAP();              return $self->END_MAP();
Line 1479  sub next { Line 1483  sub next {
     # to start a new one. (We know because we already checked to see      # to start a new one. (We know because we already checked to see
     # if the stack was empty.)      # if the stack was empty.)
     if ( scalar (@{$self->{BRANCH_STACK}}) < $self->{BRANCH_STACK_SIZE}) {      if ( scalar (@{$self->{BRANCH_STACK}}) < $self->{BRANCH_STACK_SIZE}) {
  $self->{BRANCH_STACK_SIZE} = scalar(@{$self->{BRANCH_STACK}});          $self->{BRANCH_STACK_SIZE} = scalar(@{$self->{BRANCH_STACK}});
  $self->{BRANCH_DEPTH}++;          $self->{BRANCH_DEPTH}++;
  return $self->BEGIN_BRANCH();          return $self->BEGIN_BRANCH();
     }      }
   
       # Remember the size for comparision next time.
       $self->{BRANCH_STACK_SIZE} = scalar(@{$self->{BRANCH_STACK}});
   
       # If the next resource we mean to return is going to need
       # a lower branch level, terminate branches until we get 
       # there.
   
     # Get the next resource in the branch      # Get the next resource in the branch
     $self->{HERE} = pop @{$self->{BRANCH_STACK}};      $self->{HERE} = pop @{$self->{BRANCH_STACK}};
   
       # Are we at the right depth? If not, close a branch and return
       # the current resource onto the branch stack
       if (defined($self->{HERE}->{DATA}->{ITERATOR_DEPTH})
           && $self->{HERE}->{DATA}->{ITERATOR_DEPTH} <
           $self->{BRANCH_DEPTH} ) {
           $self->{BRANCH_DEPTH}--;
           # return it so we can pick it up eventually
           push @{$self->{BRANCH_STACK}}, $self->{HERE};
           return $self->END_BRANCH();
       }
   
     # We always return it after this point and never before      # We always return it after this point and never before
     # (proof: look at just the return statements), so we      # (proof: look at just the return statements), so we
     # remember that we've seen this.      # remember that we've seen this.
Line 1493  sub next { Line 1516  sub next {
           
     # Are we at the utter end? If so, return the END_NAV_MAP marker.      # Are we at the utter end? If so, return the END_NAV_MAP marker.
     if ($self->{HERE} == $self->{NAV_MAP}->finishResource() ) {      if ($self->{HERE} == $self->{NAV_MAP}->finishResource() ) {
  $self->{FORCE_NEXT} = $self->END_NAV_MAP;          $self->{FORCE_NEXT} = $self->END_NAV_MAP;
         return $self->{HERE};          return $self->{HERE};
     }      }
           
     # Remember the size for comparision next time.  
     $self->{BRANCH_STACK_SIZE} = scalar(@{$self->{BRANCH_STACK}});  
   
     # Get the next possible resources      # Get the next possible resources
     my $nextUnfiltered = $self->{HERE}->getNext();      my $nextUnfiltered = $self->{HERE}->getNext();
     my $next = [];      my $next = [];
   
     # filter the next possibilities to remove things we've       # filter the next possibilities to remove things we've 
     # already seen      # already seen. Also, remember what branch depth they should
       # be displayed at, since there's no other reliable way to tell.
     foreach (@$nextUnfiltered) {      foreach (@$nextUnfiltered) {
  if (!defined($self->{ALREADY_SEEN}->{$_->{ID}})) {          if (!defined($self->{ALREADY_SEEN}->{$_->{ID}})) {
     push @$next, $_;              push @$next, $_;
  }              $_->{DATA}->{ITERATOR_DEPTH} = 
                   $self->{BRANCH_DEPTH} + 1;
           }
     }      }
   
     # Handle branch cases:      # Handle branch cases:
Line 1518  sub next { Line 1541  sub next {
     # 2+ things next: have some branches      # 2+ things next: have some branches
     my $nextCount = scalar(@$next);      my $nextCount = scalar(@$next);
     if ($nextCount == 0) {      if ($nextCount == 0) {
  # Return this and on the next run, close the branch up if we're           # Return this and on the next run, close the branch up if we're 
  # in a branch          # in a branch
  if ($self->{BRANCH_DEPTH} > 0 ) {          if ($self->{BRANCH_DEPTH} > 0 ) {
     $self->{FORCE_NEXT} = $self->END_BRANCH();              $self->{FORCE_NEXT} = $self->END_BRANCH();
     $self->{BRANCH_DEPTH}--;              $self->{BRANCH_DEPTH}--;
  }          }
         return $self->{HERE};          return $self->{HERE};
     }      }
           
     while (@$next) {      while (@$next) {
         # copy the next possibilities over to the branch stack          # copy the next possibilities over to the branch stack
         # in the right order          # in the right order
  push @{$self->{BRANCH_STACK}}, shift @$next;          push @{$self->{BRANCH_STACK}}, shift @$next;
     }      }
   
     if ($nextCount >= 2) {      if ($nextCount >= 2) {
  $self->{FORCE_NEXT} = $self->BEGIN_BRANCH();          $self->{FORCE_NEXT} = $self->BEGIN_BRANCH();
  $self->{BRANCH_DEPTH}++;          $self->{BRANCH_DEPTH}++;
         return $self->{HERE};           return $self->{HERE}; 
     }      }
   
Line 1552  sub next { Line 1575  sub next {
         $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          # prime the new iterator with the first resource
  #push @{$self->{RECURSIVE_ITERATOR}->{BRANCH_STACK}}, $firstResource;          #push @{$self->{RECURSIVE_ITERATOR}->{BRANCH_STACK}}, $firstResource;
     }      }
   
     return $self->{HERE};      return $self->{HERE};

Removed from v.1.51  
changed lines
  Added in v.1.52


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