OnSearch::CGIQuery - CGI library for OnSearch.


onsearch documentation Contained in the onsearch distribution.

Index


Code Index:

NAME

Top

OnSearch::CGIQuery - CGI library for OnSearch.

SYNOPSIS

Top

    my $q = OnSearch::CGIQuery -> new;
    $q -> parse_query ();
    $q -> param_value ($param_name);

DESCRIPTION

Top

OnSearch::CGIQuery provides methods to parse CGI queries and return parameter values.

METHODS

Top

new ();

This is the OnSearch::CGIQuery object constructor.

$q -> DESTROY;

The OnSearch::CGIQuery destructor, also called by Perl to delete unused objects.

$q -> parsequery ();

Parse a CGI query.

$q -> param_value (param);

Return the value of CGI parameter param.

SEE ALSO

Top

OnSearch(3)


onsearch documentation Contained in the onsearch distribution.
package OnSearch::CGIQuery; 

#$Id: CGIQuery.pm,v 1.5 2005/07/28 07:02:23 kiesling Exp $

use strict;
use warnings;
use Carp;

my $VERSION='$Revision: 1.5 $';

require Exporter;
require DynaLoader;
our (@ISA, @EXPORT_OK, %EXPORT_TAGS);
@ISA = qw(Exporter DynaLoader);
@EXPORT_OK = (qw/new parsequery param_value DESTROY/);
%EXPORT_TAGS = ( 'all' => [@EXPORT_OK] );

sub new {
    my $proto = shift;
    my $class = ref ( $proto ) || $proto;
    my $obj = {
	pwd => '',                    # Directory of calling script.
	displayregex => undef,        # Regex used for highlighting in results.
	regex => undef,               # Regex used for multi-word searches.
        context => undef,             # How much context to show on each match.
	cache => undef,               # Web site cache directory.
	ppid => undef,                # ID of parent script process.
	sid  => undef,                # ID of search process.
    };
    bless ($obj, $class);
    return $obj;
}

sub DESTROY {
    my ($self) = @_;
    undef %{$self};
}

sub parsequery {
    my $q = shift;
    my ($param, $arg);
    my ($scriptname, $request) = split /\?/, $ENV{REQUEST_URI}, 2;
    return unless $request;
    my @params = split /\&/, $request;
    foreach my $p (@params) {
	($param, $arg) = split /\=/, $p;
	$q -> {$param} = OnSearch::Utils::http_unescape ($arg);
    }
}

sub param_value {
    my $q = shift;
    my $param = $_[0];
    return $q -> {$param};
}

1;

__END__