[LON-CAPA-cvs] cvs: loncom /interface londocs.pm rat lonwrapper.pm

raeburn raeburn at source.lon-capa.org
Thu Oct 27 17:35:31 EDT 2022


raeburn		Thu Oct 27 21:35:31 2022 EDT

  Modified files:              
    /rat	lonwrapper.pm 
    /loncom/interface	londocs.pm 
  Log:
  - Prepend /adm/wrapper for images, pdfs, and non-html documents included in
    folders in Supplemental Content area, so standard LON-CAPA menus, including 
    breadcrumb trail will be shown above the resource.
  
  
Index: rat/lonwrapper.pm
diff -u rat/lonwrapper.pm:1.79 rat/lonwrapper.pm:1.80
--- rat/lonwrapper.pm:1.79	Tue Aug 30 11:41:27 2022
+++ rat/lonwrapper.pm	Thu Oct 27 21:35:30 2022
@@ -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.80 2022/10/27 21:35:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -47,7 +47,7 @@
 # ================================================================ 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'}) {
@@ -166,7 +166,7 @@
     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 +225,7 @@
                     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();
@@ -384,7 +384,7 @@
 
     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||;
@@ -460,6 +460,7 @@
                 if ($env{'form.anchor'} ne '') {
                     $url .= '#'.$env{'form.anchor'};
                 }
+                $is_supp = 1;
             }
             my $type = 'ext';
             if ($exttool) {
@@ -483,9 +484,33 @@
                     $title = &mt('External Tool');
                 }
             }
+            $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'};
+            my $crstype = &Apache::loncommon::course_type();
+            $brcrum =
+                &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
+
+        }
     }
 
 #
@@ -517,7 +542,8 @@
         }
 
         $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 +570,7 @@
 
 =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
 
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.685 loncom/interface/londocs.pm:1.686
--- loncom/interface/londocs.pm:1.685	Thu Oct 27 20:30:11 2022
+++ loncom/interface/londocs.pm	Thu Oct 27 21:35:30 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.685 2022/10/27 20:30:11 raeburn Exp $
+# $Id: londocs.pm,v 1.686 2022/10/27 21:35:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4368,6 +4368,17 @@
                 }
                 $nomodal = 1;
             }
+        } elsif (($uploaded) && (!$allowed) && ($url ne '/adm/supplemental?')) {
+            my $embstyle=&Apache::loncommon::fileembstyle($extension);
+            unless ($embstyle eq 'ssi') {
+                if (($embstyle eq 'img')
+                 || ($embstyle eq 'emb')
+                 || ($embstyle eq 'wrp')) {
+                    $url='/adm/wrapper'.$url;
+                } elsif ($url !~ /\.(sequence|page)$/) {
+                    $url='/adm/coursedocs/showdoc'.$url;
+                }
+            }
         }
         unless ($allowed && $env{'request.role.adv'}) {
             if ($ishidden || (&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {




More information about the LON-CAPA-cvs mailing list