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

raeburn raeburn at source.lon-capa.org
Mon Oct 31 15:49:06 EDT 2016


raeburn		Mon Oct 31 19:49:06 2016 EDT

  Modified files:              
    /loncom/interface	londocs.pm lonhtmlcommon.pm lonmenu.pm 
    /rat	lonwrapper.pm 
  Log:
  - Bug 6806. Support anchor in URL set for an external resource within the 
    "Supplemental Content" area.
  
  
-------------- next part --------------
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.609 loncom/interface/londocs.pm:1.610
--- loncom/interface/londocs.pm:1.609	Mon Oct 31 12:59:03 2016
+++ loncom/interface/londocs.pm	Mon Oct 31 19:48:59 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.609 2016/10/31 12:59:03 raeburn Exp $
+# $Id: londocs.pm,v 1.610 2016/10/31 19:48:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3927,6 +3927,13 @@
                 $url='';
             }
 	}
+    } elsif ($supplementalflag) { 
+        if ($isexternal) {
+            if ($url =~ /^([^#]+)#([^#]+)$/) {
+                $url = $1;
+                $anchor = $2;
+            }
+        }
     }
     my ($rand_pick_text,$rand_order_text);
     if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
@@ -3999,6 +4006,9 @@
         if ((($isexternal) || ($isexttool)) && $orderidx) {
             $url .= '&idx='.$orderidx;
         }
+        if ($anchor ne '') {
+            $url .= '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
+        }
     }
     my ($tdalign,$tdwidth);
     if ($allowed) {
@@ -4016,13 +4026,17 @@
             my ($cfile,$home,$switchserver,$forceedit,$forceview) = 
                 &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
             if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
+                my $suppanchor;
+                if ($supplementalflag) {
+                    $suppanchor = $anchor;
+                }
                 my $jscall = 
                     &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
                                                             $switchserver,
                                                             $forceedit,
                                                             undef,$symb,
                                                             &escape($env{'form.folderpath'}),
-                                                            $renametitle,'','',1);
+                                                            $renametitle,'','',1,$suppanchor);
                 if ($jscall) {
                     $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
                                 $jscall.'" >'.&mt('Edit').'</a> '."\n";
@@ -4042,8 +4056,15 @@
     if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
        $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
     } elsif ($url) {
+       if ($anchor ne '') {
+           if ($supplementalflag) {
+               $anchor = '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
+           } else {
+               $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
+           }
+       }
        $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
-                                             (($anchor ne '')?'#'.&HTML::Entities::encode($anchor,'"<>&'):''),
+                                             (($anchor ne '')?$anchor:''),
                                              '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
     } else {
        $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
@@ -4053,7 +4074,7 @@
        $line.='<a href="'.$url.'">'.$title.'</a>';
     } elsif ($url) {
        $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
-                                             (($anchor ne '')?'#'.&HTML::Entities::encode($anchor,'"<>&'):''),
+                                             (($anchor ne '')?$anchor:''),
                                              $title,600,500);
     } else {
        $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.375 loncom/interface/lonhtmlcommon.pm:1.376
--- loncom/interface/lonhtmlcommon.pm:1.375	Mon Oct 31 12:59:03 2016
+++ loncom/interface/lonhtmlcommon.pm	Mon Oct 31 19:49:00 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.375 2016/10/31 12:59:03 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.376 2016/10/31 19:49:00 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3495,7 +3495,7 @@
 
 sub jump_to_editres {
     my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb,$folderpath,
-        $title,$idx,$suppurl,$todocs) = @_;
+        $title,$idx,$suppurl,$todocs,$suppanchor) = @_;
     my ($jscall,$anchor);
     if ($switchserver) {
         if ($home) {
@@ -3549,7 +3549,11 @@
                 $cfile .= (($cfile=~/\?/)?'&':'?').'register=1';
             }
             if ($todocs) {
-               $cfile .= (($cfile=~/\?/)?'&':'?').'todocs=1';
+                $cfile .= (($cfile=~/\?/)?'&':'?').'todocs=1';
+            }
+            if ($suppanchor ne '') {
+                $cfile .= (($cfile=~/\?/)?'&':'?').'anchor='.
+                          &HTML::Entities::encode($suppanchor,'"<>&');
             }
         }
         if ($anchor ne '') {
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.458 loncom/interface/lonmenu.pm:1.459
--- loncom/interface/lonmenu.pm:1.458	Sat Oct 29 05:29:28 2016
+++ loncom/interface/lonmenu.pm	Mon Oct 31 19:49:00 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.458 2016/10/29 05:29:28 raeburn Exp $
+# $Id: lonmenu.pm,v 1.459 2016/10/31 19:49:00 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1044,11 +1044,16 @@
         $folderpath = &escape(&HTML::Entities::encode(&escape($folderpath),'<>&"'));
         $jscall = "go('/adm/coursedocs?folderpath=$folderpath$command')";
     } else {
+        my $suppanchor;
+        if ($env{'form.folderpath'}) {
+            $suppanchor = $env{'form.anchor'};
+        }
         $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
                                                 $forceedit,$forcereg,$env{'request.symb'},
                                                 &escape($env{'form.folderpath'}),
                                                 &escape($env{'form.title'}),$env{'form.idx'},
-                                                &escape($env{'form.suppurl'},$env{'form.todocs'}));
+                                                &escape($env{'form.suppurl'}),$env{'form.todocs'},
+                                                $suppanchor);
     }
     if ($jscall) {
         my $icon = 'pcstr.png';
@@ -1205,9 +1210,13 @@
              ($resurl =~ m{^/adm/$match_domain/$match_username/aboutme$}))) {
             my @folders=split('&',$env{'form.folderpath'});
             if ((@folders > 2) || ($resurl ne '/adm/supplemental')) {
+                my $suppanchor;
+                if ($resurl =~ m{^/adm/wrapper/ext/}) {
+                    $suppanchor = $env{'form.anchor'};
+                }
                 my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"'));
                 &switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
-                        "location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path'",
+                        "location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path&anchor=$suppanchor'",
                         'Folder/Page Content');
             }
         }
