1package HTML::FillInForm::Lite::Compat; 2 3use strict; 4use warnings; 5 6our $VERSION = '1.13'; 7 8use HTML::FillInForm::Lite; 9our @ISA = qw(HTML::FillInForm::Lite); 10 11$INC{'HTML/FillInForm.pm'} ||= __FILE__; 12push @HTML::FillInForm::ISA, __PACKAGE__ 13 unless HTML::FillInForm->isa(__PACKAGE__); 14 15my %known_keys = ( 16 scalarref => 1, 17 arrayref => 1, 18 fdat => 1, 19 fobject => 1, 20 file => 1, 21 target => 1, 22 fill_password => 1, 23 ignore_fields => 1, 24 disable_fields => 1, 25); 26 27my %extended_keys = ( 28 escape => 1, 29 decode_entity => 1, 30 layer => 1, 31); 32 33@known_keys{keys %extended_keys} = (); 34 35BEGIN{ 36 *fill_file = \&fill; 37 *fill_arrayref = \&fill; 38 *fill_scalarref = \&fill; 39} 40 41sub new{ 42 my $class = shift; 43 44 if(@_){ 45 warnings::warnif(portable => 46 qq{$class->new() accepts no options, } 47 . q{use HTML::FillInForm::Lite->new(...) instead}); 48 } 49 50 return $class->SUPER::new(); 51} 52 53sub fill{ 54 my $self = shift; 55 56 my $source; 57 my $data; 58 59 if (defined $_[0] and not exists $known_keys{ $_[0] }){ 60 $source = shift; 61 } 62 63 if (defined $_[0] and not exists $known_keys{ $_[0] }){ 64 $data = shift; 65 } 66 67 my %option = @_; 68 69 foreach my $key(keys %option){ 70 if(exists $extended_keys{$key}){ 71 warnings::warnif(portable => qq{HTML::FillInForm::Lite-specific option "$key" supplied}); 72 } 73 } 74 75 $source ||= $option{file} || $option{scalarref} || $option{arrayref}; 76 $data ||= $option{fdat} || $option{fobject}; 77 78 # ensure to delete all sources and data 79 delete @option{qw(scalarref arrayref file fdat fobject)}; 80 81 $option{fill_password} = 1 82 unless defined $option{fill_password}; 83 $option{decode_entity} = 1 84 unless defined $option{decode_entity}; 85 86 $option{ignore_fields} = [ $option{ignore_fields} ] 87 if defined $option{ignore_fields} 88 and ref $option{ignore_fields} ne 'ARRAY'; 89 90 return $self->SUPER::fill($source, $data, %option); 91} 92 931; 94 95__END__ 96 97=encoding UTF-8 98 99=head1 NAME 100 101HTML::FillInForm::Lite::Compat - HTML::FillInForm compatibility layer 102 103=head1 SYNOPSIS 104 105 use HTML::FillInForm::Lite::Compat; 106 107 use HTML::FillInForm; # doesn't require HTML::FillInForm 108 109 my $fif = HTML::FillInForm->new(); 110 $fif->isa('HTML::FillInForm::Lite'); # => yes 111 112 # or 113 114 perl -MHTML::FillInForm::Lite::Compat script_using_fillinform.pl 115 116=head1 DESCRIPTION 117 118This module provides an interface compatible with C<HTML::FillInForm>. 119 120It B<takes over> the C<use HTML::FillInForm> directive to use 121C<HTML::FillInForm::Lite> instead, so that scripts and modules 122that depend on C<HTML::FillInForm> go without it. 123 124=head1 METHODS 125 126The following is compatible with those of C<HTML::FillInForm>. 127 128=over 4 129 130=item new() 131 132It accepts no options as C<HTML::FillInForm> does. 133 134=item fill(...) 135 136=item fill_file(file, ...) 137 138=item fill_scalarref(scalarref, ...) 139 140=item fill_arrayref(arrayref, ...) 141 142=back 143 144=head1 SEE ALSO 145 146L<HTML::FillInForm>. 147 148L<HTML::FillInForm::Lite>. 149 150=head1 AUTHOR 151 152Goro Fuji (藤 吾郎) E<lt>gfuji(at)cpan.orgE<gt> 153 154=head1 LICENSE AND COPYRIGHT 155 156Copyright (c) 2008-2010 Goro Fuji, Some rights reserved. 157 158This program is free software; you can redistribute it and/or modify it 159under the same terms as Perl itself. 160 161=cut 162