Diff for /loncom/interface/lonnavmaps.pm between versions 1.174 and 1.182

version 1.174, 2003/04/04 21:36:01 version 1.182, 2003/04/25 17:02:26
Line 169  sub real_handler { Line 169  sub real_handler {
         return OK;          return OK;
     }      }
   
     # See if there's only one map in the top-level... if so,      # See if there's only one map in the top-level, if we don't
     # automatically display it      # already have a filter... if so, automatically display it
     my $iterator = $navmap->getIterator(undef, undef, undef, 0);      if ($ENV{QUERY_STRING} !~ /filter/) {
     my $depth = 1;          my $iterator = $navmap->getIterator(undef, undef, undef, 0);
     $iterator->next();          my $depth = 1;
     my $curRes = $iterator->next();          $iterator->next();
     my $sequenceCount = 0;          my $curRes = $iterator->next();
     my $sequenceId;          my $sequenceCount = 0;
     while ($depth > 0) {          my $sequenceId;
         if ($curRes == $iterator->BEGIN_MAP()) { $depth++; }          while ($depth > 0) {
         if ($curRes == $iterator->END_MAP()) { $depth--; }              if ($curRes == $iterator->BEGIN_MAP()) { $depth++; }
               if ($curRes == $iterator->END_MAP()) { $depth--; }
         if (ref($curRes) && $curRes->is_sequence()) {              
             $sequenceCount++;              if (ref($curRes) && $curRes->is_sequence()) {
             $sequenceId = $curRes->map_pc();                  $sequenceCount++;
                   $sequenceId = $curRes->map_pc();
               }
               
               $curRes = $iterator->next();
           }
           
           if ($sequenceCount == 1) {
               # The automatic iterator creation in the render call 
               # will pick this up. We know the condition because
               # the defined($ENV{'form.filter'}) also ensures this
               # is a fresh call.
               $ENV{'form.filter'} = "$sequenceId";
         }          }
   
         $curRes = $iterator->next();  
     }  
   
     if ($sequenceCount == 1) {  
         # The automatic iterator creation in the render call   
         # will pick this up.  
         $ENV{'form.filter'} = "$sequenceId";  
     }      }
   
     # renderer call      # renderer call
