--- loncom/xml/londefdef.pm 2007/10/15 20:00:12 1.375.2.1 +++ loncom/xml/londefdef.pm 2008/10/15 09:25:42 1.394 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.375.2.1 2007/10/15 20:00:12 albertel Exp $ +# $Id: londefdef.pm,v 1.394 2008/10/15 09:25:42 bisitz Exp $ # # # Copyright Michigan State University Board of Trustees @@ -46,6 +46,7 @@ use Apache::File(); use Image::Magick; use Apache::lonmenu(); use Apache::lonmeta(); +use Apache::lonlocal; use Apache::Constants qw(:common); use File::Basename; use LONCAPA(); @@ -106,13 +107,13 @@ sub start_m { my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval); if ($eval eq 'on') { $inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]); - #&Apache::lonxml::debug("M is evaulated to:$inside:"); + #&Apache::lonxml::debug("M is evaluated to:$inside:"); } my $tex = $inside; my $display=&Apache::lonxml::get_param('display',$parstack,$safeeval); $currentstring = &Apache::lontexconvert::converted(\$inside,$display); if ($Apache::lontexconvert::errorstring) { - my $errormsg='
'.&HTML::Entities::encode($Apache::lontexconvert::errorstring,'<>&"').'
occured while attempting to convert this TeX:
';
+	    my $errormsg='
'.&HTML::Entities::encode($Apache::lontexconvert::errorstring,'<>&"').'
occurred while attempting to convert this TeX:
';
 	    $tex = &HTML::Entities::encode($tex,'<>&"');
 	    my ($linenumber) =
 		($Apache::lontexconvert::errorstring =~ /Line (\d+)/);
@@ -200,14 +201,27 @@ sub start_html {
                           '\usepackage[dvips]{graphicx}'.
 			  '\usepackage{wrapfig}'.
 			  '\usepackage{picins}'.
+			  '\usepackage[T1]{fontenc}'."\n".
+                          '\usepackage{lmodern}'."\n".
+			  '\usepackage[postscript]{ucs}'."\n".
+			  '\usepackage[utf8x]{inputenc}'."\n".
+			  '\usepackage{pifont}' ."\n".
+			  '\usepackage{latexsym}'."\n".
                           '\usepackage{epsfig}'.
                           '\usepackage{calc}'.
                           '\usepackage{amsmath}'.
                           '\usepackage{amssymb}'.
                           '\usepackage{amsfonts}'.
                           '\usepackage{amsthm}'.
-                          '\usepackage{amscd}'.
-                          '\newenvironment{choicelist}{\begin{list}{}{\setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.05in}\setlength{\itemsep}{0.022in}\setlength{\parsep}{0in}\setlength{\belowdisplayskip}{0.04in}\setlength{\abovedisplayskip}{0.05in}\setlength{\abovedisplayshortskip}{-0.04in}\setlength{\belowdisplayshortskip}{0.04in}}}{\end{list}}'.
+                          '\usepackage{amscd}';
+
+        if($env{'form.pdfFormFields'} eq 'yes') {
+            $currentstring .= '\usepackage{hyperref}'.
+                              '\usepackage{eforms}'.
+                              '\usepackage{tabularx}';
+        } 
+
+        $currentstring .= '\newenvironment{choicelist}{\begin{list}{}{\setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.05in}\setlength{\itemsep}{0.022in}\setlength{\parsep}{0in}\setlength{\belowdisplayskip}{0.04in}\setlength{\abovedisplayskip}{0.05in}\setlength{\abovedisplayshortskip}{-0.04in}\setlength{\belowdisplayshortskip}{0.04in}}}{\end{list}}'.
                           '\renewenvironment{theindex}{\begin{list}{}{{\vskip 1mm \noindent \large\textbf{Index}} \newline \setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.01in}\setlength{\itemsep}{0.1in}\setlength{\parsep}{-0.02in}\setlength{\belowdisplayskip}{0.01in}\setlength{\abovedisplayskip}{0.01in}\setlength{\abovedisplayshortskip}{-0.04in}\setlength{\belowdisplayshortskip}{0.01in}}}{\end{list}}';
     }
     return $currentstring;
