version 1.426, 2010/11/18 17:42:15
|
version 1.429, 2011/04/05 10:33:15
|
Line 47 use Image::Magick;
|
Line 47 use Image::Magick;
|
use Apache::lonmenu(); |
use Apache::lonmenu(); |
use Apache::lonmeta(); |
use Apache::lonmeta(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
|
use Apache::loncommon(); |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use File::Basename; |
use File::Basename; |
use LONCAPA(); |
use LONCAPA(); |
Line 588 sub start_body {
|
Line 589 sub start_body {
|
sub edit_controls { |
sub edit_controls { |
my ($nochgview) = @_; |
my ($nochgview) = @_; |
my $result .= ' |
my $result .= ' |
<form method="post"> |
<form method="post" action=""> |
<div class="LC_edit_problem_header">'; |
<div class="LC_edit_problem_header">'; |
unless ($nochgview) { |
unless ($nochgview) { |
$result .= ' |
$result .= ' |
Line 600 sub edit_controls {
|
Line 601 sub edit_controls {
|
$result .= ' |
$result .= ' |
<div><input type="submit" name="editmode" accesskey="e" value="'.&mt('Edit').'" />'; |
<div><input type="submit" name="editmode" accesskey="e" value="'.&mt('Edit').'" />'; |
if (($env{'request.course.id'}) && ($env{'form.forceedit'})) { |
if (($env{'request.course.id'}) && ($env{'form.forceedit'})) { |
$result .= (' ' x 3).'<input type="button" value="'.&mt('Course View').'" onclick="javascript:location.href=currentURL" />'; |
my $viewtext = &mt('Course View'); |
|
if (&Apache::loncommon::course_type() eq 'Community') { |
|
$viewtext = &mt('Community View'); |
|
} |
|
$result .= (' ' x 3).'<input type="button" value="'. |
|
$viewtext.'" onclick="javascript:location.href=currentURL" />'; |
} |
} |
$result .= '</div> |
$result .= '</div> |
</div> |
</div> |
Line 2057 sub start_table {
|
Line 2063 sub start_table {
|
if ((defined $border) && ($border > 0)) { |
if ((defined $border) && ($border > 0)) { |
# &Apache::lonnet::logthis("Turning on table borders: $border"); |
# &Apache::lonnet::logthis("Turning on table borders: $border"); |
$table->table_border(1); |
$table->table_border(1); |
if ($cell_border ne 'none') { |
if (!defined $cell_border) { |
$table->cell_border(1); # html specs that border turns on both...unless rules='none'. |
$table->cell_border(1); # Default for rules is all if rules not defined. |
} |
} |
} |
} |
# Only all or nothing for cell borders for now: |
# Only all or nothing for cell borders for now: |
|
|
if ((defined $cell_border) && ($cell_border ne 'none')) { |
if ((defined $cell_border)) { |
# &Apache::lonnet::logthis("Turning on cell borders: $cell_border"); |
if ($cell_border eq 'all') { |
$table->cell_border(1); |
$table->cell_border(1); |
|
} elsif ($cell_border eq 'rows') { |
|
$table->cell_border(2); |
|
} elsif ($cell_border eq 'cols') { |
|
$table->cell_border(3); |
|
} else { |
|
$table->cell_border(0); |
|
} |
} |
} |
if (defined $theme) { |
if (defined $theme) { |
$table->theme($theme); |
$table->theme($theme); |
Line 2094 sub start_table {
|
Line 2107 sub start_table {
|
push(@Apache::londefdef::table, $table); |
push(@Apache::londefdef::table, $table); |
$currentstring.=' \keephidden{NEW TABLE ENTRY}'; |
$currentstring.=' \keephidden{NEW TABLE ENTRY}'; |
|
|
#-------------------------------------------------------- |
|
# Old table code here. |
|
#-------------------------------------------------------- |
|
|
|
|
|
if (0) { |
|
push(@Apache::londefdef::table, {}); |
|
$Apache::londefdef::table[-1]{'row_number'} = -1; |
|
#maximum table's width (default coincides with text line length) |
|
if ($#Apache::londefdef::table==0) { |
|
$textwidth=&recalc($env{'form.textwidth'}); #result is always in mm |
|
$textwidth=~/(\d+\.?\d*)/; |
|
$textwidth=0.85*$1; #accounts "internal" LaTeX space for table frame |
|
} else { |
|
if ($Apache::londefdef::table[-2]{'TeXlen'}[$Apache::londefdef::table[-2]{'row_number'}][$Apache::londefdef::table[-2]{'counter_columns'}]=~/\d/) { |
|
#the maximum width of nested table is determined by LATeX width of parent cell |
|
$textwidth=$Apache::londefdef::table[-2]{'TeXlen'}[$Apache::londefdef::table[-2]{'row_number'}][$Apache::londefdef::table[-2]{'counter_columns'}]; |
|
} else { |
|
#try to use all space not used before (minus 5% for LaTeX table internal) - rather silly |
|
$textwidth=$Apache::londefdef::table[-2]{'width'}; |
|
for (my $i=0;$i<$Apache::londefdef::table[-2]{'counter_columns'};$i++) { |
|
$textwidth=$textwidth-$Apache::londefdef::table[-2]{'TeXlen'}[0][$i]; |
|
} |
|
} |
|
} |
|
|
|
# width either comes forced from the TeXwidth or the width parameters. |
|
# in either case it can be a percentage or absolute width. |
|
# in the width case we ignore absolute width |
|
my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0); |
|
if (!defined($TeXwidth)) { |
|
my $htmlwidth = &Apache::lonxml::get_param('width',$parstack, |
|
$safeeval,undef,1); |
|
if ($htmlwidth =~ /%/) { |
|
$TeXwidth = $htmlwidth; |
|
} else { |
|
$TeXwidth = $textwidth; |
|
} |
|
} |
|
# if the width is specified as a % it is converted to an absolute width. |
|
# otherwise.. just plugged right in the hash |
|
|
|
if ($TeXwidth=~/%/) { |
|
$TeXwidth=~/(\d+)/; |
|
$Apache::londefdef::table[-1]{'width'}=$1*$textwidth/100; |
|
} else { |
|
$Apache::londefdef::table[-1]{'width'}=$TeXwidth; |
|
} |
|
# In the end, however the table width cannot be wider than $textwidth... |
|
|
|
if ($Apache::londefdef::table[-1]{'width'} > $textwidth) { |
|
$Apache::londefdef::table[-1]{'width'} = $textwidth; |
|
} |
|
#table's border |
|
my $border = &Apache::lonxml::get_param('border',$parstack,$safeeval); |
|
my $permission=&Apache::lonxml::get_param('TeXDropEmptyColumns',$parstack,$safeeval,undef,0); |
|
unless (defined $border) { $border = 0; } |
|
if ($border) { |
|
$Apache::londefdef::table[-1]{'hinc'} = '\hline '; |
|
$Apache::londefdef::table[-1]{'vinc'} = '&'; |
|
$Apache::londefdef::table[-1]{'vvinc'} = '|'; |
|
} else { |
|
$Apache::londefdef::table[-1]{'hinc'} = ''; |
|
$Apache::londefdef::table[-1]{'vinc'} = '&'; |
|
$Apache::londefdef::table[-1]{'vvinc'} = ''; |
|
} |
|
if ($#Apache::londefdef::table==0) { |
|
# Note that \newline seems to destroy the alignment envs. |
|
# $Apache::londefdef::table[-1]{'output'}='\strut\newline\strut\setlength{\tabcolsep}{1 mm}'; |
|
$Apache::londefdef::table[-1]{'output'}='\strut'.'\\\\'."\n".'\strut\setlength{\tabcolsep}{1 mm}'; |
|
} |
|
$Apache::londefdef::table[-1]{'output'}.=' \noindent \begin{tabular} '; |
|
$Apache::londefdef::table[-1]{'TeXlen'}=[]; |
|
$Apache::londefdef::table[-1]{'objectlen'}=[]; |
|
$Apache::londefdef::table[-1]{'objectsignal'}=[]; |
|
$Apache::londefdef::table[-1]{'maxlen'}=[]; |
|
$Apache::londefdef::table[-1]{'minlen'}=[]; |
|
$Apache::londefdef::table[-1]{'content'}=[]; |
|
$Apache::londefdef::table[-1]{'align'}=[]; |
|
$currentstring.=' \keephidden{NEW TABLE ENTRY}'; |
|
} |
|
|
|
} |
} |
return $currentstring; |
return $currentstring; |
} |
} |
Line 2188 sub end_table {
|
Line 2119 sub end_table {
|
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
|
|
|
|
# New table code: |
|
|
|
my $table = pop(@Apache::londefdef::table); |
my $table = pop(@Apache::londefdef::table); |
my $t = $table->generate(); |
my $t = $table->generate(); |
# &Apache::lonnet::logthis("Generating string"); |
# &Apache::lonnet::logthis("Generating string"); |