--- loncom/xml/londefdef.pm 2003/10/21 13:36:32 1.184
+++ loncom/xml/londefdef.pm 2003/10/24 21:25:50 1.187
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Tags Default Definition Module
#
-# $Id: londefdef.pm,v 1.184 2003/10/21 13:36:32 sakharuk Exp $
+# $Id: londefdef.pm,v 1.187 2003/10/24 21:25:50 albertel Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -50,6 +50,7 @@ use Apache::File();
use Image::Magick;
use Apache::lonmenu();
use Apache::lonmeta();
+use Apache::Constants qw(:common);
$Apache::londefdef::TD_redirection=0;
@@ -159,7 +160,7 @@ sub start_html {
&tth::tthoptions('-L -u0');
}
}
- if ($target eq 'web') {
+ if ($target eq 'web' || $target eq 'edit') {
$currentstring = &Apache::lonxml::xmlbegin().
&Apache::lonxml::fontsettings();
} elsif ($target eq 'tex') {
@@ -344,7 +345,7 @@ sub start_title {
}
if ($target eq 'meta') {
$currentstring='
';
- &start_output();
+ &start_output($target);
}
return $currentstring;
}
@@ -358,7 +359,7 @@ sub end_title {
$currentstring .= '}';
}
if ($target eq 'meta') {
- &end_output();
+ &end_output($target);
$currentstring='';
}
return $currentstring;
@@ -654,7 +655,7 @@ sub start_h1 {
$currentstring .= $pre.'{\\'.$TeXsize.' \textbf{';
} elsif ($target eq 'meta') {
$currentstring='';
- &start_output();
+ &start_output($target);
}
return $currentstring;
}
@@ -676,7 +677,7 @@ sub end_h1 {
}
$currentstring .= '}}'.$post;
} elsif ($target eq 'meta') {
- &end_output();
+ &end_output($target);
$currentstring='';
}
return $currentstring;
@@ -2178,6 +2179,44 @@ sub start_img {
# tag will care about replication
}
}
+ } elsif ($target eq 'edit') {
+ $currentstring .=&Apache::edit::tag_start($target,$token);
+ $currentstring .=&Apache::edit::text_arg('Image Url:','src',$token,70).
+ &Apache::edit::browse('src',undef,'alt').' '.
+ &Apache::edit::search('src',undef,'alt').'
';
+ $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).'
';
+ $currentstring .=&Apache::edit::text_arg('TeXwidth (mm):','TeXwidth',$token,5);
+ $currentstring .=&Apache::edit::text_arg('TeXheight (mm):','TeXheight',$token,5);
+ $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);
+ $currentstring .= '[2]{'width'} && !$token->[2]{'height'}) {
+ $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
+ &image_replication($src);
+ if (-e $src) {
+ my $image = Image::Magick->new;
+ my ($width, $height, $size, $format) = $image->Ping($src);
+ if ($width && $height) {
+ $token->[2]{'width'} =$width;
+ $token->[2]{'height'}=$height;
+ $constructtag=1;
+ }
+ }
+ }
+ if ($constructtag) {$currentstring=&Apache::edit::rebuild_tag($token);}
}
return $currentstring;
}
@@ -3294,18 +3333,14 @@ sub end_hideweboutput {
sub image_replication {
my $src = shift;
- if (not -e $src) {
- #replicates image itself
- &Apache::lonnet::repcopy($src);
- #replicates eps or ps
- my $newsrc = $src;
- $newsrc =~ s/\.(gif|jpg|jpeg|png)$/.eps/i;
- if (not -e $newsrc) {
- if (&Apache::lonnet::repcopy($newsrc) ne 'OK') {
- $newsrc =~ s/\.eps$/\.ps/;
- &Apache::lonnet::repcopy($newsrc);
- }
- }
+ if (not -e $src) { &Apache::lonnet::repcopy($src); }
+ #replicates eps or ps
+ my $epssrc = my $pssrc = $src;
+ $epssrc =~ s/\.(gif|jpg|jpeg|png)$/.eps/i;
+ $pssrc =~ s/\.(gif|jpg|jpeg|png)$/.ps/i;
+ if (not -e $epssrc && not -e $pssrc) {
+ my $result=&Apache::lonnet::repcopy($epssrc);
+ if ($result ne OK) { &Apache::lonnet::repcopy($pssrc); }
}
return '';
}