- # $Apache::londefdef::table[-1]{'output'} .= $header_of_table.$Apache::londefdef::table[-1]{'hinc'}.$output.'\end{tabular}\strut\newline\strut ';
- $Apache::londefdef::table[-1]{'output'} .= $header_of_table.$Apache::londefdef::table[-1]{'hinc'}.$output.'\end{tabular}\strut'.'\\\\'."\n".'\strut ';
- if ($#Apache::londefdef::table > 0) {
- my $inmemory = $Apache::londefdef::table[-1]{'output'};
- # Figure out max/and min width by summing us and then
- # apply that to the current column of the table we nest in
- # if it's larger than the current width or the current width
- # is undefined.
- #
- my $min_nested_width = 0;
- my $max_nested_width = 0;
- for (my $col = 0; $col <= $Apache::londefdef::table[-1]{'counter_columns'}; $col++) {
- $min_nested_width += $min_len[$col];
- $max_nested_width += $max_len[$col];
-
- }
- # Fudge in an extra 5 mm for borders etc:
-
- $min_nested_width += 5;
- $max_nested_width += 5;
-
- my $outer_column = $Apache::londefdef::table[-2]{'counter_columns'};
- my $outer_row = $Apache::londefdef::table[-2]{'row_number'};
- if ($min_nested_width > $Apache::londefdef::table[-2]{'minlen'}[$outer_row][$outer_column]) {
- $Apache::londefdef::table[-2]{'minlen'}[$outer_row][$outer_column] = $min_nested_width;
- }
- if ($max_nested_width > $Apache::londefdef::table[-2]{'maxlen'}[$outer_row][$outer_column]) {
- $Apache::londefdef::table[-2]{'maxlen'}[$outer_row][$outer_column] = $max_nested_width;
- }
-
- pop @Apache::londefdef::table;
- push @{$Apache::londefdef::table[-1]{'include'}}, $inmemory;
- } else {
- $currentstring .= $Apache::londefdef::table[-1]{'output'};
- pop @Apache::londefdef::table;
- undef @Apache::londefdef::table;
- }
- }
- &enable_para();
- }
+
}
return $currentstring;
}
@@ -2722,17 +2244,26 @@ sub tag_check {
#
sub cell_config_hash {
- my ($align, $rowspan, $colspan) = @_;
+ my ($align, $rowspan, $colspan, $width) = @_;
+ if ($rowspan ne '') {
+ $rowspan =~ s/^\s+|\s+$//g;
+ }
+ if ($colspan ne '') {
+ $colspan =~ s/^\s+|\s+$//g;
+ }
my %config;
if ($align ne '') {
$config{'halign'} = $align;
}
- if ($colspan ne "") {
+ if (($colspan =~ /^\d+$/) && ($colspan > 0)) {
$config{'colspan'} = $colspan;
}
- if ($rowspan ne '') {
+ if (($rowspan =~ /^\d+$/) && ($rowspan > 0)) {
$config{'rowspan'} = $rowspan;
}
+ if ($width ne '') {
+ $config{'width'} = $width;
+ }
return \%config;
}
@@ -2744,11 +2275,11 @@ sub start_td_tex {
# attributes, but empty of text. end_td_tex will
# fetch the contents from the recursive parse and
# fill the cell with them:
- my $align = &Apache::lonxml::get_param('align', $parstack, $safeeval, undef, 1);
- my $rowspan = &Apache::lonxml::get_param('rowspan', $parstack, $safeeval, undef, 1);
- my $colspan = &Apache::lonxml::get_param('colspan', $parstack, $safeeval, undef, 1);
-
- my $config = &cell_config_hash($align, $rowspan, $colspan);
+ my $align = &Apache::lonxml::get_param('align', $parstack, $safeeval);
+ my $rowspan = &Apache::lonxml::get_param('rowspan', $parstack, $safeeval);
+ my $colspan = &Apache::lonxml::get_param('colspan', $parstack, $safeeval);
+ my $width = &Apache::lonxml::get_param('TeXwidth', $parstack, $safeeval);
+ my $config = &cell_config_hash($align, $rowspan, $colspan, $width);
my $table = $Apache::londefdef::table[-1];
$table->add_cell('', $config);
@@ -3354,10 +2885,7 @@ sub start_applet {
&Apache::lonxml::extlink($archive);
my $currentstring = '';
if ($target eq 'web' || $target eq 'webgrade') {
- $currentstring = &Apache::lonenc::encrypt_ref($token,
- {'code'=>$code,
- 'archive'=>$archive}
- );
+ $currentstring = $token->[4];
} elsif ($target eq 'tex') {
# Turn off some stuff we can't be inside thank you LaTeX
@@ -3443,22 +2971,47 @@ sub end_embed {
#--
tag (end tag forbidden)
sub start_param {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
- if (&Apache::lonxml::get_param('name',$parstack,
- $safeeval,undef,1)=~/^cabbase$/i) {
+ my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval,
+ undef,1);
+ if ($name =~/^cabbase$/i) {
my $value=&Apache::lonxml::get_param('value',$parstack,
$safeeval,undef,1);
&Apache::lonxml::extlink($value);
- }
-
+ } elsif ($name eq 'flashvars') {
+ if (lc(&Apache::lonxml::get_param('type',$parstack,$safeeval,-2,1))
+ eq 'application/x-shockwave-flash') {
+ my $launcher =
+ &Apache::lonxml::get_param('data',$parstack,$safeeval,-2,1);
+ if ($launcher) {
+ &Apache::lonxml::extlink($launcher);
+ }
+ my $flashvars=&Apache::lonxml::get_param('value',$parstack,
+ $safeeval,undef,1);
+ if ($flashvars ne '') {
+ foreach my $item (split(/\&/,$flashvars)) {
+ my ($key,$value)=split(/=/,$item,2);
+ if ($key eq 'content') {
+ if ($value ne '') {
+ my ($dir) = ($launcher =~ m{(.+/)[^/]+$});
+ &Apache::lonxml::extlink($dir.$value);
+ }
+ } elsif ($key eq 'thumb') {
+ if ($value ne '') {
+ &Apache::lonxml::extlink($value);
+ }
+ }
+ }
+ }
+ }
+ }
my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
- &Apache::lonxml::extlink($src);
+ if ($src ne '') {
+ &Apache::lonxml::extlink($src);
+ }
my $currentstring = '';
if ($target eq 'web' || $target eq 'webgrade') {
my %toconvert;
- my $src=&Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
if ($src) { $toconvert{'src'}= $src; }
- my $name=&Apache::lonxml::get_param('name',$parstack,$safeeval,
- undef,1);
if ($name=~/^cabbase$/i) {
$toconvert{'value'}=&Apache::lonxml::get_param('value',$parstack,
$safeeval,undef,1);
@@ -3855,13 +3408,34 @@ sub end_col {
return $currentstring;
}
-#--
tag (end tag optional)
+#-- [4];
}
+ if ($target eq 'tex') {
+ # TODO: Ensure this tag is in a table:
+
+ # Fetch the attributes and build the hash for the
+ # call to define_colgroup.
+
+ my $span = &Apache::lonxml::get_param('span', $parstack, $safeeval);
+ my $halign = &Apache::lonxml::get_param('halign', $parstack, $safeeval);
+
+ my %colgroup_params;
+ if ($span ne '') {
+ $colgroup_params{'span'} = $span;
+ }
+ if ($halign ne '') {
+ $colgroup_params{'halign'} = $halign;
+ }
+
+ my $table = $Apache::londefdef::table[-1];
+ $table->define_colgroup(\%colgroup_params);
+
+ }
return $currentstring;
}
@@ -4355,6 +3929,12 @@ sub start_tbody {
if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[4];
}
+ if ($target eq 'tex') {
+ # TODO: Ensure this tag is within a table:
+
+ my $table = $Apache::londefdef::table[-1];
+ $table->start_body();
+ }
return $currentstring;
}
@@ -4364,6 +3944,12 @@ sub end_tbody {
if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[2];
}
+ if($target eq 'tex') {
+ # TODO: Ensure this tag is within a table:
+
+ my $table = $Apache::londefdef::table[-1];
+ $table->end_body();
+ }
return $currentstring;
}
@@ -4374,6 +3960,11 @@ sub start_tfoot {
if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[4];
}
+ if ($target eq 'tex') {
+ # TODO: ensure this is within a table tag.
+ my $table = $Apache::londefdef::table[-1];
+ $table->start_foot();
+ }
return $currentstring;
}
@@ -4383,6 +3974,11 @@ sub end_tfoot {
if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[2];
}
+ if ($target eq 'tex') {
+ # TODO: Ensure this is in side a table
+ my $table = $Apache::londefdef::table[-1];
+ $table->end_foot();
+ }
return $currentstring;
}
@@ -4393,6 +3989,11 @@ sub start_thead {
if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[4];
}
+ if ($target eq 'tex') {
+ # Assume we're in a table... TODO: Verify that and ignore tag if not.
+ my $table = $Apache::londefdef::table[-1];
+ $table->start_head();
+ }
return $currentstring;
}
@@ -4402,6 +4003,12 @@ sub end_thead {
if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[2];
}
+ if ($target eq 'tex') {
+ # TODO: Verify we are in a table and ignore tag if not.
+
+ my $table = $Apache::londefdef::table[-1];
+ $table->end_head();
+ }
return $currentstring;
}
@@ -4604,15 +4211,15 @@ 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/|;
+ $src=~s|/home/httpd/html/priv/[^/]+/([^/]*)/|/home/httpd/prtspool/$1/|;
if ($sext ne "") { # Put the ext. back in to uniquify.
$src =~ s/\.eps$/$sext.eps/;
}
@@ -4631,7 +4238,7 @@ sub get_eps_image {
print FILE "$src\n";
close FILE;
$src=~s|/home/httpd/html/res|/home/httpd/prtspool|;
- $src=~s|/home/([^/]*)/public_html/|/home/httpd/prtspool/$1/|;
+ $src=~s|/home/httpd/html/priv/[^/]+/([^/]*)/|/home/httpd/prtspool/$1/|;
}
my ($path,$file)=($src=~m|(.*)/([^/]*)$|);
$path =~ s/ /\_/g;
@@ -4643,12 +4250,14 @@ 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}{};
- $newsrc=~s{/home/($LONCAPA::username_re)/public_html/}{/$1/};
+ $newsrc=~s{/home/httpd/html/priv/[^/]+/($LONCAPA::username_re)/}{/$1/};
$newsrc=~s{/\./}{/};
$newsrc=~s{/([^/]+)\.(ps|eps)}{/};
if ($newsrc=~m{/home/httpd/lonUsers/}) {