CGI-Portable
view release on metacpan or search on metacpan
lib/DemoRedirect.pm view on Meta::CPAN
package DemoRedirect;
require 5.004;
# Copyright (c) 1999-2004, Darren R. Duncan. All rights reserved. This module
# is free software; you can redistribute it and/or modify it under the same terms
# as Perl itself. However, I do request that this copyright information and
# credits remain attached to the file. If you modify this module and
# redistribute a changed version then please attach a note listing the
# modifications. This module is available "as-is" and the author can not be held
# accountable for any problems resulting from its use.
use strict;
use warnings;
use vars qw($VERSION @ISA);
$VERSION = '0.50';
######################################################################
=head1 DEPENDENCIES
=head2 Perl Version
5.004
=head2 Standard Modules
I<none>
=head2 Nonstandard Modules
CGI::Portable 0.50
CGI::Portable::AppStatic 0.50
=cut
######################################################################
use CGI::Portable 0.50;
use CGI::Portable::AppStatic 0.50;
@ISA = qw(CGI::Portable::AppStatic);
######################################################################
=head1 SYNOPSIS
=head2 Redirect To A Custom Url In User Query Parameter 'url'
#!/usr/bin/perl
use strict;
use warnings;
require CGI::Portable;
my $globals = CGI::Portable->new();
require CGI::Portable::AdapterCGI;
my $io = CGI::Portable::AdapterCGI->new();
$io->fetch_user_input( $globals );
my %CONFIG = ();
$globals->set_prefs( \%CONFIG );
$globals->call_component( 'DemoRedirect' );
$io->send_user_output( $globals );
1;
=head1 DESCRIPTION
This Perl 5 object class is part of a demonstration of CGI::Portable in use.
It is one of a set of "application components" that takes its settings and user
input through CGI::Portable and uses that class to send its user output.
This demo module set can be used together to implement a web site complete with
static html pages, e-mail forms, guest books, segmented text document display,
usage tracking, and url-forwarding. Of course, true to the intent of
CGI::Portable, each of the modules in this demo set can be used independantly
of the others.
=head1 SYNTAX
This class does not export any functions or methods, so you need to call them
using object notation. This means using B<Class-E<gt>function()> for functions
and B<$object-E<gt>method()> for methods. If you are inheriting this class for
your own modules, then that often means something like B<$self-E<gt>method()>.
=head1 PUBLIC FUNCTIONS AND METHODS
=head2 main( GLOBALS )
You invoke this method to run the application component that is encapsulated by
this class. The required argument GLOBALS is an CGI::Portable object that
you have previously configured to hold the instance settings and user input for
this class. When this method returns then the encapsulated application will
have finished and you can get its user output from the CGI::Portable object.
=head1 PREFERENCES HANDLED BY THIS MODULE
I<There are no preferences. Just set the query parameter named "url" to the
destination that you want the script to forward you to. However, this module
does subclass CGI::Portable::AppStatic, so you can optionally set the
high_http_status_code and high_http_window_target preferences that it handles.>
=cut
######################################################################
# Names of properties for objects of parent class are declared here:
my $KEY_SITE_GLOBALS = 'site_globals'; # hold global site values
# Constant values used by this class:
my $UIPN_DEST_URL = 'url'; # look in the user query for destination
######################################################################
sub main {
my ($class, $globals) = @_;
my $self = bless( {}, ref($class) || $class );
UNIVERSAL::isa( $globals, 'CGI::Portable' ) or
die "initializer is not a valid CGI::Portable object";
( run in 0.725 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )