| 1 | # ----------------------------------------------------------------------------- | ||||||||||||||
| 2 | |||||||||||||||
| 3 | =encoding utf8 | ||||||||||||||
| 4 | |||||||||||||||
| 5 | =head1 NAME | ||||||||||||||
| 6 | |||||||||||||||
| 7 | Quiq::Html::Widget::FileUpload - Datei Upload Feld | ||||||||||||||
| 8 | |||||||||||||||
| 9 | =head1 BASE CLASS | ||||||||||||||
| 10 | |||||||||||||||
| 11 | L<Quiq::Html::Widget> | ||||||||||||||
| 12 | |||||||||||||||
| 13 | =head1 ATTRIBUTES | ||||||||||||||
| 14 | |||||||||||||||
| 15 | =over 4 | ||||||||||||||
| 16 | |||||||||||||||
| 17 | =item accept => $mimeType (Default: undef) | ||||||||||||||
| 18 | |||||||||||||||
| 19 | MIME-Type (oder mit Komma getrennte Liste von MIME-Types) der | ||||||||||||||
| 20 | Dateien für den Datei-Upload. | ||||||||||||||
| 21 | |||||||||||||||
| 22 | =item class => $class (Default: undef) | ||||||||||||||
| 23 | |||||||||||||||
| 24 | CSS Klasse des des Feldes. | ||||||||||||||
| 25 | |||||||||||||||
| 26 | =item disabled => $bool (Default: 0) | ||||||||||||||
| 27 | |||||||||||||||
| 28 | Feld erlaubt keine Eingabe. | ||||||||||||||
| 29 | |||||||||||||||
| 30 | =item hidden => $bool (Default: 0) | ||||||||||||||
| 31 | |||||||||||||||
| 32 | Widget ist (aktuell) unsichtbar. | ||||||||||||||
| 33 | |||||||||||||||
| 34 | =item id => $id (Default: undef) | ||||||||||||||
| 35 | |||||||||||||||
| 36 | Id des Feldes. | ||||||||||||||
| 37 | |||||||||||||||
| 38 | =item maxLength => $n (Default: Wert von "size") | ||||||||||||||
| 39 | |||||||||||||||
| 40 | Maximale Länge des Eingabewerts in Zeichen. Ein Wert von "0" beutet | ||||||||||||||
| 41 | keine Eingabebegrenzung. | ||||||||||||||
| 42 | |||||||||||||||
| 43 | =item size => $n (Default: undef) | ||||||||||||||
| 44 | |||||||||||||||
| 45 | Breite des Feldes in Zeichen. | ||||||||||||||
| 46 | |||||||||||||||
| 47 | =item name => $name (Default: undef) | ||||||||||||||
| 48 | |||||||||||||||
| 49 | Name des Feldes. | ||||||||||||||
| 50 | |||||||||||||||
| 51 | =item style => $style (Default: undef) | ||||||||||||||
| 52 | |||||||||||||||
| 53 | CSS Definition (inline). | ||||||||||||||
| 54 | |||||||||||||||
| 55 | =item undefIf => $bool (Default: 0) | ||||||||||||||
| 56 | |||||||||||||||
| 57 | Wenn wahr, liefere C<undef> als Widget-Code. | ||||||||||||||
| 58 | |||||||||||||||
| 59 | =back | ||||||||||||||
| 60 | |||||||||||||||
| 61 | =cut | ||||||||||||||
| 62 | |||||||||||||||
| 63 | # ----------------------------------------------------------------------------- | ||||||||||||||
| 64 | |||||||||||||||
| 65 | package Quiq::Html::Widget::FileUpload; | ||||||||||||||
| 66 | 1 | ▶ | use base qw/Quiq::Html::Widget/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 67 | |||||||||||||||
| 68 | 1 | ▶ | use v5.10; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 69 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 70 | 1 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 71 | |||||||||||||||
| 72 | 1 | our $VERSION = '1.240'; | |||||||||||||
| 73 | |||||||||||||||
| 74 | # ----------------------------------------------------------------------------- | ||||||||||||||
| 75 | |||||||||||||||
| 76 | =head1 METHODS | ||||||||||||||
| 77 | |||||||||||||||
| 78 | =head2 Konstruktor | ||||||||||||||
| 79 | |||||||||||||||
| 80 | =head3 new() - Konstruktor | ||||||||||||||
| 81 | |||||||||||||||
| 82 | =head4 Synopsis | ||||||||||||||
| 83 | |||||||||||||||
| 84 | $e = $class->new(@keyVal); | ||||||||||||||
| 85 | |||||||||||||||
| 86 | =cut | ||||||||||||||
| 87 | |||||||||||||||
| 88 | # ----------------------------------------------------------------------------- | ||||||||||||||
| 89 | |||||||||||||||
| 90 | 3 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 91 | 3 | my $class = shift; | |||||||||||||
| 92 | # @_: @keyVal | ||||||||||||||
| 93 | |||||||||||||||
| 94 | 3 | my $self = $class->SUPER::new( | |||||||||||||
| 95 | accept => undef, | ||||||||||||||
| 96 | class => undef, | ||||||||||||||
| 97 | disabled => 0, | ||||||||||||||
| 98 | hidden => 0, | ||||||||||||||
| 99 | id => undef, | ||||||||||||||
| 100 | maxLength => undef, | ||||||||||||||
| 101 | name => undef, | ||||||||||||||
| 102 | size => undef, | ||||||||||||||
| 103 | style => undef, | ||||||||||||||
| 104 | undefIf => 0, | ||||||||||||||
| 105 | value => undef, | ||||||||||||||
| 106 | ); | ||||||||||||||
| 107 | 3 | $self->set(@_); | |||||||||||||
| 108 | |||||||||||||||
| 109 | 3 | return $self; | |||||||||||||
| 110 | } | ||||||||||||||
| 111 | |||||||||||||||
| 112 | # ----------------------------------------------------------------------------- | ||||||||||||||
| 113 | |||||||||||||||
| 114 | =head2 Objektmethoden | ||||||||||||||
| 115 | |||||||||||||||
| 116 | =head3 html() - Generiere HTML-Code | ||||||||||||||
| 117 | |||||||||||||||
| 118 | =head4 Synopsis | ||||||||||||||
| 119 | |||||||||||||||
| 120 | $html = $e->html($h); | ||||||||||||||
| 121 | $html = $class->html($h,@keyVal); | ||||||||||||||
| 122 | |||||||||||||||
| 123 | =cut | ||||||||||||||
| 124 | |||||||||||||||
| 125 | # ----------------------------------------------------------------------------- | ||||||||||||||
| 126 | |||||||||||||||
| 127 | 3 | ▶ | sub html { | ||||||||||||
|
Subroutine
html: called CC=6 SCAR=19.1
Pod
documented
| |||||||||||||||
| 128 | 3 | my $this = shift; | |||||||||||||
| 129 | 3 | my $h = shift; | |||||||||||||
| 130 | # @_: @keyVal | ||||||||||||||
| 131 | |||||||||||||||
| 132 | 3 | ▶ | my $self = ref $this? $this: $this->new(@_); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 133 | |||||||||||||||
| 134 | # Attribute | ||||||||||||||
| 135 | |||||||||||||||
| 136 | 3 | my ($accept,$class,$disabled,$hidden,$id,$maxLength,$name,$size, | |||||||||||||
| 137 | $style,$undefIf,$value) = $self->get(qw/accept class disabled hidden | ||||||||||||||
| 138 | id maxLength name size style undefIf value/); | ||||||||||||||
| 139 | |||||||||||||||
| 140 | 3 | ▶ | if (!defined $maxLength) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 141 | 2 | $maxLength = $size; | |||||||||||||
| 142 | } | ||||||||||||||
| 143 | elsif ($maxLength == 0) { | ||||||||||||||
| 144 | 1 | $maxLength = undef; | |||||||||||||
| 145 | } | ||||||||||||||
| 146 | |||||||||||||||
| 147 | # Generierung | ||||||||||||||
| 148 | |||||||||||||||
| 149 | 3 | ▶ | if ($undefIf) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 150 | 0 | return undef; | |||||||||||||
| 151 | } | ||||||||||||||
| 152 | |||||||||||||||
| 153 | 3 | ▶ | if ($hidden) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 154 | 0 | return ''; | |||||||||||||
| 155 | } | ||||||||||||||
| 156 | |||||||||||||||
| 157 | 3 | return $h->tag('input', | |||||||||||||
| 158 | type => 'file', | ||||||||||||||
| 159 | id => $id, | ||||||||||||||
| 160 | class => $class, | ||||||||||||||
| 161 | style => $style, | ||||||||||||||
| 162 | accept => $accept, | ||||||||||||||
| 163 | name => $name, | ||||||||||||||
| 164 | disabled => $disabled, | ||||||||||||||
| 165 | size => $size, | ||||||||||||||
| 166 | maxlength => $maxLength, | ||||||||||||||
| 167 | ); | ||||||||||||||
| 168 | } | ||||||||||||||
| 169 | |||||||||||||||
| 170 | # ----------------------------------------------------------------------------- | ||||||||||||||
| 171 | |||||||||||||||
| 172 | =head1 VERSION | ||||||||||||||
| 173 | |||||||||||||||
| 174 | 1.240 | ||||||||||||||
| 175 | |||||||||||||||
| 176 | =head1 AUTHOR | ||||||||||||||
| 177 | |||||||||||||||
| 178 | Frank Seitz, L<http://fseitz.de/> | ||||||||||||||
| 179 | |||||||||||||||
| 180 | =head1 COPYRIGHT | ||||||||||||||
| 181 | |||||||||||||||
| 182 | Copyright (C) 2026 Frank Seitz | ||||||||||||||
| 183 | |||||||||||||||
| 184 | =head1 LICENSE | ||||||||||||||
| 185 | |||||||||||||||
| 186 | This code is free software; you can redistribute it and/or modify | ||||||||||||||
| 187 | it under the same terms as Perl itself. | ||||||||||||||
| 188 | |||||||||||||||
| 189 | =cut | ||||||||||||||
| 190 | |||||||||||||||
| 191 | # ----------------------------------------------------------------------------- | ||||||||||||||
| 192 | |||||||||||||||
| 193 | 1 | 1; | |||||||||||||
| 194 | |||||||||||||||
| 195 | # eof | ||||||||||||||