--- rat/lonwrapper.pm 2022/08/30 11:41:27 1.79 +++ rat/lonwrapper.pm 2023/09/27 14:52:28 1.83 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Wrapper for external and binary files as standalone resources # -# $Id: lonwrapper.pm,v 1.79 2022/08/30 11:41:27 raeburn Exp $ +# $Id: lonwrapper.pm,v 1.83 2023/09/27 14:52:28 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) = @_; + $title,$width,$height,$reuse,$is_supp) = @_; my $forcereg; unless ($env{'form.folderpath'}) { @@ -95,6 +95,8 @@ sub wrapper { } if ($env{'form.only_body'}) { $args->{'only_body'} = $env{'form.only_body'}; + } elsif (($is_supp) && ($env{'form.folderpath'} ne '')) { + $args->{'bread_crumbs_nomenu'} = 1; } my ($countdown,$donemsg,$headjs); @@ -166,7 +168,7 @@ var LCresizedef = 0; if (($uselink) && ($title eq '')) { if ($env{'form.symb'}) { $title=&Apache::lonnet::gettitle($env{'form.symb'}); - } else { + } elsif (!$is_supp) { my $symb=&Apache::lonnet::symbread($r->uri); if ($symb) { $title=&Apache::lonnet::gettitle($symb); @@ -225,7 +227,7 @@ var LCresizedef = 0; unless ($reuse) { my $resid; if ($env{'request.course.id'}) { - unless ($env{'form.folderpath'} =~ /^supplemental/) { + unless (($is_supp) || ($env{'form.folderpath'} =~ /^supplemental/)) { my $symb=&Apache::lonnet::symbread($r->uri); if ($symb) { my $navmap = Apache::lonnavmaps::navmap->new(); @@ -302,7 +304,7 @@ ENDLINK } else { my $offset = 5; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']); - if ($env{'form.inhibitmenu'} eq 'yes') { + if (($env{'form.inhibitmenu'} eq 'yes') || ($env{'form.only_body'})) { $offset = 0; } my $script = &Apache::lonhtmlcommon::scripttag(<uri; my ($is_ext,$brcrum,$absolute,$is_pdf,$exttool,$cdom,$cnum,$hostname, - $linktext,$explanation,$width,$height,$reuse); + $linktext,$explanation,$width,$height,$reuse,$is_supp); for ($url){ s|^/adm/wrapper||; @@ -425,9 +427,16 @@ 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'); - if (ref($ltitools{$toolhash{'id'}}) eq 'HASH') { - $exttoolremote = $ltitools{$toolhash{'id'}}{'url'}; + 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'}; } } if ($toolhash{'target'} eq 'window') { @@ -446,7 +455,7 @@ sub handler { } if (($is_ext) || ($exttool)) { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['forceedit','register','folderpath','symb','idx','title','anchor']); + ['forceedit','register','folderpath','symb','idx','title','anchor','only_body']); if (($env{'form.forceedit'}) && (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) && (($env{'form.folderpath'} =~ /^supplemental/) || @@ -460,6 +469,7 @@ sub handler { if ($env{'form.anchor'} ne '') { $url .= '#'.$env{'form.anchor'}; } + $is_supp = 1; } my $type = 'ext'; if ($exttool) { @@ -483,8 +493,37 @@ sub handler { $title = &mt('External Tool'); } } - $brcrum = - &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); + $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); + } + unless ($env{'form.only_body'}) { + $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','only_body']); + 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(); + unless ($env{'form.only_body'}) { + $brcrum = + &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); + } } } @@ -517,7 +556,8 @@ sub handler { } $r->print( wrapper($r,$url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool, - $linktext,$explanation,undef,$width,$height,$reuse) ); + $linktext,$explanation,undef,$width,$height,$reuse, + $is_supp) ); } # not just the menu @@ -544,7 +584,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) +=item wrapper($r,$url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,$title,$width,$height,$reuse,$is_supp) =over