[LON-CAPA-cvs] cvs: loncom /xml lonxml.pm

raeburn raeburn at source.lon-capa.org
Thu Nov 29 15:47:11 EST 2012


raeburn		Thu Nov 29 20:47:11 2012 EDT

  Modified files:              
    /loncom/xml	lonxml.pm 
  Log:
  - HTML files uploaded to course's Supplemental content area can be edited,
    and any dependencies can be replaced (or uploaded if missing).
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.533 loncom/xml/lonxml.pm:1.534
--- loncom/xml/lonxml.pm:1.533	Wed Nov 21 23:13:30 2012
+++ loncom/xml/lonxml.pm	Thu Nov 29 20:47:11 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.533 2012/11/21 23:13:30 raeburn Exp $
+# $Id: lonxml.pm,v 1.534 2012/11/29 20:47:11 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1510,7 +1510,7 @@
 }
 
 sub inserteditinfo {
-      my ($filecontents,$filetype,$filename,$symb,$itemtitle) = @_;
+      my ($filecontents,$filetype,$filename,$symb,$itemtitle,$folderpath,$uri) = @_;
       $filecontents = &HTML::Entities::encode($filecontents,'<>&"');
       my $xml_help = '';
       my $initialize='';
@@ -1536,10 +1536,11 @@
 </script>
 FULLPAGE
       if ($filetype eq 'html') {
-          if ($symb) {
+          if ($symb || $folderpath) {
               $deps_button = &Apache::lonhtmlcommon::dependencies_button()."\n";
               $initialize .= 
-                  &Apache::lonhtmlcommon::dependencycheck_js($symb,$itemtitle)."\n";
+                  &Apache::lonhtmlcommon::dependencycheck_js($symb,$itemtitle,
+                                                             undef,$folderpath,$uri)."\n";
           }
           $dragmath_button = '<span id="math_filecont">'.&Apache::lonhtmlcommon::dragmath_button('filecont',1).'</span>';
           $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup');
@@ -1797,14 +1798,24 @@
             my ($displayfile,$url,$symb,$itemtitle);
 	    $displayfile=$request->uri;
             if ($request->uri =~ m{^/uploaded/}) {
+                if ($env{'request.course.id'}) {
+                    my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+                    my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+                    if ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/\Esupplemental/}) {
+                        &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+                                                                ['folderpath','title']);
+                    }
+                }
                 ($symb,$itemtitle,$displayfile) = 
-                    &get_courseupload_hierarchy($request->uri);
+                    &get_courseupload_hierarchy($request->uri,
+                                                $env{'form.folderpath'},$env{'form.title'});
             } else {
 	        $displayfile=~s/^\/[^\/]*//;
             }
 
 	    my ($edit_info, $add_to_onload, $add_to_onresize)=
-		&inserteditinfo($filecontents,$filetype,$displayfile,$symb,$itemtitle);
+		&inserteditinfo($filecontents,$filetype,$displayfile,$symb,
+                                $itemtitle,$env{'form.folderpath'},$request->uri);
 
 	    my %options = 
 		('add_entries' =>
@@ -1855,20 +1866,34 @@
 }
 
 sub get_courseupload_hierarchy {
-    my ($url) = @_;
+    my ($url,$folderpath,$title) = @_;
     my ($symb,$itemtitle,$displaypath);
     if ($env{'request.course.id'}) {
-        $symb = &Apache::lonnet::symbread($url);
-        my ($map,$id,$res)=&Apache::lonnet::decode_symb($symb);
-        my $navmap=Apache::lonnavmaps::navmap->new;
-        if (ref($navmap)) {
-            my $res = $navmap->getBySymb($symb);
-            if (ref($res)) {
-                my @pathitems =
-                    &Apache::loncommon::get_folder_hierarchy($navmap,$map,1);
-                $itemtitle = $res->compTitle();
-                push(@pathitems,$itemtitle);
-                $displaypath = join(' » ', at pathitems);
+        if ($folderpath =~ /^supplemental/) {
+            my @folders = split(/\&/,$folderpath);
+            my @pathitems;
+            while (@folders) {
+                my $folder=shift(@folders);
+                my $foldername=shift(@folders);
+                push(@pathitems,&unescape($foldername));
+            }
+            if ($title) {
+                push(@pathitems,&unescape($title));
+            }
+            $displaypath = join(' » ', at pathitems);
+        } else {
+            $symb = &Apache::lonnet::symbread($url);
+            my ($map,$id,$res)=&Apache::lonnet::decode_symb($symb);
+            my $navmap=Apache::lonnavmaps::navmap->new;
+            if (ref($navmap)) {
+                my $res = $navmap->getBySymb($symb);
+                if (ref($res)) {
+                    my @pathitems =
+                        &Apache::loncommon::get_folder_hierarchy($navmap,$map,1);
+                    $itemtitle = $res->compTitle();
+                    push(@pathitems,$itemtitle);
+                    $displaypath = join(' » ', at pathitems);
+                }
             }
         }
     }




More information about the LON-CAPA-cvs mailing list