version 1.8, 2005/04/07 06:56:21
|
version 1.11, 2006/05/30 12:45:37
|
Line 26 package Apache::imagechoice;
|
Line 26 package Apache::imagechoice;
|
use strict; |
use strict; |
use Apache::Constants qw(:common :http); |
use Apache::Constants qw(:common :http); |
use Apache::lonnet; |
use Apache::lonnet; |
|
use lib '/home/httpd/lib/perl/'; |
|
use LONCAPA; |
|
|
|
|
sub deletedata { |
sub deletedata { |
my ($id)=@_; |
my ($id)=@_; |
Line 33 sub deletedata {
|
Line 36 sub deletedata {
|
} |
} |
|
|
sub closewindow { |
sub closewindow { |
my ($r,$output,$filename,$needimage)=@_; |
my ($r,$output,$filename,$needimage,$display)=@_; |
if ($needimage) { |
if ($needimage) { |
$needimage="<img name=\"pickimg\" src=\"$filename\" />"; |
$needimage="<img name=\"pickimg\" src=\"$filename\" />"; |
} |
} |
$r->print(<<"ENDSUBM"); |
my $js=<<"ENDSUBM"; |
<html> |
<script type="text/javascript"> |
<script> |
|
function submitthis() { |
function submitthis() { |
$output |
$output |
self.close(); |
self.close(); |
} |
} |
</script> |
</script> |
<body bgcolor="#FFFFFF" onLoad="submitthis()"> |
ENDSUBM |
|
|
|
my $start_page = |
|
&Apache::loncommon::start_page('Close Window',$js, |
|
{'bgcolor' => '#FFFFFF', |
|
'only_body' => 1, |
|
'add_entries' => { |
|
onload => 'submitthis();'},}); |
|
|
|
my $end_page = |
|
&Apache::loncommon::end_page(); |
|
|
|
my $js=<<"ENDSUBM"; |
|
$start_page |
<h3>Position Selected</h3> |
<h3>Position Selected</h3> |
|
$display |
$needimage |
$needimage |
</body> |
$end_page |
</html> |
|
ENDSUBM |
ENDSUBM |
} |
} |
|
|
Line 69 sub storedata {
|
Line 84 sub storedata {
|
$needimage=1; |
$needimage=1; |
} |
} |
|
|
|
my $display; |
if ($type eq 'point') { |
if ($type eq 'point') { |
my (undef,$x,$y)=split(':',$env{"imagechoice.$id.coords"}); |
my (undef,$x,$y)=split(':',$env{"imagechoice.$id.coords"}); |
if ($env{"imagechoice.$id.formx"}) { |
if ($env{"imagechoice.$id.formx"}) { |
$output.='opener.document.forms.'.$env{"imagechoice.$id.formname"}.'.'.$env{"imagechoice.$id.formx"}.'.value='.$x.';'; |
$output.='opener.document.forms.'.$env{"imagechoice.$id.formname"}.'.'.$env{"imagechoice.$id.formx"}.'.value='.$x.';'; |
|
$display.="<p>The X coordinate is $x</p>\n"; |
} |
} |
if ($env{"imagechoice.$id.formy"}) { |
if ($env{"imagechoice.$id.formy"}) { |
$output.='opener.document.forms.'.$env{"imagechoice.$id.formname"}.'.'.$env{"imagechoice.$id.formy"}.'.value='.$y.';'; |
$output.='opener.document.forms.'.$env{"imagechoice.$id.formname"}.'.'.$env{"imagechoice.$id.formy"}.'.value='.$y.';'; |
|
$display.="<p>The Y coordinate is $y</p>\n"; |
} |
} |
} elsif ($type eq 'polygon' or $type eq 'box') { |
} elsif ($type eq 'polygon' or $type eq 'box') { |
my $coordstr; |
my $coordstr; |
Line 83 sub storedata {
|
Line 101 sub storedata {
|
$coordstr.='('.shift(@coords).','.shift(@coords).')-'; |
$coordstr.='('.shift(@coords).','.shift(@coords).')-'; |
} |
} |
chop($coordstr); |
chop($coordstr); |
|
$display.="<p>The selected coordinates are <tt>$coordstr</tt></p>\n"; |
$output.='opener.document.forms.'.$env{"imagechoice.$id.formname"}.'.'.$env{"imagechoice.$id.formcoord"}.'.value="'.$coordstr.'";'; |
$output.='opener.document.forms.'.$env{"imagechoice.$id.formname"}.'.'.$env{"imagechoice.$id.formcoord"}.'.value="'.$coordstr.'";'; |
} |
} |
|
if ($display) { |
|
$display.="<p>If this window fails to close you may need to manually replace the old coordinates with the above value.</p>\n"; |
|
} |
&deletedata($id); |
&deletedata($id); |
&closewindow($r,$output,$filename,$needimage); |
&closewindow($r,$output,$filename,$needimage,$display); |
} |
} |
|
|
sub getcoord { |
sub getcoord { |
Line 114 sub getcoord {
|
Line 135 sub getcoord {
|
$heading='Click to select a Coordinate or click Finish to store current selection.'; |
$heading='Click to select a Coordinate or click Finish to store current selection.'; |
$nextstage='<input type="submit" name="finish" value="Finish" />'; |
$nextstage='<input type="submit" name="finish" value="Finish" />'; |
} |
} |
|
|
|
my $start_page = |
|
&Apache::loncommon::start_page('Get Coordinates',undef, |
|
{'bgcolor' => '#FFFFFF', |
|
'only_body' => 1,}); |
|
|
|
my $end_page = |
|
&Apache::loncommon::end_page(); |
$r->print(<<"END"); |
$r->print(<<"END"); |
<html> |
$start_page |
<body bgcolor="#FFFFFF"> |
|
<h3>$heading</h3> |
<h3>$heading</h3> |
<form method="POST" action="/adm/imagechoice?token=$id"> |
<form method="POST" action="/adm/imagechoice?token=$id"> |
$nextstage |
$nextstage |
Line 124 $nextstage
|
Line 152 $nextstage
|
<br /> |
<br /> |
<input name="image" type="image" src="$filename" /> |
<input name="image" type="image" src="$filename" /> |
</form> |
</form> |
</body> |
$end_page |
</html> |
|
END |
END |
} |
} |
|
|
Line 221 sub handler {
|
Line 248 sub handler {
|
$r->send_http_header; |
$r->send_http_header; |
my %data; |
my %data; |
my (undef,$id) = split(/=/,$ENV{'QUERY_STRING'}); |
my (undef,$id) = split(/=/,$ENV{'QUERY_STRING'}); |
my $filename = &Apache::lonnet::unescape($env{"imagechoice.$id.file"}); |
my $filename = &unescape($env{"imagechoice.$id.file"}); |
my $formname = $env{"imagechoice.$id.formname"}; |
my $formname = $env{"imagechoice.$id.formname"}; |
if ($env{'form.cancel'} eq 'Cancel') { |
if ($env{'form.cancel'} eq 'Cancel') { |
&deletedata($id); |
&deletedata($id); |