ActivePerl Documentation
|
NAMECGI::Imagemap.pm - imagemap behavior for CGI programs
SUPPORTED PLATFORMS
SYNOPSISuse CGI::Imagemap; $map = new CGI::Imagemap; $map->setmap(@map); $action = $map->action($x,$y); -- or -- use CGI::Imagemap 'action_map'; $action = action_map($x,$y,@map);
DESCRIPTIONCGI::Imagemap allows CGI programmers to place TYPE=IMAGE form fields on their HTML fill-out forms, with either client-side or server-side maps emulated. The imagemap file follows that of the NCSA imagemap program. Each point is an x,y tuple. Each line in the map consists of one of the following formats. Comment lines start with ``#''. circle action center edgepoint rect action upperleft lowerright point action point poly action point1 point2 ... pointN default action Using ``point'' and ``default'' in the same map makes no sense. If ``point'' is used, the action for the closest one is selected. To use CGI::Imagemap, define an image submit map on your form with something like:
<input type=image name=mv_todo
SRC="image_url">
You can pass a ``client-side'' imagemap like this:
<input type="hidden" name="todo.map"
value="rect action1 0,0 25,20">
<input type="hidden" name="todo.map"
value="rect action2 26,0 50,20">
<input type="hidden" name="todo.map"
value="rect action3 51,0 75,20">
<input type="hidden" name="todo.map"
value="default action0">
If the @map passed parameter contains a NUL (\0) in the first array position, the map is assumed to be null-separated and @map is built by splitting it. This allows a null-separated todo.map with multiple values (parsed by a cgi-lib.pl or the like) to be referenced. All of the following examples assume the above definitions in your form.
Static MethodsCGI::Imagemap allows the export of two routines, action_map and map_untaint. If you choose to use CGI::Imagemap statically, call the module with: use CGI::Imagemap qw(action_map map_untaint);
Class MethodsThe class methods for CGI::Imagemap are much the same as above, with the exception that multiple imagemaps are then maintained by the module, with full independence. The following method definitions assume the CGI::Form module is being used, like this:
use CGI::Form;
use CGI::Imagemap;
$query = new CGI::Form;
$map = new CGI::Imagemap;
EXAMPLEA couple of self-contained examples are included in the CGI::Imagemap package. They are: testmap - Uses the CGI::Form module testmap.old - Uses the old cgi-lib.pl
BUGSThe untainting stuff is not totally independent -- threading might not work very well. This can be fixed if it is important -- in the CGI world, I doubt it.
AUTHORMike Heins, Internet Robotics, <mikeh@iac.net>
CREDITSThis work is heavily kited from the Perl imagemap program originally written by V. Khera <khera@kciLink.com>.
|