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

raeburn raeburn at source.lon-capa.org
Thu Dec 13 17:28:15 EST 2012


raeburn		Thu Dec 13 22:28:15 2012 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/xml	lonxml.pm 
  Log:
  - For 2.11 
    - Backport 1.533, 1.534, 1.535 (part), 1.536, 1.537
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.531.2.4 loncom/xml/lonxml.pm:1.531.2.5
--- loncom/xml/lonxml.pm:1.531.2.4	Wed Aug  1 05:17:02 2012
+++ loncom/xml/lonxml.pm	Thu Dec 13 22:28:15 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.531.2.4 2012/08/01 05:17:02 raeburn Exp $
+# $Id: lonxml.pm,v 1.531.2.5 2012/12/13 22:28:15 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -743,9 +743,9 @@
 
 sub init_safespace {
   my ($target,$safeeval,$safehole,$safeinit) = @_;
-  $safeeval->reval('use Math::Complex;');
   $safeeval->reval('use LaTeX::Table;');
   $safeeval->deny_only(':dangerous');
+  $safeeval->reval('use Math::Complex;');
   $safeeval->permit_only(":default");
   $safeeval->permit("entereval");
   $safeeval->permit(":base_math");
@@ -1604,7 +1604,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='';
@@ -1630,10 +1630,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');
@@ -1763,6 +1764,11 @@
     } else {
 	$filetype='html';
     }
+    unless ($env{'request.uri'}) {
+        $env{'request.uri'}=$request->uri;
+        &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+                                                ['todocs']);
+    }
     if ($filetype eq 'sty') {
         $breadcrumbtext = 'Style File Editor';
     } elsif ($filetype eq 'js') {
@@ -1891,14 +1897,25 @@
             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' =>
@@ -1949,20 +1966,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);
+                }
             }
         }
     }
@@ -2119,13 +2150,18 @@
 }
 
 sub get_param {
-    my ($param,$parstack,$safeeval,$context,$case_insensitive) = @_;
+    my ($param,$parstack,$safeeval,$context,$case_insensitive, $noelide) = @_;
     if ( ! $context ) { $context = -1; }
     my $args ='';
     if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; }
     if ( ! $Apache::lonxml::usestyle ) {
 	$args=$Apache::lonxml::style_values.$args;
     }
+
+    if ($noelide) {
+        $args =~ s/'\$/'\\\$/g;
+    }
+
     if ( ! $args ) { return undef; }
     if ( $case_insensitive ) {
 	if ($args =~ s/(my (?:.*))(\$\Q$param\E[,\)])/$1.lc($2)/ei) {




More information about the LON-CAPA-cvs mailing list