--- rat/lonwrapper.pm 2022/08/30 11:48:33 1.49.2.11.2.2 +++ rat/lonwrapper.pm 2023/01/21 23:25:16 1.49.2.11.2.3 @@ -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.2 2022/08/30 11:48:33 raeburn Exp $ +# $Id: lonwrapper.pm,v 1.49.2.11.2.3 2023/01/21 23:25:16 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -46,7 +46,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'}) { @@ -122,7 +122,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); @@ -181,7 +181,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(); @@ -337,7 +337,7 @@ sub handler { my $url = $r->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||; @@ -413,6 +413,7 @@ sub handler { if ($env{'form.anchor'} ne '') { $url .= '#'.$env{'form.anchor'}; } + $is_supp = 1; } my $type = 'ext'; if ($exttool) { @@ -436,9 +437,35 @@ 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); + + } } # @@ -470,7 +497,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 @@ -497,7 +525,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