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

sakharuk lon-capa-cvs@mail.lon-capa.org
Tue, 08 Oct 2002 20:35:19 -0000


sakharuk		Tue Oct  8 16:35:19 2002 EDT

  Modified files:              
    /loncom/xml	londefdef.pm 
  Log:
  Done additional cleanup.
  
  
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.93 loncom/xml/londefdef.pm:1.94
--- loncom/xml/londefdef.pm:1.93	Tue Oct  8 16:18:36 2002
+++ loncom/xml/londefdef.pm	Tue Oct  8 16:35:19 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.93 2002/10/08 20:18:36 sakharuk Exp $
+# $Id: londefdef.pm,v 1.94 2002/10/08 20:35:19 sakharuk Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -1553,17 +1553,7 @@
               $currentstring = $token->[4];     
 	    } elsif ($target eq 'tex') {
 		my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval);
-		if (not -e '/home/httpd/html'.$src) {
-		    #replicates image itself
-		    &Apache::lonnet::repcopy('/home/httpd/html'.$src);
-		    #replicates eps or ps 
-		    my $newsrc = $src;
-		    $newsrc =~ s/(.gif|.jpg)$/.eps/;
-		    if (not-e $newsrc && &Apache::lonnet::repcopy('/home/httpd/html'.$newsrc) ne 'OK') {
-			$newsrc =~ s/\.ps$/\.eps/;
-			&Apache::lonnet::repcopy('/home/httpd/html'.$newsrc);
-		    }
-		}
+		&image_replication($src);
 	      $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
               #if original gif/jpg file exist do following:
               if (-e $src) {          
@@ -1729,17 +1719,7 @@
             $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=   
                                         $token->[2]->{'src'};
 	    my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval);
-	    if (not -e '/home/httpd/html'.$src) {
-            #replicates image itself
-		&Apache::lonnet::repcopy('/home/httpd/html'.$src);
-	        #replicates eps or ps 
-		my $newsrc = $src;
-		$newsrc =~ s/(.gif|.jpg)$/.eps/;
- 		if (not-e $newsrc && &Apache::lonnet::repcopy('/home/httpd/html'.$newsrc) ne 'OK') {
-		    $newsrc =~ s/\.ps$/\.eps/;
-		    &Apache::lonnet::repcopy('/home/httpd/html'.$newsrc);
-		}
-	    }
+	    &image_replication($src);
 	    return '';
 	}
         sub end_allow {
@@ -2538,5 +2518,22 @@
             } 
 	   return $currentstring;
 	}
+
+sub image_replication {
+    my $src = shift;
+    if (not -e '/home/httpd/html'.$src) {
+	#replicates image itself
+	&Apache::lonnet::repcopy('/home/httpd/html'.$src);
+	#replicates eps or ps 
+	my $newsrc = $src;
+	$newsrc =~ s/(.gif|.jpg)$/.eps/;
+	if (not-e $newsrc && &Apache::lonnet::repcopy('/home/httpd/html'.$newsrc) ne 'OK') {
+	    $newsrc =~ s/\.ps$/\.eps/;
+	    &Apache::lonnet::repcopy('/home/httpd/html'.$newsrc);
+	}
+    }
+    return '';
+}
+
 1;
 __END__