| 1 | |||
| 2 | ################################################################################### | ||
| 3 | # | ||
| 4 | # Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh www.ecos.de | ||
| 5 | # Embperl - Copyright (c) 2008-2015 Gerald Richter | ||
| 6 | # Embperl - Copyright (c) 2015-2023 actevy.io | ||
| 7 | # | ||
| 8 | # You may distribute under the terms of either the GNU General Public | ||
| 9 | # License or the Artistic License, as specified in the Perl README file. | ||
| 10 | # | ||
| 11 | # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR | ||
| 12 | # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | ||
| 13 | # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
| 14 | # | ||
| 15 | # $Id$ | ||
| 16 | # | ||
| 17 | ################################################################################### | ||
| 18 | |||
| 19 | package Embperl::Form::Control::password ; | ||
| 20 | |||
| 21 | use strict ; | ||
| 22 | use base 'Embperl::Form::Control' ; | ||
| 23 | |||
| 24 | use vars qw{%fdat} ; | ||
| 25 | |||
| 26 | use Embperl::Inline ; | ||
| 27 | |||
| 28 | |||
| 29 | |||
| 30 | # ------------------------------------------------------------------------------------------ | ||
| 31 | # | ||
| 32 | # init_data - daten aufteilen | ||
| 33 | # | ||
| 34 | |||
| 35 | sub init_data | ||
| 36 | { | ||
| 37 | my ($self, $req, $parentctrl) = @_ ; | ||
| 38 | |||
| 39 | my $fdat = $req -> {docdata} || \%fdat ; | ||
| 40 | my $name = $self->{name} ; | ||
| 41 | |||
| 42 | $fdat->{$name} = $fdat->{$name}?'********':'' ; | ||
| 43 | |||
| 44 | my $retype_name = $self->{retype_name} ; | ||
| 45 | $fdat->{$retype_name} = $fdat->{$name} if ($retype_name) ; | ||
| 46 | } | ||
| 47 | |||
| 48 | # ------------------------------------------------------------------------------------------ | ||
| 49 | # | ||
| 50 | # prepare_fdat - daten zusammenfuehren | ||
| 51 | # | ||
| 52 | |||
| 53 | sub prepare_fdat | ||
| 54 | { | ||
| 55 | my ($self, $req) = @_ ; | ||
| 56 | |||
| 57 | my $fdat = $req -> {form} || \%fdat ; | ||
| 58 | my $name = $self->{name} ; | ||
| 59 | return if (!exists $fdat->{$name}) ; | ||
| 60 | |||
| 61 | delete $fdat -> {$name} if ($fdat -> {$name} eq '********') ; | ||
| 62 | } | ||
| 63 | |||
| 64 | # --------------------------------------------------------------------------- | ||
| 65 | # | ||
| 66 | # get_validate_auto_rules - get rules for validation, in case user did | ||
| 67 | # not specify any | ||
| 68 | # | ||
| 69 | |||
| 70 | sub get_validate_auto_rules | ||
| 71 | { | ||
| 72 | my ($self, $req) = @_ ; | ||
| 73 | |||
| 74 | return [ ($self -> {required}?(required => 1):(emptyok => 1)), length_min => 4 ] if (!$self->{retype_name}) ; | ||
| 75 | |||
| 76 | $req ||= $Embperl::req ; | ||
| 77 | my $text = $self -> form -> convert_label ($self, $self->{retype_name}, undef, $req) ; | ||
| 78 | return [ -frontend_only, "same", $self->{retype_name} . ':' . $text, ($self -> {required}?(required => 1):(emptyok => 1)), length_min => 4 ] ; | ||
| 79 | } | ||
| 80 | |||
| 81 | |||
| 82 | 1 ; | ||
| 83 | |||
| 84 | __EMBPERL__ | ||
| 85 | |||
| 86 | [# --------------------------------------------------------------------------- | ||
| 87 | # | ||
| 88 | # show_control - output the control | ||
| 89 | #] | ||
| 90 | |||
| 91 | [$ sub show_control ($self, $req) $] | ||
| 92 | |||
| 93 | <input type="password" name="[+ $self -> {force_name} || $self -> {name} +]" [+ do { local $escmode = 0 ; $self -> get_std_control_attr($req) } +] | ||
| 94 | [$if $self -> {size} $]size="[+ $self->{size} +]"[$endif$] | ||
| 95 | [$if $self -> {maxlength} $]size="[+ $self->{maxlength} +]"[$endif$] | ||
| 96 | > | ||
| 97 | [$endsub$] | ||
| 98 | |||
| 99 | |||
| 100 | [# --------------------------------------------------------------------------- | ||
| 101 | # | ||
| 102 | # show_control_readonly - output the control as readonly | ||
| 103 | #] | ||
| 104 | |||
| 105 | [$ sub show_control_readonly ($self) $][$ if ($fdat{$self->{name}}) $]********[$endif$][$endsub$] | ||
| 106 | |||
| 107 | |||
| 108 | |||
| 109 | __END__ |