[LON-CAPA-cvs] cvs: rat / lonwrapper.pm loncom/interface londocs.pm lonhtmlcommon.pm

raeburn raeburn at source.lon-capa.org
Mon Oct 31 08:59:11 EDT 2016


raeburn		Mon Oct 31 12:59:11 2016 EDT

  Modified files:              
    /loncom/interface	londocs.pm lonhtmlcommon.pm 
    /rat	lonwrapper.pm 
  Log:
  - Bug 6806. Support anchor in URL set for an external resource.
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.608 loncom/interface/londocs.pm:1.609
--- loncom/interface/londocs.pm:1.608	Fri Jul  1 19:59:36 2016
+++ loncom/interface/londocs.pm	Mon Oct 31 12:59:03 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.608 2016/07/01 19:59:36 raeburn Exp $
+# $Id: londocs.pm,v 1.609 2016/10/31 12:59:03 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3888,7 +3888,7 @@
 	}
     }
 
-    my ($editlink,$extresform);
+    my ($editlink,$extresform,$anchor);
     my $orig_url = $url;
     $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
     $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
@@ -3912,7 +3912,17 @@
 		$url='/adm/wrapper'.$url;
             }
             if (&Apache::lonnet::symbverify($symb,$url)) {
-	        $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
+                my $shownsymb = $symb;
+                if ($isexternal) {
+                    if ($url =~ /^([^#]+)#([^#]+)$/) {
+                        $url = $1;
+                        $anchor = $2;
+                        if ($symb =~ m{^([^#]+)\Q#$anchor\E$}) {
+                            $shownsymb = $1.&escape('#').$anchor;
+                        }
+                    }
+                }
+                $url.=(($url=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');
             } else {
                 $url='';
             }
@@ -4032,7 +4042,8 @@
     if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
        $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
     } elsif ($url) {
-       $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
+       $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
+                                             (($anchor ne '')?'#'.&HTML::Entities::encode($anchor,'"<>&'):''),
                                              '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
     } else {
        $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
@@ -4041,7 +4052,8 @@
     if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
        $line.='<a href="'.$url.'">'.$title.'</a>';
     } elsif ($url) {
-       $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
+       $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
+                                             (($anchor ne '')?'#'.&HTML::Entities::encode($anchor,'"<>&'):''),
                                              $title,600,500);
     } else {
        $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
@@ -6542,8 +6554,19 @@
             my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
             $res = &Apache::lonnet::clutter($res);
             if (&Apache::lonnet::is_on_map($res)) {
-                $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='.
+                my ($url,$anchor);
+                if ($res =~ /^([^#]+)#([^#]+)$/) {
+                    $url = $1;
+                    $anchor = $2;
+                    if (($caller =~ m{^([^#]+)\Q#$anchor\E$})) {
+                        $caller = $1.&escape('#').$anchor;
+                    }
+                }
+                $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"').'?symb='.
                              &HTML::Entities::encode($caller,'<>&"');
+                if ($anchor ne '') {
+                    $backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"');
+                }
                 $backtourl = &Apache::loncommon::escape_single($backtourl);
             } else {
                 $backtourl = '/adm/navmaps';
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.374 loncom/interface/lonhtmlcommon.pm:1.375
--- loncom/interface/lonhtmlcommon.pm:1.374	Sun Oct 16 21:20:51 2016
+++ loncom/interface/lonhtmlcommon.pm	Mon Oct 31 12:59:03 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.374 2016/10/16 21:20:51 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.375 2016/10/31 12:59:03 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3496,7 +3496,7 @@
 sub jump_to_editres {
     my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb,$folderpath,
         $title,$idx,$suppurl,$todocs) = @_;
-    my $jscall;
+    my ($jscall,$anchor);
     if ($switchserver) {
         if ($home) {
             $cfile = '/adm/switchserver?otherserver='.$home.'&role='.
@@ -3516,7 +3516,16 @@
         }
     } else {
         unless ($cfile =~ m{^/priv/}) {
+            if ($cfile =~ m{^(/adm/wrapper/ext/[^#]+)#([^#]+)$}) {
+                $cfile = $1;
+                $anchor = $2;
+            }
             if ($symb) {
+                if ($anchor ne '') {
+                    if ($symb =~ m{^([^#]+)\Q#$anchor\E$}) {
+                        $symb = $1.&escape(&escape('#')).$anchor;
+                    }
+                }
                 $cfile .= (($cfile=~/\?/)?'&':'?')."symb=$symb";
             } elsif ($folderpath) {
                 $cfile .= (($cfile=~/\?/)?'&':'?').
@@ -3543,6 +3552,9 @@
                $cfile .= (($cfile=~/\?/)?'&':'?').'todocs=1';
             }
         }
+        if ($anchor ne '') {
+            $cfile .= '#'.$anchor;
+        }
         $jscall = "go('".&Apache::loncommon::escape_single($cfile)."')";
     }
     return $jscall;
Index: rat/lonwrapper.pm
diff -u rat/lonwrapper.pm:1.51 rat/lonwrapper.pm:1.52
--- rat/lonwrapper.pm:1.51	Mon Feb 22 03:36:52 2016
+++ rat/lonwrapper.pm	Mon Oct 31 12:59:11 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Wrapper for external and binary files as standalone resources
 #
-# $Id: lonwrapper.pm,v 1.51 2016/02/22 03:36:52 raeburn Exp $
+# $Id: lonwrapper.pm,v 1.52 2016/10/31 12:59:11 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -56,7 +56,7 @@
     my $anchor;
     if (($is_ext) && ($env{'form.symb'})) {
         (undef,undef,my $res) = &Apache::lonnet::decode_symb($env{'form.symb'});
-        if ($res =~ /(\#.+)$/) {
+        if ($res =~ /(#[^#]+)$/) {
             $anchor = $1;
         }
     }
@@ -181,6 +181,10 @@
             (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&
             (($env{'form.folderpath'} =~ /^supplemental/) ||
              ($env{'form.symb'} =~ /^uploaded/))) {
+            (undef,undef,my $res) = &Apache::lonnet::decode_symb($env{'form.symb'});
+            if ($res =~ /(#[^#]+)$/) {
+                 $url .= $1;
+            }
             my $type = 'ext';
             my %ltitools;
             if ($exttool) {




More information about the LON-CAPA-cvs mailing list