Line 267  sub getDescription { Line 271  sub getDescription {
     my $part = shift;      my $part = shift;
     my $status = $res->status($part);      my $status = $res->status($part);
   
     if ($status == $res->NETWORK_FAILURE) { return ""; }      if ($status == $res->NETWORK_FAILURE) { 
           return "Having technical difficulties; please check status later"; 
       }
     if ($status == $res->NOTHING_SET) {      if ($status == $res->NOTHING_SET) {
         return "Not currently assigned.";          return "Not currently assigned.";
     }      }
Line 343  sub lastTry { Line 349  sub lastTry {
 }  }
   
 # This puts a human-readable name on the ENV variable.  # This puts a human-readable name on the ENV variable.
 # FIXME: This needs better logic: Who gets the advanced view of navmaps?  
 #   As of 3-13-03, it's an open question. Guy doesn't want to check  
 #   roles directly because it should be a check of capabilities for future  
 #   role compatibity. There is no capability that matches this one for  
 #   now, so this is done. (A hack for 1.0 might be to simply check roles  
 #   anyhow.)  
 sub advancedUser {  sub advancedUser {
     return $ENV{'user.adv'};      return $ENV{'request.role.adv'};
 }  }
   
   
Line 1000  sub render { Line 1001  sub render {
         # Step two: Locate what kind of here marker is necessary          # Step two: Locate what kind of here marker is necessary
         # Determine where the "here" marker is and where the screen jumps to.          # Determine where the "here" marker is and where the screen jumps to.
   
         if ($ENV{'form.symb'}) {          if ($ENV{'form.postsymb'}) {
             $here = $jump = $ENV{'form.symb'};              $here = $jump = $ENV{'form.postsymb'};
         } elsif ($ENV{'form.postdata'}) {          } elsif ($ENV{'form.postdata'}) {
             # couldn't find a symb, is there a URL?              # couldn't find a symb, is there a URL?
             my $currenturl = $ENV{'form.postdata'};              my $currenturl = $ENV{'form.postdata'};
Line 1351  sub render { Line 1352  sub render {
         $r->rflush();          $r->rflush();
     }      }
                   
     #if ($mustCloseNavMap) { $navmap->untieHashes(); }       if ($mustCloseNavMap) { $navmap->untieHashes(); } 
   
     return $result;      return $result;
 }  }
Line 1473  sub init { Line 1474  sub init {
             unless ((time-$courserdatas{$cid.'.last_cache'})<240) {              unless ((time-$courserdatas{$cid.'.last_cache'})<240) {
                 my $reply=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum.                  my $reply=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum.
                                                  ':resourcedata',$chome);                                                   ':resourcedata',$chome);
                 if ($reply!~/^error\:/) {                  # Check for network failure
                   if ( $reply =~ /no.such.host/i || $reply =~ /con_lost/i) {
                       $self->{NETWORK_FAILURE} = 1;
                   } elsif ($reply!~/^error\:/) {
                     $courserdatas{$cid}=$reply;                      $courserdatas{$cid}=$reply;
                     $courserdatas{$cid.'.last_cache'}=time;                      $courserdatas{$cid.'.last_cache'}=time;
                 }                  }
                 # check to see if network failed  
                 elsif ( $reply=~/no.such.host/i || $reply=~/con.*lost/i )  
                 {  
                     $self->{NETWORK_FAILURE} = 1;  
                 }  
             }              }
             foreach (split(/\&/,$courserdatas{$cid})) {              foreach (split(/\&/,$courserdatas{$cid})) {
                 my ($name,$value)=split(/\=/,$_);                  my ($name,$value)=split(/\=/,$_);
Line 2690  sub to { my $self=shift; return $self->n Line 2689  sub to { my $self=shift; return $self->n
 sub compTitle {  sub compTitle {
     my $self = shift;      my $self = shift;
     my $title = $self->title();      my $title = $self->title();
       $title=~s/\&colon\;/\:/gs;
     if (!$title) {      if (!$title) {
         $title = $self->src();          $title = $self->src();
         $title = substr($title, rindex($title, '/') + 1);          $title = substr($title, rindex($title, '/') + 1);
Line 3078  sub extractParts { Line 3078  sub extractParts {
   
     $self->{PARTS} = [];      $self->{PARTS} = [];
   
       my %parts;
   
     # Retrieve part count, if this is a problem      # Retrieve part count, if this is a problem
     if ($self->is_problem()) {      if ($self->is_problem()) {
         my $metadata = &Apache::lonnet::metadata($self->src(), 'packages');          my $metadata = &Apache::lonnet::metadata($self->src(), 'packages');
Line 3089  sub extractParts { Line 3091  sub extractParts {
         foreach (split(/\,/,$metadata)) {          foreach (split(/\,/,$metadata)) {
             if ($_ =~ /^part_(.*)$/) {              if ($_ =~ /^part_(.*)$/) {
                 my $part = $1;                  my $part = $1;
                   # This floods the logs
                   #if (defined($parts{$part})) {
                   #    Apache::lonnet::logthis("$part multiply defined in metadata for " . $self->symb());
                   #  }
   
                 # check to see if part is turned off.                  # check to see if part is turned off.
                 if (! Apache::loncommon::check_if_partid_hidden($part, $self->symb())) {  
                     push @{$self->{PARTS}}, $1;                  if (!Apache::loncommon::check_if_partid_hidden($part, $self->symb())) {
                       $parts{$part} = 1;
                 }                  }
             }              }
         }          }
                   
                   
         my @sortedParts = sort @{$self->{PARTS}};          my @sortedParts = sort keys %parts;
         $self->{PARTS} = \@sortedParts;          $self->{PARTS} = \@sortedParts;
     }      }
   

Removed from v.1.174  
changed lines
  Added in v.1.182


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