| 1 |
|
| 2 |
################################################################################### |
| 3 |
# |
| 4 |
# Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh www.ecos.de |
| 5 |
# Embperl - Copyright (c) 2008-2014 Gerald Richter |
| 6 |
# |
| 7 |
# You may distribute under the terms of either the GNU General Public |
| 8 |
# License or the Artistic License, as specified in the Perl README file. |
| 9 |
# |
| 10 |
# THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR |
| 11 |
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
| 12 |
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 13 |
# |
| 14 |
# $Id$ |
| 15 |
# |
| 16 |
################################################################################### |
| 17 |
|
| 18 |
package Embperl::Form::Control::password ; |
| 19 |
|
| 20 |
use strict ; |
| 21 |
use base 'Embperl::Form::Control' ; |
| 22 |
|
| 23 |
use vars qw{%fdat} ; |
| 24 |
|
| 25 |
use Embperl::Inline ; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
# ------------------------------------------------------------------------------------------ |
| 30 |
# |
| 31 |
# init_data - daten aufteilen |
| 32 |
# |
| 33 |
|
| 34 |
sub init_data |
| 35 |
{ |
| 36 |
my ($self, $req, $parentctrl) = @_ ; |
| 37 |
|
| 38 |
my $fdat = $req -> {docdata} || \%fdat ; |
| 39 |
my $name = $self->{name} ; |
| 40 |
|
| 41 |
$fdat->{$name} = $fdat->{$name}?'********':'' ; |
| 42 |
|
| 43 |
my $retype_name = $self->{retype_name} ; |
| 44 |
$fdat->{$retype_name} = $fdat->{$name} if ($retype_name) ; |
| 45 |
} |
| 46 |
|
| 47 |
# ------------------------------------------------------------------------------------------ |
| 48 |
# |
| 49 |
# prepare_fdat - daten zusammenfuehren |
| 50 |
# |
| 51 |
|
| 52 |
sub prepare_fdat |
| 53 |
{ |
| 54 |
my ($self, $req) = @_ ; |
| 55 |
|
| 56 |
my $fdat = $req -> {form} || \%fdat ; |
| 57 |
my $name = $self->{name} ; |
| 58 |
|
| 59 |
delete $fdat -> {$name} if ($fdat -> {$name} eq '********') ; |
| 60 |
} |
| 61 |
|
| 62 |
# --------------------------------------------------------------------------- |
| 63 |
# |
| 64 |
# get_validate_auto_rules - get rules for validation, in case user did |
| 65 |
# not specify any |
| 66 |
# |
| 67 |
|
| 68 |
sub get_validate_auto_rules |
| 69 |
{ |
| 70 |
my ($self, $req) = @_ ; |
| 71 |
|
| 72 |
return [ ($self -> {required}?(required => 1):(emptyok => 1)), length_min => 4 ] if (!$self->{retype_name}) ; |
| 73 |
return [ "same", $self->{retype_name}, ($self -> {required}?(required => 1):(emptyok => 1)), length_min => 4 ] ; |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
1 ; |
| 78 |
|
| 79 |
__EMBPERL__ |
| 80 |
|
| 81 |
[# --------------------------------------------------------------------------- |
| 82 |
# |
| 83 |
# show_control - output the control |
| 84 |
#] |
| 85 |
|
| 86 |
[$ sub show_control ($self, $req) $] |
| 87 |
|
| 88 |
<input type="password" name="[+ $self -> {force_name} || $self -> {name} +]" [+ do { local $escmode = 0 ; $self -> get_std_control_attr($req) } +] |
| 89 |
[$if $self -> {size} $]size="[+ $self->{size} +]"[$endif$] |
| 90 |
[$if $self -> {maxlength} $]size="[+ $self->{maxlength} +]"[$endif$] |
| 91 |
> |
| 92 |
[$endsub$] |
| 93 |
|
| 94 |
|
| 95 |
[# --------------------------------------------------------------------------- |
| 96 |
# |
| 97 |
# show_control_readonly - output the control as readonly |
| 98 |
#] |
| 99 |
|
| 100 |
[$ sub show_control_readonly ($self) $][$ if ($fdat{$self->{name}}) $]********[$endif$][$endsub$] |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
__END__ |
| 105 |
|
| 106 |
=pod |
| 107 |
|
| 108 |
=head1 NAME |
| 109 |
|
| 110 |
Embperl::Form::Control::password - A password input control inside an Embperl Form |
| 111 |
|
| 112 |
|
| 113 |
=head1 SYNOPSIS |
| 114 |
|
| 115 |
{ |
| 116 |
type => 'password', |
| 117 |
text => 'blabla', |
| 118 |
name => 'foo', |
| 119 |
size => 10, |
| 120 |
} |
| 121 |
|
| 122 |
=head1 DESCRIPTION |
| 123 |
|
| 124 |
Used to create a password control inside an Embperl Form. |
| 125 |
See Embperl::Form on how to specify parameters. |
| 126 |
|
| 127 |
=head2 PARAMETER |
| 128 |
|
| 129 |
=head3 type |
| 130 |
|
| 131 |
Needs to be 'password' |
| 132 |
|
| 133 |
=head3 name |
| 134 |
|
| 135 |
Specifies the name of the control |
| 136 |
|
| 137 |
=head3 text |
| 138 |
|
| 139 |
Will be used as label for the text input control |
| 140 |
|
| 141 |
=head3 size |
| 142 |
|
| 143 |
Gives the size in characters |
| 144 |
|
| 145 |
=head3 retype_name |
| 146 |
|
| 147 |
Name of control that is used to repeat the password. |
| 148 |
An automatic validation rule will be generated, to make |
| 149 |
sure both inputs are equal. |
| 150 |
|
| 151 |
|
| 152 |
=head3 maxlength |
| 153 |
|
| 154 |
Gives the maximun length in characters |
| 155 |
|
| 156 |
=head1 Author |
| 157 |
|
| 158 |
G. Richter (richter at embperl dot org) |
| 159 |
|
| 160 |
=head1 See Also |
| 161 |
|
| 162 |
perl(1), Embperl, Embperl::Form |
| 163 |
|
| 164 |
|