« lib/HTML/FormFu/Role/Element/ProcessOptionsFromModel.pm
↑ Summary
lib/HTML/FormFu/Element/Checkbox.pm »
| 1 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | |||||||||||
| 3 | package HTML::FormFu::QueryType::Catalyst; | ||||||||||
| 4 | 1 | $HTML::FormFu::QueryType::Catalyst::VERSION = '2.09'; | |||||||||
| 5 | # ABSTRACT: uploaded file | ||||||||||
| 6 | |||||||||||
| 7 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use MooseX::Attribute::Chained; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | extends 'HTML::FormFu::Upload'; | |||||||||
| 11 | |||||||||||
| 12 | 1 | ▶ | use IO::File (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use Scalar::Util qw( weaken ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 1 | has basename => ( is => 'rw', traits => ['Chained'] ); | |||||||||
| 16 | 1 | has tempname => ( is => 'rw', traits => ['Chained'] ); | |||||||||
| 17 | |||||||||||
| 18 | 0 | ▶ | sub parse_uploads { | ||||||||
|
Subroutine
parse_uploads: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||
| 19 | 0 | my ( $class, $form, $name ) = @_; | |||||||||
| 20 | |||||||||||
| 21 | 0 | my @params = $form->query->param($name); | |||||||||
| 22 | 0 | my @uploads = $form->query->upload($name); | |||||||||
| 23 | 0 | my @new; | |||||||||
| 24 | |||||||||||
| 25 | # if all params aren't files, | ||||||||||
| 26 | # the files will be at the end of @params | ||||||||||
| 27 | 0 | my $non_file_count = scalar @params - scalar @uploads; | |||||||||
| 28 | |||||||||||
| 29 | 0 | ▶ | if ( $non_file_count > 0 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 0 | splice @params, $non_file_count; | |||||||||
| 31 | |||||||||||
| 32 | 0 | push @new, @params; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 0 | for my $upload (@uploads) { | |||||||||
| 36 | 0 | my $param = $class->new( | |||||||||
| 37 | { parent => $form, | ||||||||||
| 38 | basename => $upload->basename, | ||||||||||
| 39 | headers => $upload->headers, | ||||||||||
| 40 | filename => $upload->filename, | ||||||||||
| 41 | tempname => $upload->tempname, | ||||||||||
| 42 | size => $upload->size, | ||||||||||
| 43 | type => $upload->type | ||||||||||
| 44 | } ); | ||||||||||
| 45 | |||||||||||
| 46 | 0 | push @new, $param; | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 0 | ▶ | return if !@new; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | |||||||||||
| 51 | 0 | ▶ | return @new == 1 ? $new[0] : \@new; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | # copied from Catalyst 5.7x series - before it was Moosified | ||||||||||
| 55 | 0 | ▶ | sub fh { | ||||||||
|
Subroutine
fh: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 56 | 0 | my $self = shift; | |||||||||
| 57 | |||||||||||
| 58 | 0 | my $fh = IO::File->new( $self->tempname, IO::File::O_RDONLY ); | |||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | unless ( defined $fh ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | |||||||||||
| 62 | 0 | my $filename = $self->tempname; | |||||||||
| 63 | |||||||||||
| 64 | 0 | Catalyst::Exception->throw( | |||||||||
| 65 | message => qq/Can't open '$filename': '$!'/ ); | ||||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 0 | return $fh; | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 72 | |||||||||||
| 73 | 1 | 1; | |||||||||
| 74 | |||||||||||
| 75 | __END__ | ||||||||||