--- loncom/interface/lonnavmaps.pm 2002/10/03 19:10:28 1.62 +++ loncom/interface/lonnavmaps.pm 2002/10/03 19:40:33 1.63 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.62 2002/10/03 19:10:28 bowersj2 Exp $ +# $Id: lonnavmaps.pm,v 1.63 2002/10/03 19:40:33 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -888,11 +888,19 @@ sub new_handle { } } + my $currenturl = $ENV{'form.postdata'}; + $currenturl=~s/^http\:\/\///; + $currenturl=~s/^[^\/]+//; + my $queryAdd = "postdata=" . &Apache::lonnet::escape($currenturl); + + $r->print("$currenturl
"); + + # Begin the HTML table # four cols: resource + indent, chat+feedback, icon, text string $r->print('' ."\n"); - my $mapIterator = $navmap->getIterator(undef, undef, \%filterHash); + my $mapIterator = $navmap->getIterator(undef, undef, \%filterHash, 0); my $curRes = $mapIterator->next(); undef $res; # so we don't accidentally use it later my $indentLevel = -1; @@ -1028,13 +1036,13 @@ sub new_handle { my $mapId = $curRes->map_pc(); my $nowOpen = !defined($filterHash{$mapId}); $icon = $nowOpen ? - "folder_opened.gif" : "folder_closed.gif"; + "folder_closed.gif" : "folder_opened.gif"; $icon = "\"\""; $linkopen = ""; + $linkopen .= "&$queryAdd\">"; $linkclose = ""; } @@ -1428,7 +1436,7 @@ sub courseMapDefined { sub getIterator { my $self = shift; my $iterator = Apache::lonnavmaps::iterator->new($self, shift, shift, - shift, shift); + shift, undef, shift); return $iterator; } @@ -1637,7 +1645,7 @@ getIterator behaves as follows: =over 4 -=item B(nav_map, firstResource, finishResource, filterHash): 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(). It is your responsibility to ensure that the iterator will actually get there. 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 1, then only resource that exist IN the filterHash will be recursed on. If it is a 0, only resources NOT in the filterHash will be recursed on. Defaults to 0. +=item B(nav_map, firstResource, finishResource, filterHash, condition): 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(). It is your responsibility to ensure that the iterator will actually get there. 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, which is to say, do not recurse unless explicitly asked to. Thus, by default, all resources will be shown. Change the condition to a 1 without changing the hash, and only the top level of the map will be shown. Changing the condition to 1 and including some values in the hash will allow you to selectively examine parts of the navmap, while leaving it on 0 and adding things to the hash will allow you to selectively ignore parts of the nav map. See the handler code for examples. @@ -1689,6 +1697,7 @@ sub new { # A hash, used as a set, of resource already seen $self->{ALREADY_SEEN} = shift; if (!defined($self->{ALREADY_SEEN})) { $self->{ALREADY_SEEN} = {} }; + $self->{CONDITION} = shift; # Flag: Have we started yet? If not, the first action is to return BEGIN_MAP. $self->{STARTED} = 0; @@ -1859,7 +1868,7 @@ sub next { # If this is a map and we want to recurse down it... (not filtered out) if ($self->{HERE}->is_map() && - !defined($self->{FILTER}->{$self->{HERE}->map_pc()})) { + (defined($self->{FILTER}->{$self->{HERE}->map_pc()}) xor $self->{CONDITION})) { $self->{RECURSIVE_ITERATOR_FLAG} = 1; my $firstResource = $self->{HERE}->map_start(); my $finishResource = $self->{HERE}->map_finish(); @@ -1869,9 +1878,8 @@ sub next { # isn't MAIN::new, __PACKAGE__::new or Apache::lonnavmaps::iterator->new $self->{RECURSIVE_ITERATOR} = Apache::lonnavmaps::iterator->new ($self->{NAV_MAP}, $firstResource, - $finishResource, $self->{FILTER}, $self->{ALREADY_SEEN}); - # prime the new iterator with the first resource - #push @{$self->{RECURSIVE_ITERATOR}->{BRANCH_STACK}}, $firstResource; + $finishResource, $self->{FILTER}, $self->{ALREADY_SEEN}, + $self->{CONDITION}); } return $self->{HERE};