Index: rat/lonwrapper.pm
diff -u rat/lonwrapper.pm:1.52 rat/lonwrapper.pm:1.53
--- rat/lonwrapper.pm:1.52	Mon Oct 31 12:59:11 2016
+++ rat/lonwrapper.pm	Mon Oct 31 19:49:05 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Wrapper for external and binary files as standalone resources
 #
-# $Id: lonwrapper.pm,v 1.52 2016/10/31 12:59:11 raeburn Exp $
+# $Id: lonwrapper.pm,v 1.53 2016/10/31 19:49:05 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -54,10 +54,14 @@
                                         );
 
     my $anchor;
-    if (($is_ext) && ($env{'form.symb'})) {
-        (undef,undef,my $res) = &Apache::lonnet::decode_symb($env{'form.symb'});
-        if ($res =~ /(#[^#]+)$/) {
-            $anchor = $1;
+    if ($is_ext) {
+        if ($env{'form.symb'}) {
+            (undef,undef,my $res) = &Apache::lonnet::decode_symb($env{'form.symb'});
+            if ($res =~ /(#[^#]+)$/) {
+                $anchor = $1;
+            }
+        } elsif ($env{'form.anchor'} ne '') {
+            $anchor = '#'.$env{'form.anchor'};
         }
     }
 
@@ -176,14 +180,20 @@
     }
     if (($is_ext) || ($exttool)) {
         &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
-            ['forceedit','register','folderpath','symb','idx','title']);
+            ['forceedit','register','folderpath','symb','idx','title','anchor']);
         if (($env{'form.forceedit'}) &&
             (&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;
+            if ($env{'form.symb'}) {
+                (undef,undef,my $res) = &Apache::lonnet::decode_symb($env{'form.symb'});
+                if ($res =~ /(#[^#]+)$/) {
+                    $url .= $1;
+                }
+            } elsif ($env{'form.folderpath'} =~ /^supplemental/) {
+                if ($env{'form.anchor'} ne '') {
+                    $url .= '#'.$env{'form.anchor'};
+                }
             }
             my $type = 'ext';
             my %ltitools;


More information about the LON-CAPA-cvs mailing list