--- loncom/interface/lonnavmaps.pm 2002/10/28 21:11:39 1.90
+++ loncom/interface/lonnavmaps.pm 2002/10/29 20:17:39 1.91
@@ -2,7 +2,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.90 2002/10/28 21:11:39 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.91 2002/10/29 20:17:39 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -926,17 +926,21 @@ sub new_handle {
my $queryAdd = "postdata=" . &Apache::lonnet::escape($currenturl) .
"&alreadyHere=1";
- $r->print('Show All Resources
');
-
- # Begin the HTML table
- # four cols: resource + indent, chat+feedback, icon, text string
- $r->print('
' ."\n");
-
my $condition = 0;
if ($ENV{'form.condition'}) {
$condition = 1;
}
+ if ($condition) {
+ $r->print('Close All Folders
');
+ } else {
+ $r->print('Open All Folders
');
+ }
+
+ # Begin the HTML table
+ # four cols: resource + indent, chat+feedback, icon, text string
+ $r->print('' ."\n");
+
# This needs to be updated to use symbs from the remote,
# instead of uris. The changes to this and the main rendering
# loop should be obvious.
@@ -946,8 +950,12 @@ sub new_handle {
my $mapIterator = $navmap->getIterator(undef, undef, {}, 1);
my $found = 0;
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
my $curRes = $mapIterator->next();
+ my $counter = 0;
while ($depth > 0) {
if ($curRes == $mapIterator->BEGIN_MAP()) {
@@ -957,12 +965,16 @@ sub new_handle {
$depth--;
}
+ if (ref($curRes)) { $counter++; }
+
my $mapStack = $mapIterator->getStack();
if ($currenturl && !$ENV{'form.alreadyHere'} && ref($curRes) &&
$curRes->src() eq $currenturl) {
# If this is the correct resource, be sure to
# show it by making sure the containing maps
# are open.
+
+ $currentUrlIndex = $counter;
for my $map (@{$mapStack}) {
if ($condition) {
@@ -1009,6 +1021,8 @@ sub new_handle {
my @backgroundColors = ("#FFFFFF", "#F6F6F6");
my $rowNum = 0;
+ $counter = 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
@@ -1041,6 +1055,8 @@ sub new_handle {
$depth--;
}
+ if (ref($curRes)) { $counter++; }
+
if ($depth == 1) { $deltadepth = 0; } # we're done shifting, because we're
# out of the inlined map
@@ -1231,9 +1247,17 @@ sub new_handle {
$rowNum++;
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(" \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('');
+ }
+
# print indentation
for (my $i = 0; $i < $indentLevel - $deltalevel + $deltadepth; $i++) {
$r->print($indentString);
@@ -2207,7 +2231,7 @@ sub next {
$self->{RECURSIVE_ITERATOR} =
Apache::lonnavmaps::iterator->new ($self->{NAV_MAP}, $firstResource,
$finishResource, $self->{FILTER}, $self->{ALREADY_SEEN},
- $self->{CONDITION});
+ $self->{CONDITION}, $self->{DIRECTION});
}
return $self->{HERE};
|