version 1.14, 2008/03/12 02:46:53
|
version 1.15, 2008/10/13 14:06:47
|
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 Apache::lonlocal; |
use LONCAPA; |
use LONCAPA; |
|
|
|
|
Line 112 sub storedata {
|
Line 113 sub storedata {
|
|
|
sub getcoord { |
sub getcoord { |
my ($r,$type,$filename,$id)=@_; |
my ($r,$type,$filename,$id)=@_; |
my $heading='Select Position on Image'; |
my $heading=&mt('Select Position on Image'); |
my $nextstage=''; |
my $nextstage=''; |
if ($type eq 'box') { |
if ($type eq 'box') { |
my (undef,@coords)=split(':',$env{"imagechoice.$id.coords"}); |
my (undef,@coords)=split(':',$env{"imagechoice.$id.coords"}); |
my $step=scalar(@coords)/2; |
my $step=scalar(@coords)/2; |
if ($step == 0) { |
if ($step == 0) { |
$heading='Select First Coordinate on Image'; |
$heading=&mt('Select First Coordinate on Image'); |
#$nextstage='<input type="hidden" name="type" value="pairtwo" />'; |
#$nextstage='<input type="hidden" name="type" value="pairtwo" />'; |
} elsif ($step == 1) { |
} elsif ($step == 1) { |
$heading='Select Second Coordinate on Image'; |
$heading=&mt('Select Second Coordinate on Image'); |
#$nextstage='<input type="hidden" name="type" value="pairthree" />'; |
#$nextstage='<input type="hidden" name="type" value="pairthree" />'; |
} else { |
} else { |
$heading='Select Finish to save selection.'; |
$heading=&mt('Select Finish to save selection'); |
$nextstage='<input type="submit" name="finish" value="Finish" />'; |
$nextstage='<input type="submit" name="finish" value="'.&mt('Finish').'" />'; |
} |
} |
} elsif ($type eq 'polygon') { |
} elsif ($type eq 'polygon') { |
$heading='Enter Coordinate or click finish to close Polygon'; |
$heading=&mt('Enter Coordinate or click finish to close Polygon'); |
$nextstage='<input type="submit" name="finish" value="Finish" />'; |
$nextstage='<input type="submit" name="finish" value="'.&mt('Finish').'" />'; |
} elsif ($type eq 'point') { |
} elsif ($type eq 'point') { |
$heading='Click to select a Coordinate or click Finish to save current selection.'; |
$heading=&mt('Click to select a Coordinate or click Finish to save current selection'); |
$nextstage='<input type="submit" name="finish" value="Finish" />'; |
$nextstage='<input type="submit" name="finish" value="'.&mt('Finish').'" />'; |
} |
} |
|
|
my $start_page = |
my $start_page = |
Line 142 sub getcoord {
|
Line 143 sub getcoord {
|
|
|
my $end_page = |
my $end_page = |
&Apache::loncommon::end_page(); |
&Apache::loncommon::end_page(); |
|
my $canceltext=&mt('Cancel'); |
$r->print(<<"END"); |
$r->print(<<"END"); |
$start_page |
$start_page |
<h3>$heading</h3> |
<h3>$heading</h3> |
<form method="POST" action="/adm/imagechoice?token=$id"> |
<form method="POST" action="/adm/imagechoice?token=$id"> |
$nextstage |
$nextstage |
<input type="submit" name="cancel" value="Cancel" /> |
<input type="submit" name="cancel" value="$canceltext" /> |
<br /> |
<br /> |
<input name="image" type="image" src="$filename" /> |
<input name="image" type="image" src="$filename" /> |
</form> |
</form> |
Line 249 sub handler {
|
Line 251 sub handler {
|
my (undef,$id) = split(/=/,$ENV{'QUERY_STRING'}); |
my (undef,$id) = split(/=/,$ENV{'QUERY_STRING'}); |
my $filename = &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 &mt('Cancel')) { |
&deletedata($id); |
&deletedata($id); |
&closewindow($r,'',$filename); |
&closewindow($r,'',$filename); |
return OK; |
return OK; |
Line 258 sub handler {
|
Line 260 sub handler {
|
if (defined($env{'form.type'})) { $type=$env{'form.type'}; } |
if (defined($env{'form.type'})) { $type=$env{'form.type'}; } |
my $numcoords=&savecoord($id,$type); |
my $numcoords=&savecoord($id,$type); |
my $imurl=&drawimage($r,$type,$filename,$id); |
my $imurl=&drawimage($r,$type,$filename,$id); |
if (($env{'form.finish'} eq 'Finish')) { |
if ($env{'form.finish'} eq &mt('Finish')) { |
&storedata($r,$type,$imurl,$id); |
&storedata($r,$type,$imurl,$id); |
} else { |
} else { |
&getcoord($r,$type,$imurl,$id); |
&getcoord($r,$type,$imurl,$id); |