@@ -579,12 +593,7 @@ sub start_body {
 
 	if ($env{'request.state'} ne 'published') {
 	    $currentstring.=&Apache::lonmenu::constspaceform();
-	    $currentstring.=(<
-
-
-
-EDITBUTTON + $currentstring.=&Apache::londefdef::edit_controls(); } $currentstring.=&Apache::lonxml::message_location(); } elsif ($target eq 'tex') { @@ -593,6 +602,20 @@ EDITBUTTON return $currentstring; } +sub edit_controls { + my $result .= ' +
+
+
'. +&Apache::lonxml::renderingoptions().' + +
+
+
+
'; + return $result; +} + sub end_body { my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = &end_p(); # Close off unclosed

@@ -1580,6 +1603,9 @@ sub start_div { } if ($target eq 'tex') { # 4 possible alignments: left, right, center, and -missing-. + # If inside a table row, we must let the table logic + # do the alignment, however. + # my $endstring = ''; @@ -1590,6 +1616,7 @@ sub start_div { $endstring = '\end{center}'; if (&is_inside_of($tagstack, "table")) { $currentstring = ¢er_correction().$currentstring; + $endstring .= ¢er_end_correction(); } } elsif ($align eq 'right') { @@ -1645,14 +1672,18 @@ sub end_a { &Apache::lonxml::get_param('href',$parstack,$safeeval,undef,1); my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval,undef,1); - if ($href =~ /\S/) { + my $uriprint = + &Apache::lonxml::get_param('uriprint',$parstack,$safeeval,undef,1); + my $anchorprint = + &Apache::lonxml::get_param('anchorprint',$parstack,$safeeval,undef,1); + if (($href =~ /\S/) && ($uriprint=~/^on|uriprint|yes|1$/i)) { $href =~ s/([^\\])%/$1\\\%/g; # Substitute special symbols... and allow line breaks at each / # $href = &Apache::lonxml::latex_special_symbols($href); $href =~ s/\//\/\\-/g; # Map / to /\- to allow hyphenation. $currentstring .= ' ({\tt URI:'.$href.'})'; - } elsif ($name =~ /\S/) { + } elsif (($name =~ /\S/) && ($anchorprint=~/^on|anchorprint|yes|1$/i)) { $currentstring .= ' ({\tt Anchor:'.&Apache::lonxml::latex_special_symbols($name).'})'; } else { $currentstring.=''; @@ -2087,6 +2118,10 @@ sub end_table { my $WARNING=''; #width of columns from TeXwidth attributes + # Protect against unbalanced tag. + + if (scalar(@Apache::londefdef::table) > 0) { + for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) { for (my $jn=0;$jn<=$Apache::londefdef::table[-1]{'counter_columns'};$jn++) { if ($Apache::londefdef::table[-1]{'TeXlen'}[0][$jn]<$Apache::londefdef::table[-1]{'TeXlen'}[$in][$jn]) { @@ -2490,6 +2525,7 @@ sub end_table { undef @Apache::londefdef::table; } } + } return $currentstring; } @@ -2988,7 +3024,7 @@ sub start_img { # &Apache::lonxml::debug("LaTeX rendering = $latex_rendering image file: $src"); - #if original gif/jpg/png file exist do following: + #if original bmp/gif/jpg/png file exist do following: my $origsrc=$src; my ($path,$file) = &get_eps_image($src); # &Apache::lonnet::logthis("Image source: $src result: $path $file"); @@ -3054,11 +3090,14 @@ sub start_img { my $width= &Apache::lonxml::get_param('width',$parstack,$safeeval); my $height= &Apache::lonxml::get_param('height',$parstack,$safeeval); - - $currentstring .= ''.$alt.'[2]{'src'}=~/\$/) { + $currentstring.='Variable image source'; + } else { + $currentstring .= ''.$alt.'[2]{'src'},$token->[2]{'width'},$token->[2]{'height'}); @@ -4386,8 +4425,8 @@ sub get_eps_image { &Apache::lonnet::repcopy($orig_src); # Failure is not completely fatal. } &Apache::lonxml::debug("get_eps_image: Original image: $orig_src"); - my ($spath, $sname, $sext) = &fileparse($src, qr/\.(gif|png|jpg|jpeg)/i); - $src=~s/\.(gif|png|jpg|jpeg)$/\.eps/i; + my ($spath, $sname, $sext) = &fileparse($src, qr/\.(bmp|gif|png|jpg|jpeg)/i); + $src=~s/\.(bmp|gif|png|jpg|jpeg)$/\.eps/i; $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src); &Apache::lonxml::debug("Filelocation gives: $src"); if (! -e $src) { @@ -4448,7 +4487,7 @@ sub eps_generation { my $temp_file = Apache::File->new('>>'.$filename); print $temp_file "$src\n"; my $newsrc = $src; - $newsrc =~ s/(\.gif|\.jpg|\.jpeg)$/\.eps/i; + $newsrc =~ s/(\.bmp|\.gif|\.jpg|\.jpeg)$/\.eps/i; $newsrc=~s{/home/httpd/html/res}{}; $newsrc=~s{/home/($LONCAPA::username_re)/public_html/}{/$1/}; $newsrc=~s{/\./}{/};