version 1.363, 2007/04/06 10:33:37
|
version 1.396, 2008/11/10 11:17:50
|
Line 46 use Apache::File();
|
Line 46 use Apache::File();
|
use Image::Magick; |
use Image::Magick; |
use Apache::lonmenu(); |
use Apache::lonmenu(); |
use Apache::lonmeta(); |
use Apache::lonmeta(); |
|
use Apache::lonlocal; |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use File::Basename; |
use File::Basename; |
use LONCAPA(); |
use LONCAPA(); |
Line 106 sub start_m {
|
Line 107 sub start_m {
|
my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval); |
my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval); |
if ($eval eq 'on') { |
if ($eval eq 'on') { |
$inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]); |
$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 $tex = $inside; |
my $display=&Apache::lonxml::get_param('display',$parstack,$safeeval); |
my $display=&Apache::lonxml::get_param('display',$parstack,$safeeval); |
$currentstring = &Apache::lontexconvert::converted(\$inside,$display); |
$currentstring = &Apache::lontexconvert::converted(\$inside,$display); |
if ($Apache::lontexconvert::errorstring) { |
if ($Apache::lontexconvert::errorstring) { |
my $errormsg='<pre>'.&HTML::Entities::encode($Apache::lontexconvert::errorstring,'<>&"').'</pre> occured while attempting to convert this TeX: <pre>'; |
my $errormsg='<pre>'.&HTML::Entities::encode($Apache::lontexconvert::errorstring,'<>&"').'</pre> occurred while attempting to convert this TeX: <pre>'; |
$tex = &HTML::Entities::encode($tex,'<>&"'); |
$tex = &HTML::Entities::encode($tex,'<>&"'); |
my ($linenumber) = |
my ($linenumber) = |
($Apache::lontexconvert::errorstring =~ /Line (\d+)/); |
($Apache::lontexconvert::errorstring =~ /Line (\d+)/); |
Line 138 sub start_m {
|
Line 139 sub start_m {
|
# detect simple math mode entry exits, and convert them |
# detect simple math mode entry exits, and convert them |
# to use \ensuremath ... unless there's a \verb inside. |
# to use \ensuremath ... unless there's a \verb inside. |
if (! ($currentstring=~/\\verb/)) { |
if (! ($currentstring=~/\\verb/)) { |
if ($currentstring=~/^\s*\$[^\$].*[^\$]\$\s*$/) { |
if ($currentstring=~/^\s*\$[^\$].*\$\s*$/) { |
$currentstring=~s/^(\s*)\$/$1/; |
$currentstring=~s/^(\s*)\$/$1/; |
$currentstring=~s/\$(\s*)$/$1/; |
$currentstring=~s/\$(\s*)$/$1/; |
$currentstring='\ensuremath{'.$currentstring.'}'; |
$currentstring='\ensuremath{'.$currentstring.'}'; |
Line 200 sub start_html {
|
Line 201 sub start_html {
|
'\usepackage[dvips]{graphicx}'. |
'\usepackage[dvips]{graphicx}'. |
'\usepackage{wrapfig}'. |
'\usepackage{wrapfig}'. |
'\usepackage{picins}'. |
'\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{epsfig}'. |
'\usepackage{calc}'. |
'\usepackage{calc}'. |
'\usepackage{amsmath}'. |
'\usepackage{amsmath}'. |
'\usepackage{amssymb}'. |
'\usepackage{amssymb}'. |
'\usepackage{amsfonts}'. |
'\usepackage{amsfonts}'. |
'\usepackage{amsthm}'. |
'\usepackage{amsthm}'. |
'\usepackage{amscd}'. |
'\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}}'. |
|
|
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}}'; |
'\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; |
return $currentstring; |
Line 448 sub start_meta {
|
Line 462 sub start_meta {
|
if ((not defined $content) && (not defined $name)) { |
if ((not defined $content) && (not defined $name)) { |
&Apache::lonxml::startredirection(); |
&Apache::lonxml::startredirection(); |
} |
} |
|
} elsif ($target eq 'edit') { |
|
$currentstring .= &Apache::edit::tag_start($target,$token); |
|
$currentstring .= &Apache::edit::text_arg('Name:','name',$token,30); |
|
$currentstring .= &Apache::edit::text_arg('Content:','content',$token,70); |
|
$currentstring .= &Apache::edit::end_row(); |
|
} elsif ($target eq 'modified') { |
|
my $constructtag = |
|
&Apache::edit::get_new_args($token,$parstack,$safeeval, |
|
'name','content'); |
|
if ($constructtag) { $currentstring = &Apache::edit::rebuild_tag($token); } |
} |
} |
return $currentstring; |
return $currentstring; |
} |
} |
Line 471 sub end_meta {
|
Line 495 sub end_meta {
|
return $currentstring; |
return $currentstring; |
} |
} |
|
|
|
sub insert_meta { |
|
return ' |
|
<meta />'; |
|
} |
|
|
# accessrule |
# accessrule |
sub start_accessrule { |
sub start_accessrule { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_; |
my $currentstring = ''; |
my $currentstring = ''; |
my $eff=&Apache::lonxml::get_param |
my $eff =&Apache::lonxml::get_param('effect',$parstack,$safeeval,undef,1); |
('effect',$parstack,$safeeval,undef,1); |
my $realm=&Apache::lonxml::get_param('realm', $parstack,$safeeval,undef,1); |
my $realm=&Apache::lonxml::get_param |
my $role =&Apache::lonxml::get_param('role', $parstack,$safeeval,undef,1); |
('realm',$parstack,$safeeval,undef,1); |
my $type =&Apache::lonxml::get_param('type', $parstack,$safeeval,undef,1); |
my $role=&Apache::lonxml::get_param |
|
('role',$parstack,$safeeval,undef,1); |
my ($dom,$crs,$sec,$separator); |
$realm=~s/\s+//g; |
if ($type eq 'user') { |
$realm=~s/\//\_/g; |
($dom,$crs,$sec)=split(m{/},$realm); |
$realm=~s/^\_//; |
$crs = &LONCAPA::clean_username($crs); |
$realm=~s/\W/\;/g; |
$separator = '/'; |
$role=~s/\s+//g; |
} else { |
$role=~s/\//\_/g; |
($dom,$crs,$sec)=split(/\_/,$realm); |
$role=~s/\W/\;/g; |
$crs = &LONCAPA::clean_courseid($crs); |
|
$separator = '_'; |
|
} |
|
$dom = &LONCAPA::clean_domain($dom); |
|
|
|
$sec =~s/\W//; |
|
$realm = $dom; |
|
if ($crs =~ /\S/) { $realm .= $separator.$crs; } |
|
if ($sec =~ /\S/) { $realm .= $separator.$sec; } |
|
$role=~s/\W//g; |
|
|
if ($target eq 'web') { |
if ($target eq 'web') { |
my $args=''; |
my $args=''; |
if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; } |
if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; } |
Line 498 sub start_accessrule {
|
Line 537 sub start_accessrule {
|
} |
} |
} |
} |
if ($target eq 'meta') { |
if ($target eq 'meta') { |
$currentstring='<rule>'.$eff.':'.$realm.':'.$role.'</rule>'; |
$currentstring='<rule>'.$eff.':'.$realm.':'.$role.':'.$type.'</rule>'; |
} |
} |
return $currentstring; |
return $currentstring; |
} |
} |
Line 516 sub end_accessrule {
|
Line 555 sub end_accessrule {
|
return $currentstring; |
return $currentstring; |
} |
} |
|
|
|
sub generate_css_links { |
|
my $links; |
|
my $css_href = &Apache::lonnet::EXT('resource.0.cssfile'); |
|
if ($css_href =~ /\S/) { |
|
&Apache::lonxml::extlink($css_href); |
|
$links .= |
|
'<link rel="stylesheet" type="text/css" href="'.$css_href.'" />'; |
|
} |
|
return $links; |
|
} |
|
|
#-- <body> tag (end tag required) |
#-- <body> tag (end tag required) |
sub start_body { |
sub start_body { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
Line 530 sub start_body {
|
Line 580 sub start_body {
|
if (&is_inside_of($tagstack, "head")) { |
if (&is_inside_of($tagstack, "head")) { |
&end_head(@_); |
&end_head(@_); |
} |
} |
|
|
|
my $extra_head = &generate_css_links(); |
|
|
$currentstring = |
$currentstring = |
&Apache::loncommon::start_page($Apache::londefdef::title, |
&Apache::loncommon::start_page($Apache::londefdef::title, |
$Apache::londefdef::head, |
$Apache::londefdef::head |
|
.$extra_head, |
{'add_entries' => $token->[2], |
{'add_entries' => $token->[2], |
'no_title' => 1, |
'no_title' => 1, |
'force_register' => 1}); |
'force_register' => 1}); |
|
|
if ($env{'request.state'} ne 'published') { |
if ($env{'request.state'} ne 'published') { |
$currentstring.=&Apache::lonmenu::constspaceform(); |
$currentstring.=&Apache::lonmenu::constspaceform(); |
$currentstring.=(<<EDITBUTTON); |
$currentstring.=&Apache::londefdef::edit_controls(); |
<form method="post"> |
|
<input type="submit" name="editmode" accesskey="e" value="Edit" /> |
|
</form> |
|
<br /> |
|
EDITBUTTON |
|
} |
} |
$currentstring.=&Apache::lonxml::message_location(); |
$currentstring.=&Apache::lonxml::message_location(); |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
Line 553 EDITBUTTON
|
Line 602 EDITBUTTON
|
return $currentstring; |
return $currentstring; |
} |
} |
|
|
|
sub edit_controls { |
|
my $result .= ' |
|
<form method="post"> |
|
<div class="LC_edit_problem_header"> |
|
<div class="LC_edit_problem_header_row1">'. |
|
&Apache::lonxml::renderingoptions().' |
|
<input type="submit" name="changeproblemmode" value="'.&mt('Change View').'" /> |
|
</div> |
|
<div class="LC_edit_problem_header_edit_row"><input type="submit" name="editmode" accesskey="e" value="'.&mt('Edit').'" /></div></div> |
|
</form> |
|
<br />'; |
|
return $result; |
|
} |
|
|
sub end_body { |
sub end_body { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; |
my $currentstring = &end_p(); # Close off unclosed <p> |
my $currentstring = &end_p(); # Close off unclosed <p> |
Line 1228 sub start_br {
|
Line 1291 sub start_br {
|
$signal = 1; |
$signal = 1; |
} |
} |
} |
} |
if ($signal eq 1) { |
if ($signal != 1) { |
$currentstring .= ' \vskip 0 mm '; |
|
} else { |
|
$currentstring .= '\strut \\\\ \strut '; |
$currentstring .= '\strut \\\\ \strut '; |
} |
} |
|
|
Line 1542 sub start_div {
|
Line 1603 sub start_div {
|
} |
} |
if ($target eq 'tex') { |
if ($target eq 'tex') { |
# 4 possible alignments: left, right, center, and -missing-. |
# 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 = ''; |
my $endstring = ''; |
|
|
Line 1552 sub start_div {
|
Line 1616 sub start_div {
|
$endstring = '\end{center}'; |
$endstring = '\end{center}'; |
if (&is_inside_of($tagstack, "table")) { |
if (&is_inside_of($tagstack, "table")) { |
$currentstring = ¢er_correction().$currentstring; |
$currentstring = ¢er_correction().$currentstring; |
|
$endstring .= ¢er_end_correction(); |
} |
} |
} |
} |
elsif ($align eq 'right') { |
elsif ($align eq 'right') { |
Line 1607 sub end_a {
|
Line 1672 sub end_a {
|
&Apache::lonxml::get_param('href',$parstack,$safeeval,undef,1); |
&Apache::lonxml::get_param('href',$parstack,$safeeval,undef,1); |
my $name = |
my $name = |
&Apache::lonxml::get_param('name',$parstack,$safeeval,undef,1); |
&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; |
$href =~ s/([^\\])%/$1\\\%/g; |
$currentstring .= ' ({\tt URI:'.&Apache::lonxml::latex_special_symbols($href).'})'; |
# Substitute special symbols... and allow line breaks at each / |
} elsif ($name =~ /\S/) { |
# |
|
$href = &Apache::lonxml::latex_special_symbols($href); |
|
$href =~ s/\//\/\\-/g; # Map / to /\- to allow hyphenation. |
|
$currentstring .= ' ({\tt URI:'.$href.'})'; |
|
} elsif (($name =~ /\S/) && ($anchorprint=~/^on|anchorprint|yes|1$/i)) { |
$currentstring .= ' ({\tt Anchor:'.&Apache::lonxml::latex_special_symbols($name).'})'; |
$currentstring .= ' ({\tt Anchor:'.&Apache::lonxml::latex_special_symbols($name).'})'; |
} else { |
} else { |
$currentstring.=''; |
$currentstring.=''; |
Line 1953 sub start_table {
|
Line 2026 sub start_table {
|
if ($target eq 'web' || $target eq 'webgrade') { |
if ($target eq 'web' || $target eq 'webgrade') { |
$currentstring .= $token->[4]; |
$currentstring .= $token->[4]; |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
|
&disable_para(); # Can't have paras in a table. |
push(@Apache::londefdef::table, {}); |
push(@Apache::londefdef::table, {}); |
$Apache::londefdef::table[-1]{'row_number'} = -1; |
$Apache::londefdef::table[-1]{'row_number'} = -1; |
#maximum table's width (default coincides with text line length) |
#maximum table's width (default coincides with text line length) |
Line 1985 sub start_table {
|
Line 2059 sub start_table {
|
} else { |
} else { |
$TeXwidth = $textwidth; |
$TeXwidth = $textwidth; |
} |
} |
} else { |
} |
$Apache::londefdef::table[-1]{'forcedtablewidth'} = 1; |
# if the width is specified as a % it is converted to an absolute width. |
} |
# otherwise.. just plugged right in the hash |
# This stuff looks a bit hokey.. |
|
# Percentage width is actually given as an absolute width.. |
|
# so what's the difference? |
|
# |
|
if ($TeXwidth=~/%/) { |
if ($TeXwidth=~/%/) { |
$Apache::londefdef::table[-1]{'percent'}=1; |
|
$TeXwidth=~/(\d+)/; |
$TeXwidth=~/(\d+)/; |
$Apache::londefdef::table[-1]{'width'}=$1*$textwidth/100; |
$Apache::londefdef::table[-1]{'width'}=$1*$textwidth/100; |
} else { |
} else { |
$Apache::londefdef::table[-1]{'forcedtablewidth'} = 1; # may or may not need this? |
|
$Apache::londefdef::table[-1]{'width'}=$TeXwidth; |
$Apache::londefdef::table[-1]{'width'}=$TeXwidth; |
} |
} |
# In the end, however the table width cannot be wider than $textwidth... |
# In the end, however the table width cannot be wider than $textwidth... |
Line 2044 sub end_table {
|
Line 2113 sub end_table {
|
if ($target eq 'web' || $target eq 'webgrade') { |
if ($target eq 'web' || $target eq 'webgrade') { |
$currentstring = $token->[2]; |
$currentstring = $token->[2]; |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
|
my $border = &Apache::lonxml::get_param('border',$parstack,$safeeval); |
my $inmemory = ''; |
my $inmemory = ''; |
my $output = ''; |
my $output = ''; |
my $WARNING=''; |
my $WARNING=''; |
#width of columns from TeXwidth attributes |
#width of columns from TeXwidth attributes |
|
|
|
# Protect against unbalanced </table> tag. |
|
|
|
if (scalar(@Apache::londefdef::table) > 0) { |
|
|
for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) { |
for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) { |
for (my $jn=0;$jn<=$Apache::londefdef::table[-1]{'counter_columns'};$jn++) { |
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]) { |
if ($Apache::londefdef::table[-1]{'TeXlen'}[0][$jn]<$Apache::londefdef::table[-1]{'TeXlen'}[$in][$jn]) { |
Line 2140 sub end_table {
|
Line 2214 sub end_table {
|
my @fwidth=@{$Apache::londefdef::table[-1]{'TeXlen'}[0]};#final width array |
my @fwidth=@{$Apache::londefdef::table[-1]{'TeXlen'}[0]};#final width array |
my @adjust=(); |
my @adjust=(); |
#step 1. adjustment by maximum value |
#step 1. adjustment by maximum value |
my $space_neeeded=0; |
my $space_needed=0; |
for (my $jn=0;$jn<=$#max_len;$jn++) { |
for (my $jn=0;$jn<=$#max_len;$jn++) { |
$space_neeeded=$space_neeeded+$max_len[$jn]; |
$space_needed=$space_needed+$max_len[$jn]; |
} |
} |
if ($space_neeeded<=$available_space) { |
if ($space_needed<=$available_space) { |
|
|
for (my $jn=0;$jn<=$#max_len;$jn++) { |
for (my $jn=0;$jn<=$#max_len;$jn++) { |
if ($fwidth[$jn]==0) { |
if ($fwidth[$jn]==0) { |
Line 2153 sub end_table {
|
Line 2227 sub end_table {
|
} |
} |
} else { |
} else { |
#step 2. adjustment by minimum value (estimation) |
#step 2. adjustment by minimum value (estimation) |
$space_neeeded=0; |
$space_needed=0; |
for (my $jn=0;$jn<=$#min_len;$jn++) { |
for (my $jn=0;$jn<=$#min_len;$jn++) { |
$space_neeeded+=$min_len[$jn]; |
$space_needed+=$min_len[$jn]; |
} |
} |
if ($space_neeeded>$available_space) { |
if ($space_needed>$available_space) { |
$WARNING=' \textbf{NOT ENOUGH SPACE FOR TABLE} '; |
$WARNING=' \textbf{NOT ENOUGH SPACE FOR TABLE} '; |
for (my $jn=0;$jn<=$#max_len;$jn++) { |
for (my $jn=0;$jn<=$#max_len;$jn++) { |
if ($fwidth[$jn]==0) { |
if ($fwidth[$jn]==0) { |
Line 2174 sub end_table {
|
Line 2248 sub end_table {
|
} |
} |
} |
} |
if ($how_many_to_scale>0) { |
if ($how_many_to_scale>0) { |
my $space_to_adjust=($space_neeeded-$available_space)/$how_many_to_scale; |
my $space_to_adjust=($space_needed-$available_space)/$how_many_to_scale; |
foreach my $jn (@to_scale) { |
foreach my $jn (@to_scale) { |
for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) { |
for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) { |
$Apache::londefdef::table[-1]{'content'}[$in][$jn]=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/; |
$Apache::londefdef::table[-1]{'content'}[$in][$jn]=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/; |
Line 2196 sub end_table {
|
Line 2270 sub end_table {
|
} |
} |
} else { |
} else { |
#step 3. adjustment over minimal + corrections |
#step 3. adjustment over minimal + corrections |
my $enlarge_coef=$available_space/$space_neeeded; |
my $enlarge_coef=$available_space/$space_needed; |
my $acsessive=0; |
my $acsessive=0; |
for (my $jn=0;$jn<=$#min_len;$jn++) { |
for (my $jn=0;$jn<=$#min_len;$jn++) { |
$adjust[$jn]=$min_len[$jn]*$enlarge_coef; |
$adjust[$jn]=$min_len[$jn]*$enlarge_coef; |
Line 2229 sub end_table {
|
Line 2303 sub end_table {
|
} |
} |
} |
} |
} |
} |
#use all available width if it is defined in % or as TeXwidth |
# use all available width or specified width as if not specified, |
if (($Apache::londefdef::table[-1]{'percent'}==1) || ($Apache::londefdef::table[-1]{'forcedtablewidth'}==1)) { |
# the specified width gets defaulted to the available width. |
my $current=0; |
|
for (my $i=0;$i<=$#fwidth;$i++) { |
my $current=0; |
$current+=$fwidth[$i]; |
for (my $i=0;$i<=$#fwidth;$i++) { |
} |
$current+=$fwidth[$i]; |
my $coef=$Apache::londefdef::table[-1]{'width'}/$current; |
} |
for (my $i=0;$i<=$#fwidth;$i++) { |
if ($current == 0) { |
$fwidth[$i]*=$coef; |
$current = $Apache::londefdef::table[-1]{'width'}; |
} |
} |
|
my $coef=$Apache::londefdef::table[-1]{'width'}/$current; |
|
for (my $i=0;$i<=$#fwidth;$i++) { |
|
$fwidth[$i]*=$coef; |
} |
} |
#removing of empty columns if allowed |
#removing of empty columns if allowed |
my $permission=&Apache::lonxml::get_param('TeXDropEmptyColumns',$parstack,$safeeval,undef,0); |
my $permission=&Apache::lonxml::get_param('TeXDropEmptyColumns',$parstack,$safeeval,undef,0); |
Line 2288 sub end_table {
|
Line 2365 sub end_table {
|
# Do the appropriate magic if this has a colspan |
# Do the appropriate magic if this has a colspan |
# |
# |
|
|
|
my $border_char = ""; |
|
if ($border) { |
|
$border_char = "|"; |
|
} |
my $spanwidth = 0; |
my $spanwidth = 0; |
if ($colspan > 1) { |
if ($colspan > 1) { |
for (my $spancol = $jn; $spancol < $jn + $colspan; $spancol++) { |
for (my $spancol = $jn; $spancol < $jn + $colspan; $spancol++) { |
Line 2297 sub end_table {
|
Line 2378 sub end_table {
|
$colspan |
$colspan |
."}"; |
."}"; |
if ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'c') { |
if ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'c') { |
$output .= '{|c|}{'; |
$output .= '{'.$border_char.'c'.$border_char.'}{'; |
} elsif ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'r') { |
} elsif ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'r') { |
$output .= '{|r|}{'; |
$output .= '{'.$border_char.'r'.$border_char.'}{'; |
} |
} |
else { |
else { |
$output .= "{|p{$spanwidth mm}|}{"; |
$output .= '{'.$border_char."p{$spanwidth mm}".$border_char.'}{'; |
} |
} |
|
|
} else { |
} else { |
Line 2318 sub end_table {
|
Line 2399 sub end_table {
|
if ($rowspan > 1) { |
if ($rowspan > 1) { |
if ($colspan == 1) { |
if ($colspan == 1) { |
if ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'c') { |
if ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'c') { |
$output .= '\multicolumn{1}{|c|}{'; |
$output .= '\multicolumn{1}{'.$border_char.'c'.$border_char.'}{'; |
$multirow_aligned = 1; |
$multirow_aligned = 1; |
} elsif ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'r') { |
} elsif ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'r') { |
$output .= '\multicolumn{1}{|r|}{'; |
$output .= '\multicolumn{1}{'.$border_char.'r'.$border_char.'}{'; |
$multirow_aligned = 1; |
$multirow_aligned = 1; |
} |
} |
} |
} |
Line 2358 sub end_table {
|
Line 2439 sub end_table {
|
# |
# |
if ($colspan == 1 && $rowspan == 1) { |
if ($colspan == 1 && $rowspan == 1) { |
if ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'c') { |
if ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'c') { |
$output .= '\multicolumn{1}{|c|}{'; |
$output .= '\multicolumn{1}{'.$border_char.'c'.$border_char.'}{'; |
} elsif ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'r') { |
} elsif ($Apache::londefdef::table[-1]{'align'}[$in][$jn] eq 'r') { |
$output .= '\multicolumn{1}{|r|}{'; |
$output .= '\multicolumn{1}{'.$border_char.'r'.$border_char.'}{'; |
} |
} |
} |
} |
|
|
Line 2444 sub end_table {
|
Line 2525 sub end_table {
|
pop @Apache::londefdef::table; |
pop @Apache::londefdef::table; |
undef @Apache::londefdef::table; |
undef @Apache::londefdef::table; |
} |
} |
|
} |
|
&enable_para(); |
} |
} |
return $currentstring; |
return $currentstring; |
} |
} |
Line 2943 sub start_img {
|
Line 3026 sub start_img {
|
|
|
# &Apache::lonxml::debug("LaTeX rendering = $latex_rendering image file: $src"); |
# &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 $origsrc=$src; |
my ($path,$file) = &get_eps_image($src); |
my ($path,$file) = &get_eps_image($src); |
# &Apache::lonnet::logthis("Image source: $src result: $path $file"); |
# &Apache::lonnet::logthis("Image source: $src result: $path $file"); |
Line 2987 sub start_img {
|
Line 3070 sub start_img {
|
# And here's where the semi-quote breaks down: allow the user |
# And here's where the semi-quote breaks down: allow the user |
# to edit the beast as well by rendering the problem for edit: |
# to edit the beast as well by rendering the problem for edit: |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
|
my $only = join(',',&Apache::loncommon::filecategorytypes('Pictures')); |
$currentstring .=&Apache::edit::tag_start($target,$token); |
$currentstring .=&Apache::edit::tag_start($target,$token); |
$currentstring .=&Apache::edit::text_arg('Image Url:','src',$token,70). |
$currentstring .=&Apache::edit::text_arg('Image Url:','src',$token,70). |
&Apache::edit::browse('src',undef,'alt').' '. |
&Apache::edit::browse('src',undef,'alt',$only).' '. |
&Apache::edit::search('src',undef,'alt').'<br />'; |
&Apache::edit::search('src',undef,'alt').'<br />'; |
$currentstring .=&Apache::edit::text_arg('Description:','alt',$token,70).'<br />'; |
$currentstring .=&Apache::edit::text_arg('Description:','alt',$token,70).'<br />'; |
$currentstring .=&Apache::edit::text_arg('width (pixel):','width',$token,5); |
$currentstring .=&Apache::edit::text_arg('width (pixel):','width',$token,5); |
Line 3008 sub start_img {
|
Line 3092 sub start_img {
|
my $width= &Apache::lonxml::get_param('width',$parstack,$safeeval); |
my $width= &Apache::lonxml::get_param('width',$parstack,$safeeval); |
my $height= &Apache::lonxml::get_param('height',$parstack,$safeeval); |
my $height= &Apache::lonxml::get_param('height',$parstack,$safeeval); |
|
|
|
if ($token->[2]{'src'}=~/\$/) { |
$currentstring .= '<img src="'.$src.'" alt="'.$alt.'" '; |
$currentstring.='Variable image source'; |
if ($width) { $currentstring.=' width="'.$width.'" '; } |
} else { |
if ($height) { $currentstring.=' height="'.$height.'" '; } |
$currentstring .= '<img src="'.$src.'" alt="'.$alt.'" '; |
$currentstring .= ' />'; |
if ($width) { $currentstring.=' width="'.$width.'" '; } |
|
if ($height) { $currentstring.=' height="'.$height.'" '; } |
|
$currentstring .= ' />'; |
|
} |
} elsif ($target eq 'modified') { |
} elsif ($target eq 'modified') { |
my ($osrc,$owidth,$oheight)= |
my ($osrc,$owidth,$oheight)= |
($token->[2]{'src'},$token->[2]{'width'},$token->[2]{'height'}); |
($token->[2]{'src'},$token->[2]{'width'},$token->[2]{'height'}); |
Line 4340 sub get_eps_image {
|
Line 4427 sub get_eps_image {
|
&Apache::lonnet::repcopy($orig_src); # Failure is not completely fatal. |
&Apache::lonnet::repcopy($orig_src); # Failure is not completely fatal. |
} |
} |
&Apache::lonxml::debug("get_eps_image: Original image: $orig_src"); |
&Apache::lonxml::debug("get_eps_image: Original image: $orig_src"); |
my ($spath, $sname, $sext) = &fileparse($src, qr/\.(gif|png|jpg|jpeg)/i); |
my ($spath, $sname, $sext) = &fileparse($src, qr/\.(bmp|gif|png|jpg|jpeg)/i); |
$src=~s/\.(gif|png|jpg|jpeg)$/\.eps/i; |
$src=~s/\.(bmp|gif|png|jpg|jpeg)$/\.eps/i; |
$src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src); |
$src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src); |
&Apache::lonxml::debug("Filelocation gives: $src"); |
&Apache::lonxml::debug("Filelocation gives: $src"); |
if (! -e $src) { |
if (! -e $src) { |
Line 4402 sub eps_generation {
|
Line 4489 sub eps_generation {
|
my $temp_file = Apache::File->new('>>'.$filename); |
my $temp_file = Apache::File->new('>>'.$filename); |
print $temp_file "$src\n"; |
print $temp_file "$src\n"; |
my $newsrc = $src; |
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/httpd/html/res}{}; |
$newsrc=~s{/home/($LONCAPA::username_re)/public_html/}{/$1/}; |
$newsrc=~s{/home/($LONCAPA::username_re)/public_html/}{/$1/}; |
$newsrc=~s{/\./}{/}; |
$newsrc=~s{/\./}{/}; |
Line 4492 sub align_latex_image {
|
Line 4579 sub align_latex_image {
|
my ($align, $latex_rendering, $image, $width, $height) = @_; |
my ($align, $latex_rendering, $image, $width, $height) = @_; |
my $currentstring; # The 1/2 wrapped image. |
my $currentstring; # The 1/2 wrapped image. |
my $closure; # The closure of the wrappage. |
my $closure; # The closure of the wrappage. |
|
|
|
# if it's none just return it back |
|
if ($latex_rendering eq 'none') { |
|
return ($image,''); |
|
} |
|
|
# If there's an alignment specification we need to honor it here. |
# If there's an alignment specification we need to honor it here. |
# For the horizontal alignments, we will also honor the |
# For the horizontal alignments, we will also honor the |
# value of the latex specfication. The default is parbox, |
# value of the latex specfication. The default is parbox, |