Quiq/Html/Widget/ReadOnly.pm

filter: Statementstmt 96.9% 32 / 33 Branchbran 75.0% 9 / 12 Conditioncond 66.6% 4 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 87.1% 54 / 62 CC 9 SCAR 18.6
CC
9
Cov
88%
html
9.4
BEGIN
1.0
BEGIN
1.0
CRAP 6.4
« Quiq/Array.pm ↑ Summary Quiq/Progress.pm »
1 # -----------------------------------------------------------------------------
2  
3 =encoding utf8
4  
5 =head1 NAME
6  
7 Quiq::Html::Widget::ReadOnly - Nicht-änderbarer Text
8  
9 =head1 BASE CLASS
10  
11 L<Quiq::Html::Widget>
12  
13 =head1 ATTRIBUTES
14  
15 =over 4
16  
17 =item id => $id (Default: undef)
18  
19 CSS Id.
20  
21 =item class => $class (Default: undef)
22  
23 CSS Klasse.
24  
25 =item style => $style (Default: undef)
26  
27 CSS Definition (inline).
28  
29 =item disabled => $bool (Default: 0)
30  
31 Widget-Wert wird nicht kommuniziert.
32  
33 =item hidden => $bool (Default: 0)
34  
35 Widget ist (aktuell) unsichtbar.
36  
37 =item name => $name (Default: undef)
38  
39 Name des Hidden-Felds.
40  
41 =item text => $str (Default: undef)
42  
43 Text, der angezeigt wird. Ist dieses Attribut nicht gesetzt,
44 wird der Wert des Attributs value angezeigt.
45  
46 =item undefIf => $bool (Default: 0)
47  
48 Wenn wahr, liefere C<undef> als Widget-Code.
49  
50 =item value => $str (Default: undef)
51  
52 Wert (vom Anwender nicht änderbar).
53  
54 =back
55  
56 =cut
57  
58 # -----------------------------------------------------------------------------
59  
60 package Quiq::Html::Widget::ReadOnly;
61 1 ▶use base qw/Quiq::Html::Widget/;
Subroutine BEGIN: called CC=1 SCAR=0.0
62  
63 1 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
64 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
65 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
66  
67 1 our $VERSION = '1.240';
68  
69 # -----------------------------------------------------------------------------
70  
71 =head1 METHODS
72  
73 =head2 Konstruktor
74  
75 =head3 new() - Konstruktor
76  
77 =head4 Synopsis
78  
79 $e = $class->new(@keyVal);
80  
81 =cut
82  
83 # -----------------------------------------------------------------------------
84  
85 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
86 3 my $class = shift;
87 # @_: @keyVal
88  
89 # Defaultwerte
90  
91 3 my $self = $class->SUPER::new(
92 class => undef,
93 disabled => 0,
94 hidden => 0,
95 id => undef,
96 name => undef,
97 style => undef,
98 text => undef,
99 undefIf => 0,
100 value => undef,
101 );
102  
103 # Werte Konstruktoraufruf
104 3 $self->set(@_);
105  
106 3 return $self;
107 }
108  
109 # -----------------------------------------------------------------------------
110  
111 =head2 Objektmethoden
112  
113 =head3 html() - Generiere HTML-Code
114  
115 =head4 Synopsis
116  
117 $html = $e->html($h);
118 $html = $class->html($h,@keyVal);
119  
120 =cut
121  
122 # -----------------------------------------------------------------------------
123  
124 3 ▶sub html {
Subroutine html: called CC=9 SCAR=22.5
Pod documented
125 3 my $this = shift;
126 3 my $h = shift;
127  
128 3 ▶ my $self = ref $this? $this: $this->new(@_);
Branch: 1 branch
BranchTrueFalseTotal
ref $this ? : 0 3 3
129  
130 # Attribute
131  
132 3 my ($class,$disabled,$id,$name,$style,$text,$undefIf,$value) =
133 $self->get(qw/class disabled id name style text undefIf value/);
134  
135 3 ▶ if (!defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $value) 1 2 3
136 1 $value = '';
137 }
138 3 ▶ if (!defined $text) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $text) 3 0 3
139 3 $text = $value;
140 }
141  
142 # Generierung
143  
144 3 ▶ if ($undefIf) {
Branch: 1 branch
BranchTrueFalseTotal
if ($undefIf) 0 3 3
145 0 return undef;
146 }
147  
148 3 ▶ return '' if !$name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 1 2 3
149  
150 2 my $str = $h->tag('input',
151 -nl => 0,
152 type => 'hidden',
153 name => $name,
154 disabled => $disabled,
155 value => $value,
156 );
157 2 $str .= $text;
158  
159 # Wenn CSS-Attribut(e) angegeben sind, in <span> einfassen
160  
161 2 ▶ if ($id || $class || $style) {
Branch: 1 branch
BranchTrueFalseTotal
if ($id or $class or $style) 1 1 2
Condition66%4/6
$id or $class or $style
l!l&&r!l&&!r
101
$id or $class
l!l&&r!l&&!r
101
MC/DC33%1/3
$id or $class or $style
$id $class $style
Truth table50%2/4
A or B or C
A= $idB= $classC= $style
ABCresult
1XX1
01X1
0011
0000
162 1 $str = $h->tag('span',
163 id => $id,
164 class => $class,
165 style => $style,
166 '-',
167 $str
168 );
169 }
170  
171 2 return "$str\n";
172 }
173  
174 # -----------------------------------------------------------------------------
175  
176 =head1 VERSION
177  
178 1.240
179  
180 =head1 AUTHOR
181  
182 Frank Seitz, L<http://fseitz.de/>
183  
184 =head1 COPYRIGHT
185  
186 Copyright (C) 2026 Frank Seitz
187  
188 =head1 LICENSE
189  
190 This code is free software; you can redistribute it and/or modify
191 it under the same terms as Perl itself.
192  
193 =cut
194  
195 # -----------------------------------------------------------------------------
196  
197 1 1;
198  
199 # eof
« Quiq/Array.pm ↑ Summary Quiq/Progress.pm »