CGI-FormMagick
view release on metacpan or search on metacpan
lib/CGI/FormMagick.pm view on Meta::CPAN
Defaults to "file". "string" is also available, in which case you must
specify a source which is either a literal string or a scalar variable.
=item source
Defaults to a filename matching that of your script, only with an
extension of .xml (we got this idea from XML::Simple).
=item charset
Tell FormMagick that the XML input uses the specified character set encoding.
Defaults to 'none' which is good enough for English text and US ASCII. Any
other characters may cause parse errors. Valid charsets are "ISO-8859-1",
"UTF-8", "UTF-16", or "US-ASCII". This option is case sensitive.
=back
=begin testing
BEGIN: {
use_ok('CGI::FormMagick');
use vars qw($fm);
use lib "lib/";
}
ok(CGI::FormMagick->can('new'), "We can call new");
ok($fm = CGI::FormMagick->new(type => 'file', source => "t/simple.xml"), "create fm object");
ok($fm2 = CGI::FormMagick->new(type => 'string', source => '<form></form>',
charset => 'US-ASCII'), 'We can pass charset');
isa_ok($fm, 'CGI::FormMagick');
isa_ok($fm2, 'CGI::FormMagick');
$fm->parse_xml();
=end testing
=cut
sub new {
my $self = shift;
my $class = ref($self) || $self;
$self = bless {}, $class;
my %args = @_;
$self->{debug} = $args{DEBUG} || 0;
# $self->{inputtype} = uc($args{type}) || "file";
$self->{inputtype} = $args{type} || "file";
$self->{source} = $args{source};
$self->{charset} = $args{charset} || undef;
foreach (qw(PREVIOUSBUTTON RESETBUTTON STARTOVERLINK NEXTBUTTON)) {
if (exists $args{$_}) {
warn("$_ as arg to new() is deprecated -- use accessor method instead\n");
$self->{lc($_)} = $args{$_};
} else {
$self->{lc($_)} = 1;
}
}
#$self->{sessiondir} = initialise_sessiondir($args{SESSIONDIR});
$self->{calling_package} = (caller)[0];
$self->{fallback_language} = undef;
return $self;
}
=pod
=head2 previousbutton()
With no arguments, tells you whether the previousbutton will be
displayed or not. If you give it a true argument (eg 1) it will set the
previous button to be displayed. A false value (eg 0) will set it to
not be displayed.
=head2 nextbutton()
As for previousbutton, but affects the "Next" button.
=head2 finishbutton()
Ditto.
=head2 resetbutton()
Ditto.
=head2 startoverlink()
Ditto.
=head2 debug()
Turns debugging on/off.
=begin testing
is($fm->previousbutton, 1, "Previous button set on to begin with");
$fm->previousbutton(0);
is($fm->previousbutton, 0, "Previous button turned off");
$fm->previousbutton(1);
is($fm->previousbutton, 1, "Previous button turned on again");
$fm->previousbutton("");
is($fm->previousbutton, 0, "Previous button turned off with empty string");
$fm->previousbutton("a");
is($fm->previousbutton, 1, "Previous button turned on with true string");
is($fm->debug, 0, "Debug set off to begin with");
$fm->debug(1);
is($fm->debug, 1, "Debug turned on");
$fm->debug(0);
=end testing
=cut
sub AUTOLOAD {
my ($self, $onoff) = @_;
my ($called_sub_name) = ($AUTOLOAD =~ m/([^:]*)$/);
$called_sub_name = lc($called_sub_name);
my @flags = qw(
( run in 1.502 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )