- # $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 +2344,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 +2375,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);
@@ -3152,7 +2783,9 @@ sub start_img {
my $inside = &Apache::lonxml::get_all_text("/img",$parser,$style);
return '';
}
- &Apache::lonxml::extlink($src);
+ unless ($src =~ m{^data\:image/gif;base64,}) {
+ &Apache::lonxml::extlink($src);
+ }
my $currentstring = '';
my $scaling = .3;
@@ -3162,8 +2795,10 @@ sub start_img {
my $enc = ('yes' eq
lc(&Apache::lonxml::get_param('encrypturl',$parstack,
$safeeval)));
- $currentstring.=&Apache::lonenc::encrypt_ref($token,{'src'=>$src},
- $enc);
+ unless ($src =~ m{^data\:image/gif;base64,}) {
+ $currentstring.=&Apache::lonenc::encrypt_ref($token,{'src'=>$src},
+ $enc);
+ }
# and render unto TeX that which is LaTeX
} elsif ($target eq 'tex') {
@@ -3206,7 +2841,7 @@ sub start_img {
# &Apache::lonxml::debug("LaTeX rendering = $latex_rendering image file: $src");
- #if original bmp/gif/jpg/png file exist do following:
+ #if original bmp/gif/jpg/png/svg file exist do following:
my $origsrc=$src;
my ($path,$file) = &get_eps_image($src);
# &Apache::lonnet::logthis("Image source: $src result: $path $file");
@@ -3253,8 +2888,8 @@ sub start_img {
my $only = join(',',&Apache::loncommon::filecategorytypes('Pictures'));
$currentstring .=&Apache::edit::tag_start($target,$token);
$currentstring .=&Apache::edit::text_arg('Image Url:','src',$token,70).
- &Apache::edit::browse('src',undef,'alt',$only).' '.
- &Apache::edit::search('src',undef,'alt').'
';
+ &Apache::edit::browse_or_search('src',undef,'alt',$only,undef,1).
+ '
';
$currentstring .=&Apache::edit::text_arg('Description:','alt',$token,70).'
';
$currentstring .=&Apache::edit::text_arg('width (pixel):','width',$token,5);
$currentstring .=&Apache::edit::text_arg('height (pixel):','height',$token,5).'
';
@@ -3264,22 +2899,31 @@ 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.='
'.&mt('Warning: the description "[_1]" will be available, even for encrypted URL',$alt).'';
+ }
$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);
-
+ my $element = &Apache::edit::get_element('src');
+ my $text;
if ($token->[2]{'src'}=~/\$/) {
- $currentstring.='Variable image source';
- } else {
+ $text = &mt('Variable image source');
+ } elsif ($token->[2]{'src'}=~/\S/) {
$currentstring .= '
';
+ } else {
+ $text = &mt("No image source specified");
}
+ $currentstring .= '
'.$text.'';
} elsif ($target eq 'modified') {
my ($osrc,$owidth,$oheight)=
($token->[2]{'src'},$token->[2]{'width'},$token->[2]{'height'});
@@ -3347,10 +2991,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
@@ -3436,22 +3077,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);
@@ -3816,7 +3482,7 @@ sub start_caption {
my $currentstring = '';
if ($target eq 'web' || $target eq 'webgrade') {
$currentstring = $token->[4];
- }
+ }
return $currentstring;
}
@@ -3824,7 +3490,7 @@ sub end_caption {
my ($target,$token) = @_;
my $currentstring = '';
if ($target eq 'web' || $target eq 'webgrade') {
- $currentstring = $token->[2];
+ $currentstring = $token->[2];
}
return $currentstring;
}
@@ -3848,13 +3514,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;
}
@@ -3936,8 +3623,68 @@ sub start_iframe {
my ($target,$token) = @_;
my $currentstring = '';
if ($target eq 'web' || $target eq 'webgrade') {
- $currentstring = $token->[4];
- }
+ my ($src,$url,$query);
+ if ($token->[2]->{'src'}) {
+ $src = $token->[2]->{'src'};
+ } elsif ($token->[2]->{'SRC'}) {
+ $src = $token->[2]->{'SRC'};
+ }
+ if ($src) {
+ ($url,$query) = ($src =~ /^([^?]+)\??([^?]*)$/);
+ if ($query =~ /inhibitmenu=yes/) {
+ $currentstring = $token->[4];
+ } else {
+ my $inhibit;
+ if ($url =~ m{^[^/.].*\.x?html?$}) {
+ $inhibit = 1;
+ } elsif ($url =~ m{^/(uploaded|res)/.*\.x?html?$}) {
+ $inhibit = 1;
+ }
+ if ($inhibit) {
+ $currentstring = '