--- rat/lonwrapper.pm 2017/05/07 13:58:04 1.61 +++ rat/lonwrapper.pm 2017/05/10 13:49:21 1.63 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Wrapper for external and binary files as standalone resources # -# $Id: lonwrapper.pm,v 1.61 2017/05/07 13:58:04 raeburn Exp $ +# $Id: lonwrapper.pm,v 1.63 2017/05/10 13:49:21 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,7 +42,8 @@ use LONCAPA qw(:DEFAULT :match);; # ================================================================ Main Handler sub wrapper { - my ($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,$title) = @_; + my ($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation, + $title,$width,$height) = @_; my $forcereg; unless ($env{'form.folderpath'}) { @@ -83,7 +84,7 @@ sub wrapper { my $startpage = &Apache::loncommon::start_page('Menu',undef,$args); my $endpage = &Apache::loncommon::end_page(); - if (($env{'browser.mobile'}) || ($exttool eq 'window')) { + if (($env{'browser.mobile'}) || ($exttool eq 'window') || ($exttool eq 'tab')) { my $output = $startpage; if ($is_pdf) { if ($title eq '') { @@ -99,14 +100,41 @@ sub wrapper { $output .= $title.'
'; } $output .= ''.&mt('Link to PDF (for mobile devices)').''; - } elsif ($exttool eq 'window') { + } elsif (($exttool eq 'window') || ($exttool eq 'tab')) { if ($linktext eq '') { $linktext = &mt('Launch External Tool'); } - $output .= '
'. - ''. - $linktext.''. - '
'; + if ($exttool eq 'tab') { + $output .= '
'. + ''. + $linktext.''. + '
'; + } else { + $output .= <<"ENDLINK"; + +
+ +$linktext +
+ENDLINK + } if ($explanation ne '') { $output .= '
'.$explanation.'
'; } @@ -171,7 +199,7 @@ sub handler { my $url = $r->uri; my ($is_ext,$brcrum,$absolute,$is_pdf,$exttool,$cdom,$cnum,$hostname, - $linktext,$explanation); + $linktext,$explanation,$width,$height); for ($url){ s|^/adm/wrapper||; @@ -183,13 +211,13 @@ sub handler { if ($url =~ /\.pdf$/i) { $is_pdf = 1; - } elsif ($url =~ m{^/adm/($match_domain)/($match_courseid)/(\d+)/exttool$}) { + } elsif ($url =~ m{^/adm/($match_domain)/($match_courseid)/(\d+)/ext\.tool$}) { $cdom = $1; $cnum = $2; my $marker = $3; $exttool = 'iframe'; my $exttoolremote; - my %toolhash = &Apache::lonnet::get('exttool_'.$marker,['target','linktext','explanation','id'], + my %toolhash = &Apache::lonnet::get('exttool_'.$marker,['target','linktext','explanation','id','width','height'], $cdom,$cnum); if ($toolhash{'id'}) { my %ltitools = &Apache::lonnet::get_domain_ltitools($cdom); @@ -198,11 +226,17 @@ sub handler { } } if ($toolhash{'target'} eq 'window') { - $exttool = 'window'; + $exttool = 'window'; + $width = $toolhash{'width'}; + $height = $toolhash{'height'}; + } elsif ($toolhash{'target'} eq 'tab') { + $exttool = 'tab'; + } + if (($exttool eq 'window') || ($exttool eq 'tab')) { $linktext = $toolhash{'linktext'}; $explanation = $toolhash{'explanation'}; } elsif (($exttoolremote =~ /^http:/) && ($ENV{'SERVER_PORT'} == 443)) { - $exttool = 'window'; + $exttool = 'tab'; } } if (($is_ext) || ($exttool)) { @@ -252,7 +286,7 @@ sub handler { # # Actual URL # - if ($url=~/$LONCAPA::assess_re/) { + if (($url=~/$LONCAPA::assess_re/) && (!$exttool)) { # # This is uploaded homework # @@ -277,7 +311,8 @@ sub handler { &Apache::lonenc::check_encrypt(\$url); } - $r->print( wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation) ); + $r->print( wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool, + $linktext,$explanation,undef,$width,$height) ); } # not just the menu