| OpenPlugin documentation | Contained in the OpenPlugin distribution. |
OpenPlugin::Param - Retrieve GET/POST/other values sent by client with a request
$OP = OpenPlugin->new();
@params = $OP->param->get_incoming();
$param = $OP->param->get_incoming('param');
The Param plugin offers an interface to retrieve parameters sent from the browser to the server.
get_incoming( [ $fieldname ] )
get( [ $fieldname ] )
Called with no parameters, get_incoming() returns a list containing the
names of each parameter sent to the server.
Called with one parameter, get_incoming returns value(s) for $fieldname.
Call in list context to return multiple values for $fieldname.
set_incoming( $fieldname = $value )>
Set the value of an incoming parameter. This is typically called internally when the server receives parameters by the browser. However, sometimes developers find it useful to be able to modify this value, perhaps in order to do sanity checking on the information sent from the user.
The $value parameter can be a reference to a hash, if there are multiple
values for a particular field.
None known.
See the TO DO section of the <OpenPlugin::Request> plugin.
See the individual driver documentation for settings and parameters specific to that driver.
Copyright (c) 2001-2003 Eric Andreychek. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Eric Andreychek <eric@openthought.net>
| OpenPlugin documentation | Contained in the OpenPlugin distribution. |
package OpenPlugin::Param; # $Id: Param.pm,v 1.16 2003/04/03 01:51:24 andreychek Exp $ use strict; use base qw( OpenPlugin::Plugin ); $OpenPlugin::Param::VERSION = sprintf("%d.%02d", q$Revision: 1.16 $ =~ /(\d+)\.(\d+)/); sub OP { return $_[0]->{_m}{OP} } sub type { return 'param' } *get = \*get_incoming; # Retrieve GET/POST parameters sub get_incoming { my ( $self, $name ) = @_; # Just return a list of available parameters unless ( $name ) { return ( ref $self->state->{param} eq 'HASH' ) ? keys %{ $self->state->{param} } : (); } # This parameter has a list of values if ( ref $self->state->{param}{ $name } eq 'ARRAY' and wantarray ) { return @{ $self->state->{param}{ $name } }; } # Return a single parameter return $self->state->{param}{ $name }; } sub set_incoming { my ( $self, @args ) = @_; return undef unless ( $args[0] ); if( ref $args[0] eq 'HASH' ) { foreach my $arg ( keys %{ $args[0] } ) { $self->state->{ param }{ $arg } = $args[0]->{ $arg }; } } else { $self->state->{ param }{ $args[0] } = $args[1]; } } 1; __END__