| 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::show ; | ||
| 20 | |||
| 21 | use strict ; | ||
| 22 | use base 'Embperl::Form::Control' ; | ||
| 23 | |||
| 24 | use Embperl::Inline ; | ||
| 25 | |||
| 26 | 1 ; | ||
| 27 | |||
| 28 | __EMBPERL__ | ||
| 29 | |||
| 30 | [# --------------------------------------------------------------------------- | ||
| 31 | # | ||
| 32 | # show_control - output the control | ||
| 33 | #] | ||
| 34 | |||
| 35 | [$ sub show_control ($self, $req, $value) | ||
| 36 | |||
| 37 | my $name = $self->{name}; | ||
| 38 | my $value = exists $self->{value} ? $self->{value} : $fdat{$name}; | ||
| 39 | |||
| 40 | $value = int($value) if ($self -> {int}) ; | ||
| 41 | $value = $value?1:0 if ($self -> {bool}) ; | ||
| 42 | |||
| 43 | my $options = $value ; | ||
| 44 | $options = [ split /\t/, $value ] if $self->{split}; | ||
| 45 | $options = [ split /\n/, $value ] if $self->{splitlines}; | ||
| 46 | $options = [$options] if (!ref $options) ; | ||
| 47 | |||
| 48 | $options = $self -> form -> convert_options ($self, $options, $options, $req) | ||
| 49 | if (ref $options eq 'ARRAY' && !$self -> {showoptions}) ; | ||
| 50 | |||
| 51 | $][$ if ref $options eq 'ARRAY' $][- $n = @$options -][$ foreach $v (@$options) $][+ $v +][$ if $n-- > 1 $]<br />[$endif$][$ endforeach | ||
| 52 | $][$ elsif ref $value eq 'HASH' $][$ foreach $k (keys %$value) $][+ $k +]: [+ $value->{$k} +]<br />[$ endforeach | ||
| 53 | $][$ elsif ref $value $]<em>[+ ref $value +]</em>[$ | ||
| 54 | else $][+ $value +][$ endif $] | ||
| 55 | |||
| 56 | [$ if $self->{hidden} $] | ||
| 57 | <input type="hidden" name="[+ $name +]" value="[+ $value +]"> | ||
| 58 | [$endif$] | ||
| 59 | [$endsub$] | ||
| 60 | |||
| 61 | __END__ |