--- loncom/interface/lonnavmaps.pm 2004/12/02 22:50:16 1.306
+++ loncom/interface/lonnavmaps.pm 2004/12/14 15:56:41 1.310
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.306 2004/12/02 22:50:16 foxr Exp $
+# $Id: lonnavmaps.pm,v 1.310 2004/12/14 15:56:41 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -377,7 +377,7 @@ ENDSUBM
-
+
");
@@ -435,7 +435,6 @@ sub removeFromFilter {
# Convenience function: Given a stack returned from getStack on the iterator,
# return the correct src() value.
-# Later, this should add an anchor when we start putting anchors in pages.
sub getLinkForResource {
my $stack = shift;
my $res;
@@ -443,14 +442,18 @@ sub getLinkForResource {
# Check to see if there are any pages in the stack
foreach $res (@$stack) {
if (defined($res)) {
+ my $anchor;
if ($res->is_page()) {
- return $res->link();
+ foreach (@$stack) { if (defined($_)) { $anchor = $_; } }
+ $anchor=&Apache::lonnet::escape($anchor->shown_symb());
+ return ($res->link(),$res->shown_symb(),$anchor);
}
# in case folder was skipped over as "only sequence"
my ($map,$id,$src)=&Apache::lonnet::decode_symb($res->symb());
if ($map=~/\.page$/) {
- return &Apache::lonnet::clutter($map).'#'.
- &Apache::lonnet::escape(&Apache::lonnet::declutter($src));
+ my $url=&Apache::lonnet::clutter($map);
+ $anchor=&Apache::lonnet::escape($src->shown_symb());
+ return ($url,$res->shown_symb(),$anchor);
}
}
}
@@ -463,7 +466,7 @@ sub getLinkForResource {
if (defined($_)) { $res = $_; }
}
- return $res->link();
+ return ($res->link(),$res->shown_symb());
}
# Convenience function: This separates the logic of how to create
@@ -1126,7 +1129,7 @@ sub render_resource {
!$params->{'condensed'}) {
my $displaypart=$resource->part_display($part);
$partLabel = " (Part: $displaypart)";
- $link.='#'.&Apache::lonnet::escape($part);
+ if ($link!~/\#/) { $link.='#'.&Apache::lonnet::escape($part); }
$title = "";
}
@@ -1846,7 +1849,26 @@ END
# Add part 0 so we display it correctly.
unshift @parts, '0';
}
-
+
+ {
+ my ($src,$symb,$anchor,$stack);
+ if ($args->{'sort'}) {
+ my $it = $navmap->getIterator(undef, undef, undef, 1);
+ while ( my $res=$it->next()) {
+ if (ref($res) &&
+ $res->symb() eq $curRes->symb()) { last; }
+ }
+ $stack=$it->getStack();
+ } else {
+ $stack=$it->getStack();
+ }
+ ($src,$symb,$anchor)=getLinkForResource($stack);
+ if (defined($anchor)) { $anchor='#'.$anchor; }
+ my $srcHasQuestion = $src =~ /\?/;
+ $args->{"resourceLink"} = $src.
+ ($srcHasQuestion?'&':'?') .
+ 'symb=' . &Apache::lonnet::escape($symb).$anchor;
+ }
# Now, we've decided what parts to show. Loop through them and
# show them.
foreach my $part (@parts) {
@@ -1857,22 +1879,6 @@ END
# Set up some data about the parts that the cols might want
my $filter = $it->{FILTER};
- my $src;
- if ($args->{'sort'}) {
- $src = $curRes->src(); # FIXME this is wrong for .pages
- } else {
- my $stack = $it->getStack();
- $src=getLinkForResource($stack);
- }
- my $anchor='';
- if ($src=~s/(\#.*)$//) {
- $anchor=$1;
- }
- my $srcHasQuestion = $src =~ /\?/;
- $args->{"resourceLink"} = $src.
- ($srcHasQuestion?'&':'?') .
- 'symb=' . &Apache::lonnet::escape($curRes->shown_symb()).
- $anchor;
# Now, display each column.
foreach my $col (@$cols) {