--- loncom/interface/lonnavmaps.pm 2002/10/28 21:11:39 1.90
+++ loncom/interface/lonnavmaps.pm 2002/10/29 20:20:45 1.92
@@ -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.92 2002/10/29 20:20:45 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -820,7 +820,7 @@ sub new_handle {
&Apache::loncommon::no_cache($r);
$r->send_http_header;
- # Initialize the nav map
+ # Create the nav map the nav map
my $navmap = Apache::lonnavmaps::navmap->new(
$ENV{"request.course.fn"}.".db",
$ENV{"request.course.fn"}."_parms.db", 1, 1);
@@ -850,6 +850,9 @@ sub new_handle {
'
New message (click to open)
');
}
+ # Now that we've displayed some stuff to the user, init the navmap
+ $navmap->init();
+
# Check that it's defined
if (!($navmap->courseMapDefined())) {
$r->print('Coursemap undefined.' .
@@ -926,17 +929,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 +953,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 +968,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 +1024,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 +1058,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 +1250,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);
@@ -1616,6 +1643,14 @@ sub new {
$self->{PARM_HASH} = \%parmhash;
$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,
# generate them
if ($self->{GENERATE_COURSE_USER_OPT}) {
@@ -1720,10 +1755,6 @@ sub new {
}
$self->{PARM_CACHE} = {};
-
- bless($self);
-
- return $self;
}
# Checks to see if coursemap is defined, matching test in old lonnavmaps
@@ -2207,7 +2238,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};
|