--- rat/lonwrapper.pm 2023/07/06 19:53:17 1.49.2.11.2.4 +++ rat/lonwrapper.pm 2022/08/30 11:41:27 1.79 @@ -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.11.2.4 2023/07/06 19:53:17 raeburn Exp $ +# $Id: lonwrapper.pm,v 1.79 2022/08/30 11:41:27 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -47,7 +47,7 @@ use Digest::MD5(); # ================================================================ Main Handler sub wrapper { my ($r,$url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation, - $title,$width,$height,$reuse,$is_supp) = @_; + $title,$width,$height,$reuse) = @_; my $forcereg; unless ($env{'form.folderpath'}) { @@ -166,7 +166,7 @@ var LCresizedef = 0; if (($uselink) && ($title eq '')) { if ($env{'form.symb'}) { $title=&Apache::lonnet::gettitle($env{'form.symb'}); - } elsif (!$is_supp) { + } else { my $symb=&Apache::lonnet::symbread($r->uri); if ($symb) { $title=&Apache::lonnet::gettitle($symb); @@ -225,7 +225,7 @@ var LCresizedef = 0; unless ($reuse) { my $resid; if ($env{'request.course.id'}) { - unless (($is_supp) || ($env{'form.folderpath'} =~ /^supplemental/)) { + unless ($env{'form.folderpath'} =~ /^supplemental/) { my $symb=&Apache::lonnet::symbread($r->uri); if ($symb) { my $navmap = Apache::lonnavmaps::navmap->new(); @@ -334,12 +334,12 @@ ENDLINK } }); window.onload = function(){ - if (LCresizedef) { - LCnotready = 0; - \$(window).trigger('resize'); - } else { - LCnotready = 1; - } + if (LCresizedef) { + LCnotready = 0; + \$(window).trigger('resize'); + } else { + LCnotready = 1; + } }; SCRIPT # javascript will position the iframe if window was resized (or zoomed) @@ -384,7 +384,7 @@ sub handler { my $url = $r->uri; my ($is_ext,$brcrum,$absolute,$is_pdf,$exttool,$cdom,$cnum,$hostname, - $linktext,$explanation,$width,$height,$reuse,$is_supp); + $linktext,$explanation,$width,$height,$reuse); for ($url){ s|^/adm/wrapper||; @@ -425,16 +425,9 @@ sub handler { my %toolhash = &Apache::lonnet::get('exttool_'.$marker,['target','linktext','explanation','id','width','height'], $cdom,$cnum); if ($toolhash{'id'}) { - my ($idx,%ltitools); - if ($toolhash{'id'} =~ /^c(\d+)$/) { - $idx = $1; - %ltitools = &Apache::lonnet::get_course_lti($cnum,$cdom,'consumer'); - } else { - $idx = $toolhash{'id'}; - %ltitools = &Apache::lonnet::get_domain_lti($cdom,'consumer'); - } - if (ref($ltitools{$idx}) eq 'HASH') { - $exttoolremote = $ltitools{$idx}{'url'}; + my %ltitools = &Apache::lonnet::get_domain_lti($cdom,'consumer'); + if (ref($ltitools{$toolhash{'id'}}) eq 'HASH') { + $exttoolremote = $ltitools{$toolhash{'id'}}{'url'}; } } if ($toolhash{'target'} eq 'window') { @@ -467,7 +460,6 @@ sub handler { if ($env{'form.anchor'} ne '') { $url .= '#'.$env{'form.anchor'}; } - $is_supp = 1; } my $type = 'ext'; if ($exttool) { @@ -491,35 +483,9 @@ sub handler { $title = &mt('External Tool'); } } - $title = &HTML::Entities::encode($title,'\'"<>&'); - $is_supp = 1; - if ($env{'request.course.id'}) { - $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - &Apache::loncommon::validate_folderpath(1,'',$cnum,$cdom); - } $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); } - } elsif ($env{'request.course.id'}) { - my $courseurl = &Apache::lonnet::courseid_to_courseurl($env{'request.course.id'}); - $courseurl =~ s{^/}{}; - if ($url =~ m{^\Q/uploaded/$courseurl/supplemental/\E}) { - $is_supp = 1; - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['folderpath','title']); - if ($env{'form.folderpath'}) { - $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - &Apache::loncommon::validate_folderpath(1,'',$cnum,$cdom); - } - my $title = $env{'form.title'}; - $title = &HTML::Entities::encode($title,'\'"<>&'); - my $crstype = &Apache::loncommon::course_type(); - $brcrum = - &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); - - } } # @@ -551,8 +517,7 @@ sub handler { } $r->print( wrapper($r,$url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool, - $linktext,$explanation,undef,$width,$height,$reuse, - $is_supp) ); + $linktext,$explanation,undef,$width,$height,$reuse) ); } # not just the menu @@ -579,7 +544,7 @@ described at http://www.lon-capa.org. =over -=item wrapper($r,$url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,$title,$width,$height,$reuse,$is_supp) +=item wrapper($r,$url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,$title,$width,$height,$reuse) =over