--- rat/lonwrapper.pm 2017/06/22 02:11:30 1.49.2.4.2.1
+++ rat/lonwrapper.pm 2017/05/08 14:20:32 1.62
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Wrapper for external and binary files as standalone resources
#
-# $Id: lonwrapper.pm,v 1.49.2.4.2.1 2017/06/22 02:11:30 raeburn Exp $
+# $Id: lonwrapper.pm,v 1.62 2017/05/08 14:20:32 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -38,18 +38,16 @@ use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::lonextresedit();
use Apache::lonexttool();
-use LONCAPA qw(:DEFAULT :match);
+use LONCAPA qw(:DEFAULT :match);;
# ================================================================ Main Handler
sub wrapper {
- my ($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,
- $title,$width,$height) = @_;
+ my ($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,$title) = @_;
my $forcereg;
unless ($env{'form.folderpath'}) {
$forcereg = 1;
}
-
my %lt = &Apache::lonlocal::texthash(
'noif' => 'No iframe support.',
'show' => 'Show content in pop-up window',
@@ -84,8 +82,8 @@ sub wrapper {
my $startpage = &Apache::loncommon::start_page('Menu',undef,$args);
my $endpage = &Apache::loncommon::end_page();
-
- if (($env{'browser.mobile'}) || ($exttool eq 'window') || ($exttool eq 'tab')) {
+
+ if (($env{'browser.mobile'}) || ($exttool eq 'window')) {
my $output = $startpage;
if ($is_pdf) {
if ($title eq '') {
@@ -101,43 +99,14 @@ sub wrapper {
$output .= $title.'
';
}
$output .= ''.&mt('Link to PDF (for mobile devices)').'';
- } elsif (($exttool eq 'window') || ($exttool eq 'tab')) {
+ } elsif ($exttool eq 'window') {
if ($linktext eq '') {
$linktext = &mt('Launch External Tool');
}
- if ($exttool eq 'tab') {
- $output .= '
';
- } else {
- $output .= <<"ENDLINK";
-
-
-ENDLINK
- }
+ $output .= '';
if ($explanation ne '') {
$output .= ''.$explanation.'
';
}
@@ -201,8 +170,8 @@ sub handler {
return OK if $r->header_only;
my $url = $r->uri;
- my ($is_ext,$brcrum,$absolute,$is_pdf,$exttool,$cdom,$cnum,
- $linktext,$explanation,$width,$height);
+ my ($is_ext,$brcrum,$absolute,$is_pdf,$exttool,$cdom,$cnum,$hostname,
+ $linktext,$explanation);
for ($url){
s|^/adm/wrapper||;
@@ -211,6 +180,7 @@ sub handler {
s|:|:|g;
}
+
if ($url =~ /\.pdf$/i) {
$is_pdf = 1;
} elsif ($url =~ m{^/adm/($match_domain)/($match_courseid)/(\d+)/ext\.tool$}) {
@@ -219,7 +189,7 @@ sub handler {
my $marker = $3;
$exttool = 'iframe';
my $exttoolremote;
- my %toolhash = &Apache::lonnet::get('exttool_'.$marker,['target','linktext','explanation','id','width','height'],
+ my %toolhash = &Apache::lonnet::get('exttool_'.$marker,['target','linktext','explanation','id'],
$cdom,$cnum);
if ($toolhash{'id'}) {
my %ltitools = &Apache::lonnet::get_domain_ltitools($cdom);
@@ -228,20 +198,13 @@ sub handler {
}
}
if ($toolhash{'target'} eq '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'};
+ $exttool = 'window';
+ $linktext = $toolhash{'linktext'};
$explanation = $toolhash{'explanation'};
} elsif (($exttoolremote =~ /^http:/) && ($ENV{'SERVER_PORT'} == 443)) {
- $exttool = 'tab';
+ $exttool = 'window';
}
}
-
if (($is_ext) || ($exttool)) {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['forceedit','register','folderpath','symb','idx','title','anchor']);
@@ -262,18 +225,24 @@ sub handler {
my $type = 'ext';
if ($exttool) {
$type = 'tool';
+ } 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));
+ $cnum,$hostname));
return OK;
} elsif ($env{'form.folderpath'} =~ /^supplemental/) {
my $crstype = &Apache::loncommon::course_type();
my $title = $env{'form.title'};
if ($title eq '') {
- $title = &mt('External Resource');
+ if ($is_ext) {
+ $title = &mt('External Resource');
+ } else {
+ $title = &mt('External Tool');
+ }
}
$brcrum =
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
@@ -308,8 +277,7 @@ sub handler {
&Apache::lonenc::check_encrypt(\$url);
}
- $r->print( wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,
- $linktext,$explanation,undef,$width,$height) );
+ $r->print( wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation) );
} # not just the menu
@@ -336,7 +304,7 @@ described at http://www.lon-capa.org.
=over
-=item wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$title))
+=item wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$title))
=over