--- loncom/interface/londocs.pm 2016/08/08 13:37:42 1.484.2.65 +++ loncom/interface/londocs.pm 2016/10/31 20:48:30 1.484.2.66 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.484.2.65 2016/08/08 13:37:42 raeburn Exp $ +# $Id: londocs.pm,v 1.484.2.66 2016/10/31 20:48:30 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -3608,7 +3608,7 @@ END } } - 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/}; @@ -3630,11 +3630,28 @@ END $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=''; } } + } 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') { @@ -3702,6 +3719,9 @@ $form_end; if ($isexternal && $orderidx) { $url .= '&idx='.$orderidx; } + if ($anchor ne '') { + $url .= '&anchor='.&HTML::Entities::encode($anchor,'"<>&'); + } } my ($tdalign,$tdwidth); if ($allowed) { @@ -3714,13 +3734,17 @@ $form_end; 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 = ''.&mt('Edit').' '."\n"; @@ -3740,7 +3764,15 @@ $form_end; if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) { $line.=''; } elsif ($url) { - $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes', + 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 '')?$anchor:''), '',600,500); } else { $line.=''; @@ -3749,7 +3781,8 @@ $form_end; if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) { $line.=''.$title.''; } elsif ($url) { - $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes', + $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'. + (($anchor ne '')?$anchor:''), $title,600,500); } else { $line.=$title.' '.$reinit.''; @@ -5898,8 +5931,19 @@ sub editing_js { 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';