Diff for /loncom/interface/lonnavmaps.pm between versions 1.87 and 1.88

version 1.87, 2002/10/28 13:58:58 version 1.88, 2002/10/28 19:10:35
Line 910  sub new_handle { Line 910  sub new_handle {
         }          }
     }      }
   
       # Is this a new-style course? If so, we want to suppress showing the top-level
       # maps in their own folders, in favor of "inlining" them.
       my $topResource = $navmap->getById("0.0");
       my $inlineTopLevelMaps = $topResource->src() =~ m|^/uploaded/.*default\.sequence$|;
   
     my $currenturl = $ENV{'form.postdata'};      my $currenturl = $ENV{'form.postdata'};
     $currenturl=~s/^http\:\/\///;      $currenturl=~s/^http\:\/\///;
     $currenturl=~s/^[^\/]+//;      $currenturl=~s/^[^\/]+//;
Line 936  sub new_handle { Line 941  sub new_handle {
     # instead of uris. The changes to this and the main rendering      # instead of uris. The changes to this and the main rendering
     # loop should be obvious.      # loop should be obvious.
     # Here's a simple example of the iterator.      # Here's a simple example of the iterator.
     # If there is a current resource      # Preprocess the map: Look for current URL, force inlined maps to display
     if ($currenturl && !$ENV{'form.alreadyHere'}) {  
         # Give me every resource...      my $mapIterator = $navmap->getIterator(undef, undef, {}, 1);
         my $mapIterator = $navmap->getIterator(undef, undef, {}, 1);      my $found = 0;
         my $found = 0;      my $depth = 1;
         my $depth = 1;      $mapIterator->next(); # discard the first BEGIN_MAP
         $mapIterator->next(); # discard the first BEGIN_MAP      my $curRes = $mapIterator->next();
         my $curRes = $mapIterator->next();      
               while ($depth > 0) {
         while ($depth > 0 && !$found) {          if ($curRes == $mapIterator->BEGIN_MAP()) {
             if (ref($curRes) && $curRes->src() eq $currenturl) {              $depth++;
                 # If this is the correct resource, be sure to           }
                 # show it by making sure the containing maps          if ($curRes == $mapIterator->END_MAP()) {
                 # are open.              $depth--;
           }
                 my $mapStack = $mapIterator->getStack();  
                 for my $map (@{$mapStack}) {          my $mapStack = $mapIterator->getStack();
                     if ($condition) {          if ($currenturl && !$ENV{'form.alreadyHere'} && ref($curRes) && 
                         undef $filterHash{$map->map_pc()};              $curRes->src() eq $currenturl) {
                     } else {              # If this is the correct resource, be sure to 
                         $filterHash{$map->map_pc()} = 1;              # show it by making sure the containing maps
                     }              # are open.
               
               for my $map (@{$mapStack}) {
                   if ($condition) {
                       undef $filterHash{$map->map_pc()};
                   } else {
                       $filterHash{$map->map_pc()} = 1;
                 }                  }
                 $found = 1;  
             }              }
             $curRes = $mapIterator->next();              $ENV{'form.alreadyHere'} = 1;
           }
               
           # Preprocessing: If we're inlining nav maps into the top-level display,
           # make sure we show this map!
           if ($inlineTopLevelMaps && ref($curRes) && $curRes->is_map && 
               scalar(@{$mapStack}) == 1) {
               if ($condition) {
                   undef $filterHash{$curRes->map_pc()};
               } else {
                   $filterHash{$curRes->map_pc()} = 1;
               }
         }          }
     }  
   
           $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 = 0;      my $indentLevel = 0;
     my $indentString = "<img src=\"/adm/lonIcons/whitespace1.gif\" width=\"25\" height=\"1\" alt=\"\" border=\"0\" />";      my $indentString = "<img src=\"/adm/lonIcons/whitespace1.gif\" width=\"25\" height=\"1\" alt=\"\" border=\"0\" />";
Line 974  sub new_handle { Line 997  sub new_handle {
     my $in24Hours = $now + 24 * 60 * 60;      my $in24Hours = $now + 24 * 60 * 60;
     my $depth = 1;      my $depth = 1;
     my $displayedHereMarker = 0;      my $displayedHereMarker = 0;
       
     # We know the first thing is a BEGIN_MAP (see "$self->{STARTED}"      # We know the first thing is a BEGIN_MAP (see "$self->{STARTED}"
     # code in iterator->next), so ignore the first one      # code in iterator->next), so ignore the first one
     my $mapIterator = $navmap->getIterator(undef, undef, \%filterHash,      my $mapIterator = $navmap->getIterator(undef, undef, \%filterHash,
                                            $condition);                                             $condition);
     $mapIterator->next();      $mapIterator->next();
     my $curRes = $mapIterator->next();      my $curRes = $mapIterator->next();
       my $deltadepth = 0;
   
       my @backgroundColors = ("#FFFFFF", "#F6F6F6");
       my $rowNum = 0;
   
     while ($depth > 0) {      while ($depth > 0) {
           # If we're in a new style course, and this is a BEGIN_MAP, END_MAP, or
           # map resource and the stack depth is only one, just plain ignore this resource
           # entirely. (This has the effect of inlining the resources in that map
           # in the nav map.)
           if ($inlineTopLevelMaps && scalar(@{$mapIterator->getStack()}) == 1 &&
               ref($curRes) && $curRes->is_map()) {
               # We let the normal depth stuff occur, but we need to shift everything
               # over by one to the left to make it look right.
               $deltadepth = -1;
               $curRes = $mapIterator->next();
               next;
           }
   
         if ($curRes == $mapIterator->BEGIN_MAP() ||          if ($curRes == $mapIterator->BEGIN_MAP() ||
             $curRes == $mapIterator->BEGIN_BRANCH()) {              $curRes == $mapIterator->BEGIN_BRANCH()) {
             $indentLevel++;              $indentLevel++;
Line 1001  sub new_handle { Line 1041  sub new_handle {
             $depth--;              $depth--;
         }          }
   
           if ($depth == 1) { $deltadepth = 0; } # we're done shifting, because we're
                                                 # out of the inlined map
   
         # Is this resource being blotted out?          # Is this resource being blotted out?
         if (ref($curRes) && !advancedUser() && $curRes->randomout()) {          if (ref($curRes) && !advancedUser() && $curRes->randomout()) {
             $curRes = $mapIterator->next();              $curRes = $mapIterator->next();
Line 1168  sub new_handle { Line 1211  sub new_handle {
                         $color = $hurryUpColor;                          $color = $hurryUpColor;
                     }                      }
                     # Special case: If this is the last try, and there is                      # Special case: If this is the last try, and there is
                     # more then one available, give a bit of urgency                      # more then one available, and it's not due yet, give a bit of urgency
                     my $tries = $curRes->tries($part);                      my $tries = $curRes->tries($part);
                     my $maxtries = $curRes->maxtries($part);                      my $maxtries = $curRes->maxtries($part);
                     if ($tries && $maxtries && $maxtries > 1 &&                      if ($tries && $maxtries && $maxtries > 1 &&
                         $maxtries - $tries == 1) {                          $maxtries - $tries == 1 && $curRes->duedate() &&
                           $curRes->duedate() > time()) {
                         $color = $hurryUpColor;                          $color = $hurryUpColor;
                     }                      }
                     if ($color ne "") {                      if ($color ne "") {
Line 1184  sub new_handle { Line 1228  sub new_handle {
                     $nonLinkedText .= ' <i>(hidden)</i> ';                      $nonLinkedText .= ' <i>(hidden)</i> ';
                 }                  }
   
                   $rowNum++;
                   my $backgroundColor = $backgroundColors[$rowNum % scalar(@backgroundColors)];
   
                 # FIRST COL: The resource indentation, branch icon, and name                  # FIRST COL: The resource indentation, branch icon, and name
                 $r->print("  <tr><td align=\"left\" valign=\"center\" width=\"60%\">\n");                  $r->print("  <tr bgcolor=\"$backgroundColor\"><td align=\"left\" valign=\"center\" width=\"60%\">\n");
   
                 # print indentation                  # print indentation
                 for (my $i = 0; $i < $indentLevel - $deltalevel; $i++) {                  for (my $i = 0; $i < $indentLevel - $deltalevel + $deltadepth; $i++) {
                     $r->print($indentString);                      $r->print($indentString);
                 }                  }
   
Line 2174  sub populateStack { Line 2221  sub populateStack {
     my $self=shift;      my $self=shift;
     my $stack = shift;      my $stack = shift;
   
     push @$stack, $self->{HERE};      push @$stack, $self->{HERE} if ($self->{HERE});
   
     if ($self->{RECURSIVE_ITERATOR_FLAG}) {      if ($self->{RECURSIVE_ITERATOR_FLAG}) {
         $self->{RECURSIVE_ITERATOR}->populateStack($stack);          $self->{RECURSIVE_ITERATOR}->populateStack($stack);

Removed from v.1.87  
changed lines
  Added in v.1.88


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