| 1 | 10 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | |||||||||||
| 3 | package HTML::FormFu::QueryType::CGI; | ||||||||||
| 4 | 10 | $HTML::FormFu::QueryType::CGI::VERSION = '2.09'; | |||||||||
| 5 | # ABSTRACT: uploaded file | ||||||||||
| 6 | |||||||||||
| 7 | 10 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 10 | extends 'HTML::FormFu::Upload'; | |||||||||
| 10 | |||||||||||
| 11 | 10 | ▶ | use HTTP::Headers; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 10 | ▶ | use Scalar::Util qw( blessed ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 21 | ▶ | sub parse_uploads { | ||||||||
|
Subroutine
parse_uploads: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||
| 15 | 21 | my ( $class, $form, $name ) = @_; | |||||||||
| 16 | |||||||||||
| 17 | 21 | my $query = $form->query; | |||||||||
| 18 | ## CGI wants you to use $query->multi_param($foo). | ||||||||||
| 19 | ## doing so breaks CGI::Simple. So shoosh it up for now. | ||||||||||
| 20 | 21 | local $CGI::LIST_CONTEXT_WARN = 0; | |||||||||
| 21 | |||||||||||
| 22 | 21 | my @params = $query->param($name); | |||||||||
| 23 | 21 | my @new; | |||||||||
| 24 | |||||||||||
| 25 | 21 | for my $param (@params) { | |||||||||
| 26 | 26 | ▶ | if ( blessed $param ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 18 | my $filename = $param; | |||||||||
| 28 | |||||||||||
| 29 | 18 | $param = $class->new( | |||||||||
| 30 | { _param => $param, | ||||||||||
| 31 | filename => sprintf( "%s", $filename ), | ||||||||||
| 32 | parent => $form, | ||||||||||
| 33 | |||||||||||
| 34 | # TODO: for now, parent points to the form | ||||||||||
| 35 | # pointing to a field will require handling multiple | ||||||||||
| 36 | # fields of the same name | ||||||||||
| 37 | # if fixed, other QueryTypes and MultiForm will need updating | ||||||||||
| 38 | } ); | ||||||||||
| 39 | |||||||||||
| 40 | my $headers | ||||||||||
| 41 | 18 | = HTTP::Headers->new( %{ $query->uploadInfo($filename) } ); | |||||||||
| 42 | |||||||||||
| 43 | 18 | $param->headers($headers); | |||||||||
| 44 | 18 | $param->size( $headers->content_length ); | |||||||||
| 45 | 18 | $param->type( $headers->content_type ); | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 26 | push @new, $param; | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 21 | ▶ | return if !@new; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | |||||||||||
| 53 | 21 | ▶ | return @new == 1 ? $new[0] : \@new; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 5 | ▶ | sub fh { | ||||||||
|
Subroutine
fh: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 57 | 5 | my ($self) = @_; | |||||||||
| 58 | |||||||||||
| 59 | 5 | return $self->_param; | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 10 | __PACKAGE__->meta->make_immutable; | |||||||||
| 63 | |||||||||||
| 64 | 10 | 1; | |||||||||
| 65 | |||||||||||
| 66 | __END__ | ||||||||||