--- loncom/xml/londefdef.pm 2002/01/18 16:33:54 1.41
+++ loncom/xml/londefdef.pm 2002/02/26 22:27:22 1.46
@@ -1,7 +1,8 @@
+
# The LearningOnline Network with CAPA
# Tags Default Definition Module
#
-# $Id: londefdef.pm,v 1.41 2002/01/18 16:33:54 sakharuk Exp $
+# $Id: londefdef.pm,v 1.46 2002/02/26 22:27:22 sakharuk Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -49,7 +50,7 @@ use Apache::lonxml;
BEGIN {
- &Apache::lonxml::register('Apache::londefdef',('m','html','head','map','select','option','input','textarea','form','meta','title','body','center','b','strong','table','dt','h1','h2','h3','h4','h5','h6','cite','i','address','dd','dl','dir','ol','ul','menu','dfn','kbd','tt','code','em','q','p','br','big','small','basefont','font','s','sub','strike','sup','hr','a','li','u','output','param','applet','img','embed','tr','td','allow','frameset','pre'));
+ &Apache::lonxml::register('Apache::londefdef',('m','html','head','map','select','option','input','textarea','form','meta','title','body','center','b','strong','table','dt','h1','h2','h3','h4','h5','h6','cite','i','address','dd','dl','dir','ol','ul','menu','dfn','kbd','tt','code','em','q','p','br','big','small','basefont','font','s','sub','strike','sup','hr','a','li','u','output','param','applet','img','embed','tr','td','allow','frameset','pre','insert'));
}
@@ -123,7 +124,8 @@ sub end_m {
\setlength{\marginparwidth}{90pt}
\setlength{\textfloatsep}{8pt plus 2.0pt minus 4.0pt}
\newcommand{\keephidden}[1]{}
- \usepackage[dvips]{graphicx}';
+ \usepackage[dvips]{graphicx}
+ \usepackage{epsfig}';
}
return $currentstring;
}
@@ -1309,7 +1311,7 @@ EDITBUTTON
my ($target,$token) = @_;
my $currentstring = '';
if ($target eq 'web') {
- $currentstring = $token->[4];
+ $currentstring = $token->[4];
} elsif ($target eq 'tex') {
$currentstring = '';
}
@@ -1319,38 +1321,57 @@ EDITBUTTON
my ($target,$token) = @_;
my $currentstring = '';
if ($target eq 'web') {
- $currentstring = $token->[2];
+ $currentstring = $token->[2];
} elsif ($target eq 'tex') {
- $currentstring = '';
- }
+ $currentstring = '';
+ }
return $currentstring;
}
#-- tag
sub start_img {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
- $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
+ $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
$token->[2]->{'src'};
my $currentstring = '';
- if ($target eq 'web') {
+
+ if ($target eq 'web') {
$currentstring = $token->[4];
} elsif ($target eq 'tex') {
- my $durty = $token->[2]->{'src'};
- $durty =~ s!(^.*)/(.*)$!$1/!;
- my $durtytwo = $2;
- my $num = index($durtytwo,'gif',0);
- substr($durtytwo,$num,3) = 'eps';
- $currentstring = '\graphicspath{{/home/httpd/html'.$durty.'}}\fbox{\includegraphics{'.$durtytwo.'}}';
- }
- return $currentstring;
+ my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval);
+ my $file;
+ my $path;
+ if ($src =~ m!(.*)/([^/]*)$!) {
+ $file = $2;
+ $path = $1;
+ if ($path=~m:^/:) {
+ $path = '/home/httpd/html'.$path;
+ } elsif ($path =~ /^\./) {
+ $path = $Apache::lonxml::pwd[-1].'/'.$path;
+ } else {
+ #else it is a full url don't print
+ $path = undef;
+ }
+ } else {
+ $path = $Apache::lonxml::pwd[-1];
+ $file = $src;
+ }
+ $file=~s/(\.gif|\.jpg)$/\.eps/;
+ if ($path) {
+ $currentstring = '\graphicspath{{'.$path.'}}\fbox{\includegraphics{'.$file.'}}';
+ } else {
+ $currentstring = 'See the image at \tt{'.$src.'}';
+ }
+ }
+ return $currentstring;
}
sub end_img {
my ($target,$token) = @_;
my $currentstring = '';
if ($target eq 'web') {
- $currentstring = $token->[2];
+ $currentstring = $token->[2];
} elsif ($target eq 'tex') {
- $currentstring = '';
- }
+ $currentstring = '';
+ }
return $currentstring;
}
#--