--- rat/lonwrapper.pm 2017/06/22 02:11:30 1.49.2.4.2.1 +++ 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.2.1 2017/06/22 02:11:30 raeburn Exp $ +# $Id: lonwrapper.pm,v 1.63 2017/05/10 13:49:21 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -38,7 +38,7 @@ 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 { @@ -49,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', @@ -84,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) { @@ -113,10 +112,9 @@ sub wrapper { } else { $output .= <<"ENDLINK";
@@ -201,8 +198,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,$width,$height); for ($url){ s|^/adm/wrapper||; @@ -211,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$}) { @@ -232,16 +230,15 @@ 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'; } } - if (($is_ext) || ($exttool)) { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['forceedit','register','folderpath','symb','idx','title','anchor']); @@ -262,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); @@ -336,7 +339,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