--- loncom/interface/lonnavmaps.pm 2003/03/20 17:19:29 1.161 +++ loncom/interface/lonnavmaps.pm 2003/03/20 18:03:14 1.162 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.161 2003/03/20 17:19:29 bowersj2 Exp $ +# $Id: lonnavmaps.pm,v 1.162 2003/03/20 18:03:14 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1107,7 +1107,7 @@ sub render { if ($condenseParts) { # do the condensation if (!$curRes->opendate("0")) { - @parts = ("0"); + @parts = (); $args->{'condensed'} = 1; } if (!$args->{'condensed'}) { @@ -1757,7 +1757,7 @@ getIterator behaves as follows: =over 4 -=item * B(firstResource, finishResource, filterHash, condition, forceTop): 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(). 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. forceTop is a boolean value. If it is false (default), the iterator will only return the first level of map that is not just a single, 'redirecting' map. If true, the iterator will return all information, starting with the top-level map, regardless of content. +=item * B(firstResource, finishResource, filterHash, condition, forceTop, returnTopMap): 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(). 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. forceTop is a boolean value. If it is false (default), the iterator will only return the first level of map that is not just a single, 'redirecting' map. If true, the iterator will return all information, starting with the top-level map, regardless of content. returnTopMap, if true (default false), will cause the iterator to return the top-level map object (resource 0.0) before anything else. Thus, by default, only top-level resources will be shown. Change the condition to a 1 without changing the hash, and all resources will be shown. Changing the condition to 1 and including some values in the hash will allow you to selectively suppress parts of the navmap, while leaving it on 0 and adding things to the hash will allow you to selectively add parts of the nav map. See the handler code for examples. @@ -1832,6 +1832,11 @@ sub new { # Do we want to automatically follow "redirection" maps? $self->{FORCE_TOP} = shift; + # Do we want to return the top-level map object (resource 0.0)? + $self->{RETURN_0} = shift; + # have we done that yet? + $self->{HAVE_RETURNED_0} = 0; + # Now, we need to pre-process the map, by walking forward and backward # over the parts of the map we're going to look at. @@ -1945,6 +1950,13 @@ sub new { sub next { my $self = shift; + # If we want to return the top-level map object, and haven't yet, + # do so. + if ($self->{RETURN_0} && !$self->{HAVE_RETURNED_0}) { + $self->{HAVE_RETURNED_0} = 1; + return $self->{NAV_MAP}->getById('0.0'); + } + if ($self->{RECURSIVE_ITERATOR_FLAG}) { # grab the next from the recursive iterator my $next = $self->{RECURSIVE_ITERATOR}->next();