| 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::show ; |
| 19 |
|
| 20 |
use strict ; |
| 21 |
use base 'Embperl::Form::Control' ; |
| 22 |
|
| 23 |
use Embperl::Inline ; |
| 24 |
|
| 25 |
1 ; |
| 26 |
|
| 27 |
__EMBPERL__ |
| 28 |
|
| 29 |
[# --------------------------------------------------------------------------- |
| 30 |
# |
| 31 |
# show_control - output the control |
| 32 |
#] |
| 33 |
|
| 34 |
[$ sub show_control ($self, $req, $value) |
| 35 |
|
| 36 |
my $name = $self->{name}; |
| 37 |
my $value = exists $self->{value} ? $self->{value} : $fdat{$name}; |
| 38 |
|
| 39 |
$value = int($value) if ($self -> {int}) ; |
| 40 |
$value = $value?1:0 if ($self -> {bool}) ; |
| 41 |
|
| 42 |
my $options = $value ; |
| 43 |
$options = [ split /\t/, $value ] if $self->{split}; |
| 44 |
$options = [ split /\n/, $value ] if $self->{splitlines}; |
| 45 |
$options = [$options] if (!ref $options) ; |
| 46 |
|
| 47 |
$options = $self -> form -> convert_options ($self, $options, $options, $req) |
| 48 |
if (ref $options eq 'ARRAY' && !$self -> {showoptions}) ; |
| 49 |
|
| 50 |
$][$ if ref $options eq 'ARRAY' $][- $n = @$options -][$ foreach $v (@$options) $][+ $v +][$ if $n-- > 1 $]<br />[$endif$][$ endforeach |
| 51 |
$][$ elsif ref $value eq 'HASH' $][$ foreach $k (keys %$value) $][+ $k +]: [+ $value->{$k} +]<br />[$ endforeach |
| 52 |
$][$ elsif ref $value $]<em>[+ ref $value +]</em>[$ |
| 53 |
else $][+ $value +][$ endif $] |
| 54 |
|
| 55 |
[$ if $self->{hidden} $] |
| 56 |
<input type="hidden" name="[+ $name +]" value="[+ $value +]"> |
| 57 |
[$endif$] |
| 58 |
[$endsub$] |
| 59 |
|
| 60 |
__END__ |
| 61 |
|
| 62 |
=pod |
| 63 |
|
| 64 |
=head1 NAME |
| 65 |
|
| 66 |
Embperl::Form::Control::show - A text display control inside an Embperl Form |
| 67 |
|
| 68 |
|
| 69 |
=head1 SYNOPSIS |
| 70 |
|
| 71 |
{ |
| 72 |
type => 'display', |
| 73 |
text => 'blabla', |
| 74 |
hidden => 1, |
| 75 |
name => 'foo', |
| 76 |
split => 1 |
| 77 |
} |
| 78 |
|
| 79 |
=head1 DESCRIPTION |
| 80 |
|
| 81 |
Used to create a display only control inside an Embperl Form. |
| 82 |
See Embperl::Form on how to specify parameters. |
| 83 |
|
| 84 |
=head2 PARAMETER |
| 85 |
|
| 86 |
=head3 type |
| 87 |
|
| 88 |
Needs to be set to 'show'. |
| 89 |
|
| 90 |
=head3 text |
| 91 |
|
| 92 |
Will be used as label for the text display control. |
| 93 |
|
| 94 |
=head3 value |
| 95 |
|
| 96 |
value to display. If not given $fdat{<name>} will be used. |
| 97 |
If the data given within value is an arrayref, every element will be displayed |
| 98 |
on a separate line. |
| 99 |
|
| 100 |
=head3 hidden |
| 101 |
|
| 102 |
If set, an appropriate hidden input field will be created |
| 103 |
automatically. |
| 104 |
|
| 105 |
=head3 name |
| 106 |
|
| 107 |
Will be used as name for the hidden input field. |
| 108 |
|
| 109 |
=head3 split |
| 110 |
|
| 111 |
Splits the value into an array at \t if set and displays every array element |
| 112 |
on a new line. |
| 113 |
|
| 114 |
=head3 splitlines |
| 115 |
|
| 116 |
Splits the value into an array at \n if set and displays every array element |
| 117 |
on a new line. |
| 118 |
|
| 119 |
=head1 Author |
| 120 |
|
| 121 |
G. Richter (richter at embperl dot org), A. Beckert ([email protected]) |
| 122 |
|
| 123 |
=head1 See Also |
| 124 |
|
| 125 |
perl(1), Embperl, Embperl::Form |
| 126 |
|
| 127 |
|