################################################################################### # # Embperl - Copyright (c) 1997-2010 Gerald Richter / ecos gmbh www.ecos.de # # You may distribute under the terms of either the GNU General Public # License or the Artistic License, as specified in the Perl README file. # # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # $Id$ # ################################################################################### package Embperl::Form::Control::radio ; use strict ; use vars qw{%fdat} ; use base 'Embperl::Form::ControlMultValue' ; use Embperl::Inline ; # --------------------------------------------------------------------------- # # show_control_readonly - output readonly control # sub show_control_readonly { my ($self, $req) = @_ ; my ($values, $options) = $self -> get_values ; my $name = $self -> {name} ; my $addtop = $self -> {addtop} || [] ; my $addbottom= $self -> {addbottom} || [] ; my $set = !defined ($fdat{$name})?1:0 ; my $filter = $self -> {filter} ; my $val ; my $i = 0 ; if ($set) { foreach $val ((@$addtop, @$values, @$addbottom)) { if (!defined ($filter) || (ref $val?$val -> [0]:$val =~ /$filter/i)) { $fdat{$name} = ref $val?$val -> [0]:$val ; last ; } } } $self -> show_control ($req, "^\Q$fdat{$name}\E\$", $values, $options) ; } # --------------------------------------------------------------------------- sub show_control_addons { my ($self, $req) = @_ ; } 1 ; __EMBPERL__ [# --------------------------------------------------------------------------- # # show_control - output the control #] [$ sub show_control ($self, $req, $filter, $values, $options) ($values, $options) = $self -> get_values ($req) if (!$values) ; my $name = $self -> {name} ; $filter ||= $self -> {filter} ; my $addtop = $self -> {addtop} || [] ; my $addbottom= $self -> {addbottom} || [] ; my $ignorecase= $self -> {ignorecase} ; my $max = @$values ; my $set = !defined ($fdat{$name})?1:0 ; my $nsprefix = $self -> form -> {jsnamespace} ; my $val ; my $i = 0 ; if ($self -> {vert}) { $tr = '
| [+ $val ->[1] || $val -> [0] +] | [+ do { local $escmode = 0 ; $trend }+] [$endif$] [$endforeach$] [$ foreach $val (@$values) $][- $x = ($val =~ /$filter/i) -] [$if !defined ($filter) || ($val =~ /$filter/i) $] [- $fdat{$name} = $val, $set = 0 if ($set) ; $fdat{$name} = $val if ($ignorecase && lc($fdat{$name}) eq lc($val)) ; -] [+ do { local $escmode = 0 ; $tr }+]{sublines} || $self -> {subobjects}) $] OnClick="[+ $nsprefix +]show_radio_checked(document, this,[+ $i +],[+ $max +])" [$endif$] > | [+ $options ->[$i] || $val +] | [+ do { local $escmode = 0 ; $trend }+] [$endif$] [* $i++ ; *] [$endforeach$] [$ foreach $val (@$addbottom) $] [$if !defined ($filter) || ($val->[0] =~ /$filter/i) $] [- $fdat{$name} = $val -> [0], $set = 0 if ($set) ; -] [+ do { local $escmode = 0 ; $tr }+][+ $val ->[1] || $val -> [0] +] | [+ do { local $escmode = 0 ; $trend }+] [$endif$] [$endforeach$] [+ do { local $escmode = 0 ; $trendglob }+]