--- rat/lonwrapper.pm 2020/05/22 23:54:42 1.49.2.4.4.2
+++ 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.49.2.4.4.2 2020/05/22 23:54:42 raeburn Exp $
+# $Id: lonwrapper.pm,v 1.63 2017/05/10 13:49:21 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -37,7 +37,8 @@ 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 {
@@ -48,7 +49,6 @@ sub wrapper {
unless ($env{'form.folderpath'}) {
$forcereg = 1;
}
-
my %lt = &Apache::lonlocal::texthash(
'noif' => 'No iframe support.',
'show' => 'Show content in pop-up window',
@@ -83,7 +83,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') || ($exttool eq 'tab')) {
my $output = $startpage;
if ($is_pdf) {
@@ -112,10 +112,9 @@ sub wrapper {
} else {
$output .= <<"ENDLINK";
@@ -200,7 +198,7 @@ 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,$width,$height);
for ($url){
@@ -210,6 +208,7 @@ sub handler {
s|:|:|g;
}
+
if ($url =~ /\.pdf$/i) {
$is_pdf = 1;
} elsif ($url =~ m{^/adm/($match_domain)/($match_courseid)/(\d+)/ext\.tool$}) {
@@ -221,7 +220,7 @@ sub handler {
my %toolhash = &Apache::lonnet::get('exttool_'.$marker,['target','linktext','explanation','id','width','height'],
$cdom,$cnum);
if ($toolhash{'id'}) {
- my %ltitools = &Apache::lonnet::get_domain_lti($cdom,'consumer');
+ my %ltitools = &Apache::lonnet::get_domain_ltitools($cdom);
if (ref($ltitools{$toolhash{'id'}}) eq 'HASH') {
$exttoolremote = $ltitools{$toolhash{'id'}}{'url'};
}
@@ -231,10 +230,10 @@ sub handler {
$width = $toolhash{'width'};
$height = $toolhash{'height'};
} elsif ($toolhash{'target'} eq 'tab') {
- $exttool = 'tab';
+ $exttool = 'tab';
}
if (($exttool eq 'window') || ($exttool eq 'tab')) {
- $linktext = $toolhash{'linktext'};
+ $linktext = $toolhash{'linktext'};
$explanation = $toolhash{'explanation'};
} elsif (($exttoolremote =~ /^http:/) && ($ENV{'SERVER_PORT'} == 443)) {
$exttool = 'tab';
@@ -260,18 +259,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);
@@ -334,7 +339,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 +381,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 +389,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.