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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 07 Nov 2002 19:33:52 -0000


albertel		Thu Nov  7 14:33:52 2002 EDT

  Modified files:              
    /loncom/xml	lonxml.pm londefdef.pm 
  Log:
  - get_param can now be insensitive to case, it takes an optional 4th
     parameter that controls this
  - BUG#932 and BUG#934 
  
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.212 loncom/xml/lonxml.pm:1.213
--- loncom/xml/lonxml.pm:1.212	Wed Nov  6 18:05:02 2002
+++ loncom/xml/lonxml.pm	Thu Nov  7 14:33:52 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.212 2002/11/06 23:05:02 albertel Exp $
+# $Id: lonxml.pm,v 1.213 2002/11/07 19:33:52 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1354,24 +1354,38 @@
 }
 
 sub get_param {
-  my ($param,$parstack,$safeeval,$context) = @_;
-  if ( ! $context ) { $context = -1; }
-  my $args ='';
-  if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; }
-  if ( ! $args ) { return undef; }
-  if ( $args =~ /my \$$param=\"/ ) {
-    return &Apache::run::run("{$args;".'return $'.$param.'}',$safeeval); #'
-  } else {
-    return undef;
-  }
+    my ($param,$parstack,$safeeval,$context,$case_insensitive) = @_;
+    if ( ! $context ) { $context = -1; }
+    my $args ='';
+    if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; }
+    if ( ! $args ) { return undef; }
+    if ( $case_insensitive ) {
+	if ($args =~ s/(my \$)(\Q$param\E)(=\")/$1.lc($2).$3/ei) {
+	    return &Apache::run::run("{$args;".'return $'.$param.'}',
+                                     $safeeval); #'
+	} else {
+	    return undef;
+	}
+    } else {
+	if ( $args =~ /my \$\Q$param\E=\"/ ) {
+	    return &Apache::run::run("{$args;".'return $'.$param.'}',
+                                     $safeeval); #'
+	} else {
+	    return undef;
+	}
+    }
 }
 
 sub get_param_var {
-  my ($param,$parstack,$safeeval,$context) = @_;
+  my ($param,$parstack,$safeeval,$context,$case_insensitive) = @_;
   if ( ! $context ) { $context = -1; }
   my $args ='';
   if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; }
-  if ( $args !~ /my \$$param=\"/ ) { return undef; }
+  if ($case_insensitive) {
+      if (! ($args=~s/(my \$)(\Q$param\E)(=\")/$1.lc($2).$3/ei)) {
+	  return undef;
+      }
+  } elsif ( $args !~ /my \$\Q$param\E=\"/ ) { return undef; }
   my $value=&Apache::run::run("{$args;".'return $'.$param.'}',$safeeval); #'
   if ($value =~ /^[\$\@\%]/) {
     return &Apache::run::run("return $value",$safeeval,1);
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.98 loncom/xml/londefdef.pm:1.99
--- loncom/xml/londefdef.pm:1.98	Thu Nov  7 14:24:53 2002
+++ loncom/xml/londefdef.pm	Thu Nov  7 14:33:52 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.98 2002/11/07 19:24:53 albertel Exp $
+# $Id: londefdef.pm,v 1.99 2002/11/07 19:33:52 albertel Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -1543,18 +1543,18 @@
 #-- <img> tag
         sub start_img {
 	    my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
-            $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
-                                        $token->[2]->{'src'};
+	    my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,
+						 undef,1);
+            $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
             my $currentstring = '';
 	    my $width_param = '';
 	    my $height_param = '';
 	    my $scaling = .3;
 
 	    if ($target eq 'web') {
-              $currentstring = $token->[4];     
+              $currentstring = $token->[4];
 	    } elsif ($target eq 'tex') {
-		my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval);
-		&image_replication($src);
+	      &image_replication($src);
 	      $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
               #if original gif/jpg file exist do following:
               if (-e $src) {