--- rat/lonwrapper.pm 2016/01/26 14:30:40 1.50 +++ rat/lonwrapper.pm 2017/04/25 22:19:03 1.60 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Wrapper for external and binary files as standalone resources # -# $Id: lonwrapper.pm,v 1.50 2016/01/26 14:30:40 raeburn Exp $ +# $Id: lonwrapper.pm,v 1.60 2017/04/25 22:19:03 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,7 +42,7 @@ use LONCAPA qw(:DEFAULT :match);; # ================================================================ Main Handler sub wrapper { - my ($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$title) = @_; + my ($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,$title) = @_; my $forcereg; unless ($env{'form.folderpath'}) { @@ -53,7 +53,19 @@ sub wrapper { 'show' => 'Show content in pop-up window', ); - my $noiframe = &Apache::loncommon::modal_link($url,$lt{'show'},500,400); + my $anchor; + 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'}; + } + } + + my $noiframe = &Apache::loncommon::modal_link($url.$anchor,$lt{'show'},500,400); my $args = {'bgcolor' => '#FFFFFF'}; if ($forcereg) { $args->{'force_register'} = $forcereg; @@ -62,7 +74,10 @@ sub wrapper { $args->{'bread_crumbs'} = $brcrum; } if ($absolute) { - $args->{'use_absolute'} = $absolute; + $args->{'use_absolute'} = $absolute; + } + if ($env{'form.only_body'}) { + $args->{'only_body'} = $env{'form.only_body'}; } my $startpage = &Apache::loncommon::start_page('Menu',undef,$args); @@ -85,13 +100,19 @@ sub wrapper { } $output .= ''.&mt('Link to PDF (for mobile devices)').''; } elsif ($exttool eq 'window') { + if ($linktext eq '') { + $linktext = &mt('Launch External Tool'); + } $output .= '
'. ''. - &mt('Launch External Tool').''. + $linktext.''. '
'; + if ($explanation ne '') { + $output .= '
'.$explanation.'
'; + } } else { $output .= '
'."\n". - '\n". "
\n"; @@ -99,11 +120,16 @@ sub wrapper { $output .= $endpage; return $output; } else { + my $offset = 5; + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']); + if ($env{'form.inhibitmenu'} eq 'yes') { + $offset = 0; + } my $script = &Apache::lonhtmlcommon::scripttag(< - + $endpage ENDFRAME @@ -144,7 +170,8 @@ sub handler { return OK if $r->header_only; my $url = $r->uri; - my ($is_ext,$brcrum,$absolute,$is_pdf,$exttool,$cdom,$cnum); + my ($is_ext,$brcrum,$absolute,$is_pdf,$exttool,$cdom,$cnum,$hostname, + $linktext,$explanation); for ($url){ s|^/adm/wrapper||; @@ -161,29 +188,42 @@ sub handler { $cnum = $2; my $marker = $3; $exttool = 'iframe'; - my %toolhash = &Apache::lonnet::get('exttool_'.$marker,['target'],$cdom,$cnum); + my %toolhash = &Apache::lonnet::get('exttool_'.$marker,['target','linktext','explanation'], + $cdom,$cnum); if ($toolhash{'target'} eq 'window') { - $exttool = 'window'; + $exttool = 'window'; + $linktext = $toolhash{'linktext'}; + $explanation = $toolhash{'explanation'}; } } 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/))) { + 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; if ($exttool) { $type = 'tool'; - %ltitools = &Apache::lonnet::get_domain_ltitools($cdom); + } elsif (($url =~ /^http:/) && ($ENV{'SERVER_PORT'} == 443)) { + $hostname = $r->hostname(); } $r->print( &Apache::lonextresedit::display_editor($url,$env{'form.folderpath'}, $env{'form.symb'}, $env{'form.idx'},$type,$cdom, - $cnum,\%ltitools)); + $cnum,$hostname)); return OK; } elsif ($env{'form.folderpath'} =~ /^supplemental/) { my $crstype = &Apache::loncommon::course_type(); @@ -224,11 +264,11 @@ sub handler { } # encrypt url if not external - unless ($is_ext || $exttool) { + unless ($is_ext) { &Apache::lonenc::check_encrypt(\$url); } - $r->print( wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool) ); + $r->print( wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation) ); } # not just the menu