Diff for /loncom/interface/lonnavmaps.pm between versions 1.89 and 1.92

version 1.89, 2002/10/28 20:48:29 version 1.92, 2002/10/29 20:20:45
Line 820  sub new_handle { Line 820  sub new_handle {
     &Apache::loncommon::no_cache($r);      &Apache::loncommon::no_cache($r);
     $r->send_http_header;      $r->send_http_header;
   
     # Initialize the nav map      # Create the nav map the nav map
     my $navmap = Apache::lonnavmaps::navmap->new(      my $navmap = Apache::lonnavmaps::navmap->new(
                         $ENV{"request.course.fn"}.".db",                          $ENV{"request.course.fn"}.".db",
                         $ENV{"request.course.fn"}."_parms.db", 1, 1);                          $ENV{"request.course.fn"}."_parms.db", 1, 1);
Line 850  sub new_handle { Line 850  sub new_handle {
                   '<br><img src="/adm/lonMisc/feedback.gif"> New message (click to open)<p>');                     '<br><img src="/adm/lonMisc/feedback.gif"> New message (click to open)<p>'); 
     }      }
   
       # Now that we've displayed some stuff to the user, init the navmap
       $navmap->init();
   
     # Check that it's defined      # Check that it's defined
     if (!($navmap->courseMapDefined())) {      if (!($navmap->courseMapDefined())) {
         $r->print('<font size="+2" color="red">Coursemap undefined.</font>' .          $r->print('<font size="+2" color="red">Coursemap undefined.</font>' .
Line 926  sub new_handle { Line 929  sub new_handle {
     my $queryAdd = "postdata=" . &Apache::lonnet::escape($currenturl) .      my $queryAdd = "postdata=" . &Apache::lonnet::escape($currenturl) .
         "&alreadyHere=1";          "&alreadyHere=1";
   
     $r->print('<a href="navmaps?condition=1&filter=">Show All Resources</a><br /><br />');  
   
     # Begin the HTML table  
     # four cols: resource + indent, chat+feedback, icon, text string  
     $r->print('<table cellspacing="0" cellpadding="3" border="0" bgcolor="#FFFFFF">' ."\n");  
   
     my $condition = 0;      my $condition = 0;
     if ($ENV{'form.condition'}) {      if ($ENV{'form.condition'}) {
         $condition = 1;          $condition = 1;
     }      }
   
       if ($condition) {
           $r->print('<a href="navmaps?condition=0&filter=">Close All Folders</a><br /><br />');
       } else {
           $r->print('<a href="navmaps?condition=1&filter=">Open All Folders</a><br /><br />');
       }
   
       # Begin the HTML table
       # four cols: resource + indent, chat+feedback, icon, text string
       $r->print('<table cellspacing="0" cellpadding="3" border="0" bgcolor="#FFFFFF">' ."\n");
   
     # This needs to be updated to use symbs from the remote,       # This needs to be updated to use symbs from the remote, 
     # 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.
Line 946  sub new_handle { Line 953  sub new_handle {
     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;
       my $currentUrlIndex = 0; # keeps track of when the current resource is found,
                                # so we can back up a few and put the anchor above the
                                # current resource
     $mapIterator->next(); # discard the first BEGIN_MAP      $mapIterator->next(); # discard the first BEGIN_MAP
     my $curRes = $mapIterator->next();      my $curRes = $mapIterator->next();
       my $counter = 0;
           
     while ($depth > 0) {      while ($depth > 0) {
         if ($curRes == $mapIterator->BEGIN_MAP()) {          if ($curRes == $mapIterator->BEGIN_MAP()) {
Line 957  sub new_handle { Line 968  sub new_handle {
             $depth--;              $depth--;
         }          }
   
           if (ref($curRes)) { $counter++; }
   
         my $mapStack = $mapIterator->getStack();          my $mapStack = $mapIterator->getStack();
         if ($currenturl && !$ENV{'form.alreadyHere'} && ref($curRes) &&           if ($currenturl && !$ENV{'form.alreadyHere'} && ref($curRes) && 
             $curRes->src() eq $currenturl) {              $curRes->src() eq $currenturl) {
             # If this is the correct resource, be sure to               # If this is the correct resource, be sure to 
             # show it by making sure the containing maps              # show it by making sure the containing maps
             # are open.              # are open.
   
               $currentUrlIndex = $counter;
                           
             for my $map (@{$mapStack}) {              for my $map (@{$mapStack}) {
                 if ($condition) {                  if ($condition) {
Line 1004  sub new_handle { Line 1019  sub new_handle {
     $mapIterator->next();      $mapIterator->next();
     $curRes = $mapIterator->next();      $curRes = $mapIterator->next();
     my $deltadepth = 0;      my $deltadepth = 0;
       $depth = 1;
   
     my @backgroundColors = ("#FFFFFF", "#F6F6F6");      my @backgroundColors = ("#FFFFFF", "#F6F6F6");
     my $rowNum = 0;      my $rowNum = 0;
   
       $counter = 0;
   
     while ($depth > 0) {      while ($depth > 0) {
         # If we're in a new style course, and this is a BEGIN_MAP, END_MAP, or          # 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          # map resource and the stack depth is only one, just plain ignore this resource
Line 1040  sub new_handle { Line 1058  sub new_handle {
             $depth--;              $depth--;
         }          }
   
           if (ref($curRes)) { $counter++; }
   
         if ($depth == 1) { $deltadepth = 0; } # we're done shifting, because we're          if ($depth == 1) { $deltadepth = 0; } # we're done shifting, because we're
                                               # out of the inlined map                                                # out of the inlined map
   
Line 1230  sub new_handle { Line 1250  sub new_handle {
                 $rowNum++;                  $rowNum++;
                 my $backgroundColor = $backgroundColors[$rowNum % scalar(@backgroundColors)];                  my $backgroundColor = $backgroundColors[$rowNum % scalar(@backgroundColors)];
   
                 # FIRST COL: The resource indentation, branch icon, and name                  # FIRST COL: The resource indentation, branch icon, name, and anchor
                 $r->print("  <tr bgcolor=\"$backgroundColor\"><td align=\"left\" valign=\"center\" width=\"60%\">\n");                  $r->print("  <tr bgcolor=\"$backgroundColor\"><td align=\"left\" valign=\"center\" width=\"60%\">\n");
   
                   # anchor for current resource... - 5 is deliberate: If it's that
                   # high on the screen, don't bother focusing on it. Also this will
                   # print multiple anchors if this is an expanded multi-part problem...
                   # who cares?
                   if ($counter == $currentUrlIndex - 5) {
                       $r->print('<a name="current" />');
                   }
   
                 # print indentation                  # print indentation
                 for (my $i = 0; $i < $indentLevel - $deltalevel + $deltadepth; $i++) {                  for (my $i = 0; $i < $indentLevel - $deltalevel + $deltadepth; $i++) {
                     $r->print($indentString);                      $r->print($indentString);
Line 1615  sub new { Line 1643  sub new {
     $self->{PARM_HASH} = \%parmhash;      $self->{PARM_HASH} = \%parmhash;
     $self->{HASH_TIED} = 1;      $self->{HASH_TIED} = 1;
   
       bless($self);
           
       return $self;
   }
   
   sub init {
       my $self = $self;
   
     # If the course opt hash and the user opt hash should be generated,      # If the course opt hash and the user opt hash should be generated,
     # generate them      # generate them
     if ($self->{GENERATE_COURSE_USER_OPT}) {      if ($self->{GENERATE_COURSE_USER_OPT}) {
Line 1719  sub new { Line 1755  sub new {
     }          }    
   
     $self->{PARM_CACHE} = {};      $self->{PARM_CACHE} = {};
       
     bless($self);  
           
     return $self;  
 }  }
   
 # Checks to see if coursemap is defined, matching test in old lonnavmaps  # Checks to see if coursemap is defined, matching test in old lonnavmaps
Line 2053  sub new { Line 2085  sub new {
     if ($self->{DIRECTION} == FORWARD) {      if ($self->{DIRECTION} == FORWARD) {
         push @{$self->{BRANCH_STACK}}, $self->{FIRST_RESOURCE};          push @{$self->{BRANCH_STACK}}, $self->{FIRST_RESOURCE};
     } else {      } else {
         push @{$self->{BRANCH_STACK}), $self->{FINISH_RESOURCE};          push @{$self->{BRANCH_STACK}}, $self->{FINISH_RESOURCE};
     }      }
     $self->{BRANCH_STACK_SIZE} = 1;      $self->{BRANCH_STACK_SIZE} = 1;
   
Line 2151  sub next { Line 2183  sub next {
     $self->{ALREADY_SEEN}->{$self->{HERE}->{ID}} = 1;      $self->{ALREADY_SEEN}->{$self->{HERE}->{ID}} = 1;
           
     # Get the next possible resources      # Get the next possible resources
       my $nextUnfiltered;
     if ($self->{DIRECTION} == FORWARD()) {      if ($self->{DIRECTION} == FORWARD()) {
         my $nextUnfiltered = $self->{HERE}->getNext();          $nextUnfiltered = $self->{HERE}->getNext();
     } else {      } else {
         my $nextUnfiltered = $self->{HERE}->getPrevious();          $nextUnfiltered = $self->{HERE}->getPrevious();
     }      }
     my $next = [];      my $next = [];
   
Line 2205  sub next { Line 2238  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},
                                              $self->{CONDITION});                                               $self->{CONDITION}, $self->{DIRECTION});
     }      }
   
     return $self->{HERE};      return $self->{HERE};

Removed from v.1.89  
changed lines
  Added in v.1.92


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