--- loncom/xml/londefdef.pm	2010/02/01 12:03:19	1.415
+++ loncom/xml/londefdef.pm	2010/10/19 19:33:21	1.424
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.415 2010/02/01 12:03:19 foxr Exp $
+# $Id: londefdef.pm,v 1.424 2010/10/19 19:33:21 raeburn Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -43,7 +43,6 @@ use Apache::lonnet;
 use strict;
 use Apache::lonxml;
 use Apache::lontable;
-use Apache::File();
 use Image::Magick;
 use Apache::lonmenu();
 use Apache::lonmeta();
@@ -2048,29 +2047,39 @@ sub start_table {
 	my $width  = &Apache::lonxml::get_param('TeXwidth', $parstack, $safeeval, undef, 0);
 	my $theme  = &Apache::lonxml::get_param('TeXtheme', $parstack, $safeeval, undef, 0);
 	my $align  = &Apache::lonxml::get_param('align', $parstack, $safeeval, undef, 0);
+	my $cell_border = &Apache::lonxml::get_param('rules', $parstack, $safeeval, undef, 0);
 
 	# The only thing that needs any figuring out is the width.. and then only if it is
 	# a percent. If not it's assumed to be some valid TeX measurement unit e.g. 3.0cm
 	#
 
 	my $table = new Apache::lontable();
-	if ($border ne '') {
+	if ((defined $border) && ($border > 0)) {
+	#    &Apache::lonnet::logthis("Turning on table borders: $border");
 	    $table->table_border(1);
+	    if ($cell_border ne 'none') {
+		$table->cell_border(1); # html specs that border turns on both...unless rules='none'.
+	    }
+	}
+	# Only all or nothing for cell borders for now:
+
+	if ((defined $cell_border) && ($cell_border ne 'none')) {
+	#    &Apache::lonnet::logthis("Turning on cell borders: $cell_border");
 	    $table->cell_border(1);
 	}
-	if ($theme ne '') {
+	if (defined $theme) {
 	    $table->theme($theme);
 	}
-	if ($align ne '') {
+	if (defined $align) {
 	    $table->alignment($align);
 	}
 
 	# Missing width is most of page width
 
-	if ($width eq "") {
+	if (!(defined $width)) {
 	    $width = '70%';
 	}
-	
+
 	# If a percentage, need to calculate what this means in terms of
 	# page width:
 	
@@ -2183,7 +2192,9 @@ sub end_table {
 
 	my $table = pop(@Apache::londefdef::table);
 	my $t     = $table->generate();
+	# &Apache::lonnet::logthis("Generating string");
 	$currentstring = $t->generate_string();
+	# &Apache::lonnet::logthis("Generated: $currentstring");
 	&enable_para();
 	#--------------------------------------------------------------
 	#  Old table code:
@@ -3159,24 +3170,13 @@ sub start_img {
    # Render unto browsers that which are the browser's...
 
     if ($target eq 'web' || $target eq 'webgrade') {
-	if ($env{'browser.imagesuppress'} ne 'on') {
-	    my $enc = ('yes' eq 
-		       lc(&Apache::lonxml::get_param('encrypturl',$parstack,
-						     $safeeval)));
-	    $currentstring.=&Apache::lonenc::encrypt_ref($token,{'src'=>$src},
-							 $enc);
-	} else {
-	    my $alttag = &Apache::lonxml::get_param('alt',$parstack,$safeeval,
-						    undef,1);
-	    if (!$alttag) {
-		$alttag = &Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],
-						   $src);
-	    }
-	    $currentstring.='[IMAGE: '.$alttag.']';
-	}
-
-	# and render unto TeX that which is LaTeX
+        my $enc = ('yes' eq 
+                   lc(&Apache::lonxml::get_param('encrypturl',$parstack,
+                      $safeeval)));
+        $currentstring.=&Apache::lonenc::encrypt_ref($token,{'src'=>$src},
+                         $enc);
 
+    # and render unto TeX that which is LaTeX
     } elsif ($target eq 'tex') {
 	#
 	#  The alignment will require some superstructure to be put around
@@ -3275,21 +3275,28 @@ sub start_img {
 						   ['','bottom','middle','top','left','right'],$token,5);
 	$currentstring .=&Apache::edit::select_arg('TeXwrap:', 'TeXwrap',
 						   ['', 'none','parbox', 'parpic', 'wrapfigure'], $token, 2);
+        my $alt=    &Apache::lonxml::get_param('alt',$parstack,$safeeval);
+        my $enc=    &Apache::lonxml::get_param('encrypturl',$parstack,$safeeval);
+ 
 	$currentstring .=&Apache::edit::select_arg('Encrypt URL:','encrypturl',
 						   ['no','yes'], $token, 2);
+        if (($alt=~/\S/) && (lc($enc) eq 'yes')) {
+           $currentstring.='<br /><span class="LC_warning">'.&mt('Warning: the description "[_1]" will be available, even for encrypted URL',$alt).'</span><br />';
+        }
 	$currentstring .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
 	my $src=    &Apache::lonxml::get_param('src',$parstack,$safeeval);
-	my $alt=    &Apache::lonxml::get_param('alt',$parstack,$safeeval);
 	my $width=  &Apache::lonxml::get_param('width',$parstack,$safeeval);
 	my $height= &Apache::lonxml::get_param('height',$parstack,$safeeval);
 
         if ($token->[2]{'src'}=~/\$/) {
-           $currentstring.='Variable image source';
-        } else {
+           $currentstring.=&mt('Variable image source');
+        } elsif ($token->[2]{'src'}=~/\S/) {
 	   $currentstring .= '<img src="'.$src.'" alt="'.$alt.'" ';
 	   if ($width) { $currentstring.=' width="'.$width.'" '; }
 	   if ($height) { $currentstring.=' height="'.$height.'" '; }
 	   $currentstring .= ' />';
+        } else {
+           $currentstring.=&mt("No image source specified");
         }
     } elsif ($target eq 'modified') {
 	my ($osrc,$owidth,$oheight)=
@@ -3358,23 +3365,12 @@ sub start_applet {
     &Apache::lonxml::extlink($archive);
     my $currentstring = '';
     if ($target eq 'web' || $target eq 'webgrade') {
-	if ($env{'browser.appletsuppress'} ne 'on') {
-	    $currentstring = &Apache::lonenc::encrypt_ref($token,
-							  {'code'=>$code,
-							   'archive'=>$archive}
-							  );
-	} else {
-	    my $alttag= &Apache::lonxml::get_param('alt',$parstack,
-						   $safeeval,undef,1);
-	    unless ($alttag) {
-		$alttag=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],
-						 $code);
-	    }
-	    $currentstring='[APPLET: '.$alttag.']';
-	}
+        $currentstring = &Apache::lonenc::encrypt_ref($token,
+                                                      {'code'=>$code,
+                                                       'archive'=>$archive}
+                                                     );
     } elsif ($target eq 'tex') {
-	# Turn off some stuff we can't be inside thank you LaTeX
-	
+        # Turn off some stuff we can't be inside thank you LaTeX
 
 	my $restart_sub = 0;
 	my $restart_sup = 0;
@@ -3438,16 +3434,7 @@ sub start_embed {
     &Apache::lonxml::extlink($src);
     my $currentstring = '';
     if ($target eq 'web' || $target eq 'webgrade') {
-	if ($env{'browser.embedsuppress'} ne 'on') {
-	    $currentstring=&Apache::lonenc::encrypt_ref($token,{'src'=>$src});
-	} else {
-	    my $alttag=&Apache::lonxml::get_param
-		('alt',$parstack,$safeeval,undef,1);
-	    unless ($alttag) {
-		$alttag=&Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],$src);
-	    }
-	    $currentstring='[EMBED: '.$alttag.']';
-	}
+    $currentstring=&Apache::lonenc::encrypt_ref($token,{'src'=>$src}); 
     } elsif ($target eq 'tex') {
     } 
     return $currentstring;
@@ -3457,9 +3444,10 @@ sub end_embed {
     my ($target,$token) = @_;
     my $currentstring = '';
     if ($target eq 'web' || $target eq 'webgrade') {
-	$currentstring = $token->[2];     
-    } elsif ($target eq 'tex') {  
-    } 
+        $currentstring = $token->[2];
+    } elsif ($target eq 'tex') {
+        # ./.
+    }
     return $currentstring;
 }
 
@@ -3897,12 +3885,16 @@ sub end_colgroup {
     return $currentstring;
 }
 
+
 #-- <del> tag (end tag required)
 sub start_del {
     my ($target,$token) = @_;
     my $currentstring = '';
     if ($target eq 'web' || $target eq 'webgrade') {
 	$currentstring = $token->[4];     
+    } elsif ($target eq 'tex') {
+	&disable_para();
+	$currentstring .= '\st{';  
     } 
     return $currentstring;
 }
@@ -3911,7 +3903,10 @@ sub end_del {
     my ($target,$token) = @_;
     my $currentstring = '';
     if ($target eq 'web' || $target eq 'webgrade') {
-	$currentstring = $token->[2];    
+	$currentstring = $token->[2];     
+    } elsif ($target eq 'tex') {
+	&enable_para();
+	$currentstring = '}';
     } 
     return $currentstring;
 }
@@ -4620,13 +4615,13 @@ sub get_eps_image {
 
 		#if replication failed try to produce eps file dynamically
 		$src=~s/\.ps$/\.eps/;
-		my $temp_file;
-		open(FILE,">>/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat");
-		my $newsrc=$orig_src;
-		$newsrc =~ s|(.*)/res/|/home/httpd/html/res/|;
-		&Apache::lonxml::debug("queueing $newsrc for dynamic eps production.");
-		print FILE ("$newsrc\n");
-		close(FILE);
+		if (open(FILE,">>/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat")) {
+		    my $newsrc=$orig_src;
+		    $newsrc =~ s|(.*)/res/|/home/httpd/html/res/|;
+		    &Apache::lonxml::debug("queueing $newsrc for dynamic eps production.");
+		    print FILE ("$newsrc\n");
+		    close(FILE);
+                }
 		$src=~s|/home/httpd/html/res|/home/httpd/prtspool|;
 		$src=~s|/home/([^/]*)/public_html/|/home/httpd/prtspool/$1/|;
 		if ($sext ne "") {	 # Put the ext. back in to uniquify.
@@ -4659,8 +4654,10 @@ sub get_eps_image {
 sub eps_generation {
     my ($src,$file,$width_param) = @_;	     
     my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat";
-    my $temp_file = Apache::File->new('>>'.$filename); 
-    print $temp_file "$src\n";
+    if (open(my $tmpfile,">>$filename")) { 
+        print $tmpfile "$src\n";
+        close($tmpfile);
+    }
     my $newsrc = $src;
     $newsrc =~ s/(\.bmp|\.gif|\.jpg|\.jpeg)$/\.eps/i;
     $newsrc=~s{/home/httpd/html/res}{};
@@ -4847,6 +4844,7 @@ sub latex_header {
 	"\\usepackage{xcolor}\n".
 	'\usepackage{calc}'.
 	'\usepackage{amsmath}'.
+    '\usepackage{soul}',
 	'\usepackage{amssymb}'.
 	'\usepackage{amsfonts}'.
 	'\usepackage{amsthm}'.