[LON-CAPA-cvs] cvs: loncom /interface lonnavmaps.pm rat lonpage.pm

albertel lon-capa-cvs@mail.lon-capa.org
Sun, 12 Dec 2004 21:06:37 -0000


albertel		Sun Dec 12 16:06:37 2004 EDT

  Modified files:              
    /rat	lonpage.pm 
    /loncom/interface	lonnavmaps.pm 
  Log:
  - links to resources in .page uses the anchors in there
  - anchors are now symbs
  - anchors are now encyrpted
  - symb passed is for the .page not the individual resource, fixes #3711
  
  
  
Index: rat/lonpage.pm
diff -u rat/lonpage.pm:1.64 rat/lonpage.pm:1.65
--- rat/lonpage.pm:1.64	Fri Dec 10 14:59:55 2004
+++ rat/lonpage.pm	Sun Dec 12 16:06:36 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Page Handler
 #
-# $Id: lonpage.pm,v 1.64 2004/12/10 19:59:55 albertel Exp $
+# $Id: lonpage.pm,v 1.65 2004/12/12 21:06:36 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -434,11 +434,14 @@
                               my $rid=$colcont[$j];
                               my $metainfo = '';
 			      my $esrc=&Apache::lonnet::declutter($hash{'src_'.$rid});
+			      my ($mapid,$resid)=split(/\./,$rid);
+			      my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$hash{'src_'.$rid});
 			      if ($hash{'encrypted_'.$rid}) {
+				  $symb=&Apache::lonenc::encrypted($symb);
 				  $esrc=&Apache::lonenc::encrypted($esrc);
 			      }
                               unless ($hash{'src_'.$rid} =~ m-^/uploaded/-) { 
-                                  $metainfo ='<a name="'.&Apache::lonnet::escape($esrc).'" />'.
+                                  $metainfo ='<a name="'.&Apache::lonnet::escape($symb).'" />'.
                                   '<a href="'.$metalink{$rid}.'" target="LONcatInfo">'.
                                   '<img src="/adm/lonMisc/cat_button.gif" border=0>'.
                                   '</img></a>';
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.307 loncom/interface/lonnavmaps.pm:1.308
--- loncom/interface/lonnavmaps.pm:1.307	Tue Dec  7 17:58:05 2004
+++ loncom/interface/lonnavmaps.pm	Sun Dec 12 16:06:36 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.307 2004/12/07 22:58:05 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.308 2004/12/12 21:06:36 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -435,7 +435,6 @@
 
 # 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 @@
     # 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 @@
         if (defined($_)) { $res = $_; }
     }
 
-    return $res->link();
+    return ($res->link(),$res->shown_symb());
 }
 
 # Convenience function: This separates the logic of how to create
@@ -1857,22 +1860,19 @@
 
             # Set up some data about the parts that the cols might want
             my $filter = $it->{FILTER};
-	    my $src;
+	    my ($src,$symb,$anchor);
 	    if ($args->{'sort'}) {
 		$src = $curRes->src(); # FIXME this is wrong for .pages
+		$symb = $curRes->symb(); # FIXME this is wrong for .pages
 	    } else {
 		my $stack = $it->getStack();
-		$src=getLinkForResource($stack);
-	    }
-            my $anchor='';
-            if ($src=~s/(\#.*)$//) {
-		$anchor=$1;
+		($src,$symb,$anchor)=getLinkForResource($stack);
 	    }
+	    if (defined($anchor)) { $anchor='#'.$anchor; }
             my $srcHasQuestion = $src =~ /\?/;
             $args->{"resourceLink"} = $src.
                 ($srcHasQuestion?'&':'?') .
-                'symb=' . &Apache::lonnet::escape($curRes->shown_symb()).
-		$anchor;
+                'symb=' . &Apache::lonnet::escape($symb).$anchor;
 
             # Now, display each column.
             foreach my $col (@$cols) {