--- rat/lonwrapper.pm 2020/04/07 20:39:03 1.49.2.4.4.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.4.1 2020/04/07 20:39:03 raeburn Exp $
+# $Id: lonwrapper.pm,v 1.62 2017/05/08 14:20:32 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -37,18 +37,17 @@ use Apache::lonlocal;
use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::lonextresedit();
-use LONCAPA qw(:DEFAULT :match);
+use Apache::lonexttool();
+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',
@@ -83,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 '') {
@@ -100,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.'
';
}
@@ -200,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||;
@@ -210,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$}) {
@@ -218,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);
@@ -227,17 +198,11 @@ 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)) {
@@ -260,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);
@@ -306,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
@@ -334,7 +304,7 @@ described at http://www.lon-capa.org.
=over
-=item wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,$title,$width,$height)
+=item wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$title))
=over
@@ -376,22 +346,6 @@ true if URL is for an external resource.
true if URL is for a PDF (based on file extension).
-=item $exttool
-
-If URL is for an External Tool, will contain the target type: iframe, window or tab.
-
-=item $linktext
-
-optional. If URL is for an External Tool, and target type is window or tab,
-then the link text may be an option set in the course for each tool instance,
-or may be a default defined in the domain for all instances of the tool.
-
-=item $explanation
-
-optional. If URL is for an External Tool, and target type is window or tab,
-then the explanation is an option set in the course for each tool instance,
-or may be a default defined in the domain for all instances of the tool.
-
=item $title
optional. If wrapped item is a PDF, and $env{'browser.mobile'}
@@ -400,20 +354,6 @@ above the link, but if not provided as a
will be used, otherwise, the filename will be displayed (unless
hidden URL set for the resource).
-=item $width
-
-optional. If URL is for an External Tool, and target type is window,
-then a default width may have been defined in the domain for all instances of
-the tool. If so, that width will be used for the window opened (via a link)
-to launch the external tool.
-
-=item $height
-
-optional. If URL is for an External Tool, and target type is window,
-then a default height may have been defined in the domain for all instances of
-the tool. If so, that height will be used for the window opened (via a link)
-to launch the external tool.
-
=back
Returns markup for the entire page.