--- loncom/xml/londefdef.pm 2002/01/18 16:33:54 1.41 +++ loncom/xml/londefdef.pm 2002/03/06 20:37:38 1.48 @@ -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.48 2002/03/06 20:37:38 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','externallink')); } @@ -114,16 +115,9 @@ sub end_m { &Apache::lonxml::fontsettings(); } elsif ($target eq 'tex') { $currentstring .= '\documentclass[letterpaper]{article} - \setlength{\oddsidemargin}{-40pt} - \setlength{\evensidemargin}{-60pt} - \setlength{\topmargin}{200pt} - \setlength{\textwidth}{4.4in} - \setlength{\textheight}{6.8in} - \setlength{\parindent}{20pt} - \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; } @@ -148,7 +142,7 @@ sub end_m { my ($target,$token) = @_; my $currentstring = ''; if ($target eq 'web') { - $currentstring = &Apache::lonxml::registerurl(). + $currentstring = &Apache::lonxml::registerurl(undef,$target). $token->[2]; } return $currentstring; @@ -330,7 +324,8 @@ sub end_m { my $currentstring = ''; if ($target eq 'web') { if (!$Apache::lonxml::registered) { - $currentstring.='
'.&Apache::lonxml::registerurl().''; + $currentstring.=''. + &Apache::lonxml::registerurl(undef,$target).''; } my $onLoad=''; foreach my $key (keys(%{$token->[2]})) { @@ -1309,7 +1304,7 @@ EDITBUTTON my ($target,$token) = @_; my $currentstring = ''; if ($target eq 'web') { - $currentstring = $token->[4]; + $currentstring = $token->[4]; } elsif ($target eq 'tex') { $currentstring = ''; } @@ -1319,38 +1314,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; } #--