blib/lib/Embperl/Form/Control/displaylink.pm untested

filter: Statementstmt 0.0% 0 / 62 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 98 CC 1 SCAR 6.9
CC
1
Cov
0%
show_control_readonly
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
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::displaylink ;
20  
21 use strict ;
22 use base 'Embperl::Form::Control' ;
23  
24 use Embperl::Inline ;
25  
26 # ---------------------------------------------------------------------------
27 #
28 # show_control_readonly - output readonly control
29 #
30  
31 sub show_control_readonly
32 {
33 my ($self, $req) = @_ ;
34  
35 $self -> show_control ($req) ;
36 }
37  
38 1 ;
39  
40 __EMBPERL__
41
42 [# ---------------------------------------------------------------------------
43 #
44 # show_control - output the control
45 #]
46  
47 [$ sub show_control ($self, $req)
48  
49 my $name = $self->{name};
50 my $hrefs = $self -> {href} ;
51 my $targets = $self -> {target} ;
52 my $opens = $self -> {open} ;
53 my $displays = $self -> {link} || $self -> {value} ;
54 my $form = $self -> form ;
55 my $showoptions = $self -> {showoptions} ;
56 my $state = $self -> {state} ;
57  
58 $hrefs = [$hrefs] if (!ref $hrefs) ;
59 $targets = [$targets] if ($targets && !ref $targets) ;
60 $opens = [$opens] if ($opens && !ref $opens) ;
61 $displays = [$displays] if (!ref $displays) ;
62  
63  
64 @hrefs = map { my $x = $_ ; $x =~ s/%%%name%%%/$epreq->Escape ($fdat{$name},6)/eg ; $x =~ s/%%(.+?)%%/$epreq->Escape ($fdat{$1}, 6)/eg ; $x } ref ($hrefs)?@$hrefs:($hrefs) ;
65 @opens = map { my $x = $_ ; $x =~ s/%%%name%%%/$epreq->Escape ($fdat{$name},6)/eg ; $x =~ s/%%(.+?)%%/$epreq->Escape ($fdat{$1}, 6)/eg ; $x } ref ($opens)?@$opens:($opens) ;
66 @displays = map { my $x = $_ ; $x =~ s/%%%name%%%/$fdat{$name}/g ; $x =~ s/%%(.+?)%%/$fdat{$1}/eg ; $x } @$displays ;
67  
68 my $dispn = 0 ;
69 $]
70 <div [+ do { local $escmode = 0 ; $self -> get_std_control_attr($req, '', 'readonly') } +]>
71 [$ foreach $display (@displays) $]
72 [$if $opens[$dispn] $]
73 <a href="#" class="[+ $state +]" onclick="if (this.className.search('ef-disabled') == -1) [+ $opens[$dispn] +][$if $hrefs[$dispn] $]('[+ $hrefs[$dispn] +]')[$endif$]" [+ do { local $escmode = 0 ; $self -> {eventattrs} } +]>
74 [$else$]
75 <a href="[+ do {local $escmode=0;$hrefs[$dispn]} +]" class="[+ $state +]"
76 [$if $targets -> [$dispn] $]target="[+ $targets -> [$dispn] +]"[$endif$]
77 [+ do { local $escmode = 0 ; $self -> {eventattrs} } +]>
78 [$endif$][$ if $showoptions < 0 $][+ do { local $escmode = 0 ; $display } +][$else$][+ $showoptions?$display:$form -> convert_text ($self, $display, undef, $req) +][$endif$]</a>&nbsp;
79 [- $dispn++ -]
80 [$endforeach$]
81 </div>
82 __END__