| 1 | package Rose::HTML::Form::Field::Group; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 13 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | 13 | ▶ | use Carp(); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | # XXX: Can't use Scalar::Defer 0.11 (or possibly later) until some things | ||||||||||||||||||||||||||||||||
| 8 | # XXX: are sorted out. See: http://rt.cpan.org/Ticket/Display.html?id=31039 | ||||||||||||||||||||||||||||||||
| 9 | # XXX: Scalar::Defer 0.18 seems to work again. Yay! | ||||||||||||||||||||||||||||||||
| 10 | # XXX: ...but this whole approach is a bt too clever. | ||||||||||||||||||||||||||||||||
| 11 | #use Scalar::Defer(); | ||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 13 | ▶ | use Scalar::Util(); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | 13 | ▶ | use Rose::HTML::Util(); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | 13 | ▶ | use base 'Rose::HTML::Form::Field'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | 13 | our $VERSION = '0.606'; | |||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | 13 | our $Debug = undef; | |||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | use Rose::Object::MakeMethods::Generic | ||||||||||||||||||||||||||||||||
| 23 | 13 | ▶ | ( | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 24 | 13 | scalar => [ qw(rows columns) ], | |||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | 'scalar --get_set_init' => | ||||||||||||||||||||||||||||||||
| 27 | [ | ||||||||||||||||||||||||||||||||
| 28 | qw(html_linebreak xhtml_linebreak) | ||||||||||||||||||||||||||||||||
| 29 | ], | ||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | boolean => [ 'linebreak' => { default => 1 } ], | ||||||||||||||||||||||||||||||||
| 32 | 13 | ); | |||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | sub init | ||||||||||||||||||||||||||||||||
| 35 | 113 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 36 | 113 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 113 | $self->{'items'} = []; | |||||||||||||||||||||||||||||||
| 39 | 113 | $self->{'values'} = {}; | |||||||||||||||||||||||||||||||
| 40 | 113 | $self->{'labels'} = {}; | |||||||||||||||||||||||||||||||
| 41 | 113 | $self->{'defaults'} = {}; | |||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | 113 | $self->SUPER::init(@_); | |||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 13 | ▶ | use constant HTML_LINEBREAK => "<br>\n"; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 47 | 13 | ▶ | use constant XHTML_LINEBREAK => "<br />\n"; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | 8 | ▶ | sub init_html_linebreak { HTML_LINEBREAK } | ||||||||||||||||||||||||||||||
|
Subroutine
init_html_linebreak: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub init_xhtml_linebreak { XHTML_LINEBREAK } | ||||||||||||||||||||||||||||||
|
Subroutine
init_xhtml_linebreak: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub _item_class { '' } | ||||||||||||||||||||||||||||||
|
Subroutine
_item_class: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 53 | 153 | ▶ | sub _item_group_class { '' } | ||||||||||||||||||||||||||||||
|
Subroutine
_item_group_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub _item_name { 'item' } | ||||||||||||||||||||||||||||||
|
Subroutine
_item_name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub _item_name_plural { 'items' } | ||||||||||||||||||||||||||||||
|
Subroutine
_item_name_plural: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||
| 57 | sub children | ||||||||||||||||||||||||||||||||
| 58 | 8 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
children: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 59 | 8 | ▶ | Carp::croak "Cannot set children() for a pseudo-group ($_[0])" if(@_ > 1); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 60 | 8 | ▶ | return wantarray ? () : []; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | 1 | ▶ | sub is_flat_group { 1 } | ||||||||||||||||||||||||||||||
|
Subroutine
is_flat_group: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | sub items | ||||||||||||||||||||||||||||||||
| 66 | 2692 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
items: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 67 | 2692 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 2692 | ▶ | if(@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 70 | { | ||||||||||||||||||||||||||||||||
| 71 | 83 | $self->{'items'} = $self->_args_to_items({ localized => 0 }, @_); | |||||||||||||||||||||||||||||||
| 72 | 83 | $self->label_items; | |||||||||||||||||||||||||||||||
| 73 | 83 | $self->init_items; | |||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | 2692 | ▶ | return (wantarray) ? @{$self->{'items'} || []} : $self->{'items'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->{'items'} || []
MC/DC0%0/1
$self->{'items'} || []
$self->{'items'}
Truth table50%1/2
A
A= $self->{'items'}
| |||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | sub visible_items | ||||||||||||||||||||||||||||||||
| 80 | 219 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
visible_items: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 81 | 219 | ▶ | my $items = shift->items or return; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 82 | 219 | ▶ | return wantarray ? (grep { !$_->hidden } @$items) : [ grep { !$_->hidden } @$items ]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||
| 85 | sub show_all_items | ||||||||||||||||||||||||||||||||
| 86 | 4 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
show_all_items: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 87 | 4 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||
| 89 | 4 | foreach my $item ($self->items) | |||||||||||||||||||||||||||||||
| 90 | { | ||||||||||||||||||||||||||||||||
| 91 | 22 | $item->hidden(0); | |||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | sub hide_all_items | ||||||||||||||||||||||||||||||||
| 96 | 4 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
hide_all_items: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 97 | 4 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||
| 99 | 4 | foreach my $item ($self->items) | |||||||||||||||||||||||||||||||
| 100 | { | ||||||||||||||||||||||||||||||||
| 101 | 20 | $item->hidden(1); | |||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||
| 105 | sub delete_item | ||||||||||||||||||||||||||||||||
| 106 | 18 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
delete_item: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 107 | 18 | my($self, $value) = @_; | |||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | 18 | ▶ | my $delete_item = $self->item($value) or return; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 110 | 14 | my $group_class = $self->_item_group_class; | |||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||
| 112 | 14 | ▶ | my $items = $self->items || []; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->items || []
MC/DC0%0/1
$self->items || []
$self->items
Truth table50%1/2
A
A= $self->items
| |||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||
| 114 | 14 | my $i = 0; | |||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||
| 116 | 14 | foreach my $item (@$items) | |||||||||||||||||||||||||||||||
| 117 | { | ||||||||||||||||||||||||||||||||
| 118 | 47 | ▶ | if($item->isa($group_class)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 119 | { | ||||||||||||||||||||||||||||||||
| 120 | 2 | ▶ | if(my $deleted = $item->delete_item($value)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 121 | { | ||||||||||||||||||||||||||||||||
| 122 | 2 | return $deleted; | |||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||
| 126 | 45 | ▶ | last if($item eq $delete_item); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 127 | 33 | $i++; | |||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||
| 130 | 12 | return splice(@$items, $i, 1); | |||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | sub push_items { shift->add_items(@_) } | ||||||||||||||||||||||||||||||
|
Subroutine
push_items: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub push_item { shift->add_item(@_) } | ||||||||||||||||||||||||||||||
|
Subroutine
push_item: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | sub pop_items | ||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
pop_items: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 138 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | my $items = $self->items || []; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->items || []
MC/DC0%0/1
$self->items || []
$self->items
Truth table0%0/2
A
A= $self->items
| |||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if(@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||||||
| 144 | 0 | my $offset = $#$items - $_[0]; | |||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | return splice(@$items, $offset < 0 ? 0 : $offset) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||
| 148 | 0 | my @items = pop(@$items); | |||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | $self->init_items if(@items); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 150 | 0 | return @items; | |||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | sub pop_item { shift->pop_items(@_) } | ||||||||||||||||||||||||||||||
|
Subroutine
pop_item: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||
| 155 | sub shift_items | ||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
shift_items: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 157 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | my $items = $self->items || []; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->items || []
MC/DC0%0/1
$self->items || []
$self->items
Truth table0%0/2
A
A= $self->items
| |||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | my @items = @_ ? splice(@$items, 0, $_[0]) : shift(@$items); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | $self->init_items if(@items); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 163 | 0 | return @items; | |||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | sub shift_item { shift->shift_items(@_) } | ||||||||||||||||||||||||||||||
|
Subroutine
shift_item: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||
| 168 | sub unshift_items | ||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
unshift_items: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 170 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||
| 172 | 0 | unshift(@{$self->{'items'}}, $self->_args_to_items({ localized => 0 }, @_)); | |||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||
| 174 | 0 | $self->init_items; | |||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | sub unshift_item { shift->unshift_items(@_) } | ||||||||||||||||||||||||||||||
|
Subroutine
unshift_item: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||
| 179 | sub delete_items | ||||||||||||||||||||||||||||||||
| 180 | 4 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
delete_items: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 181 | 4 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||
| 183 | 4 | foreach my $arg (@_) | |||||||||||||||||||||||||||||||
| 184 | { | ||||||||||||||||||||||||||||||||
| 185 | 12 | $self->delete_item($arg); | |||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||
| 189 | sub delete_item_group | ||||||||||||||||||||||||||||||||
| 190 | 2 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
delete_item_group: called CC=8 SCAR=23.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 191 | 2 | my($self, $value) = @_; | |||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||
| 193 | 2 | my $group_class = $self->_item_group_class; | |||||||||||||||||||||||||||||||
| 194 | 2 | ▶ | my $delete_item = UNIVERSAL::isa($value, $group_class) ? $value : ($self->item_group($value) or return); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->item_group($value) or return
MC/DC0%0/1
$self->item_group($value) or return
$self->item_group($value)
Truth table50%1/2
A
A= $self->item_group($value)
| |||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||
| 196 | 2 | ▶ | my $items = $self->items || []; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->items || []
MC/DC0%0/1
$self->items || []
$self->items
Truth table50%1/2
A
A= $self->items
| |||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||
| 198 | 2 | my $i = 0; | |||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||
| 200 | 2 | foreach my $item (@$items) | |||||||||||||||||||||||||||||||
| 201 | { | ||||||||||||||||||||||||||||||||
| 202 | 4 | ▶ | last if($item eq $delete_item); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||
| 204 | 2 | ▶ | if($item->isa($group_class)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 205 | { | ||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if(my $deleted = $item->delete_item($value)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 207 | { | ||||||||||||||||||||||||||||||||
| 208 | 0 | return $deleted; | |||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||
| 212 | 2 | $i++; | |||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||
| 215 | 2 | return splice(@$items, $i, 1); | |||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||
| 218 | sub delete_item_groups | ||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
delete_item_groups: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 220 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||
| 222 | 0 | foreach my $arg (@_) | |||||||||||||||||||||||||||||||
| 223 | { | ||||||||||||||||||||||||||||||||
| 224 | 0 | $self->delete_item_group($arg); | |||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||
| 228 | sub items_localized | ||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
items_localized: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 230 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | if(@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 233 | { | ||||||||||||||||||||||||||||||||
| 234 | 0 | $self->{'items'} = $self->_args_to_items({ localized => 1 }, @_); | |||||||||||||||||||||||||||||||
| 235 | 0 | $self->init_items; | |||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | return (wantarray) ? @{$self->{'items'}} : $self->{'items'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||
| 241 | sub items_html_attr | ||||||||||||||||||||||||||||||||
| 242 | 16 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
items_html_attr: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 243 | 16 | my($self, $name) = (shift, shift); | |||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||
| 245 | 16 | ▶ | if(@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 246 | { | ||||||||||||||||||||||||||||||||
| 247 | 8 | foreach my $item ($self->items) | |||||||||||||||||||||||||||||||
| 248 | { | ||||||||||||||||||||||||||||||||
| 249 | 28 | $item->html_attr($name, @_); | |||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||
| 252 | 8 | return @_; | |||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||
| 255 | 8 | foreach my $item (@{[ $self->items ]}) | |||||||||||||||||||||||||||||||
| 256 | { | ||||||||||||||||||||||||||||||||
| 257 | 8 | return $item->html_attr($name); | |||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||
| 260 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||
| 263 | sub delete_items_html_attr | ||||||||||||||||||||||||||||||||
| 264 | 8 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
delete_items_html_attr: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 265 | 8 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||
| 267 | 8 | foreach my $item ($self->items) | |||||||||||||||||||||||||||||||
| 268 | { | ||||||||||||||||||||||||||||||||
| 269 | 28 | $item->delete_html_attr(@_); | |||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||
| 273 | 13 | *fields = \&items; | |||||||||||||||||||||||||||||||
| 274 | 13 | *fields_localized = \&items_localized; | |||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||
| 276 | 42 | ▶ | sub _html_item { $_[1]->html_field } | ||||||||||||||||||||||||||||||
|
Subroutine
_html_item: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 277 | 14 | ▶ | sub _xhtml_item { $_[1]->xhtml_field } | ||||||||||||||||||||||||||||||
|
Subroutine
_xhtml_item: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||
| 279 | sub _args_to_items | ||||||||||||||||||||||||||||||||
| 280 | 99 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
_args_to_items: called CC=20 SCAR=30.0
| |||||||||||||||||||||||||||||||||
| 281 | 99 | my($self, $options) = (shift, shift); | |||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||
| 283 | 99 | my(%labels, @choices, $items); | |||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||
| 285 | 99 | my $class = $self->_item_class; | |||||||||||||||||||||||||||||||
| 286 | 99 | my $group_class = $self->_item_group_class; | |||||||||||||||||||||||||||||||
| 287 | 99 | ▶ | my $label_method = $options->{'localized'} ? 'label_id' : 'label'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||
| 289 | 99 | ▶ | if(@_ == 1 && ref $_[0] eq 'HASH') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ == 1 and ref $_[0] eq "HASH"
MC/DC100%2/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1
ref $_[0] eq "HASH"
Truth table100%3/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||
| 290 | { | ||||||||||||||||||||||||||||||||
| 291 | 17 | %labels = %{$_[0]}; | |||||||||||||||||||||||||||||||
| 292 | 17 | @choices = sort keys %labels; | |||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||
| 294 | else | ||||||||||||||||||||||||||||||||
| 295 | { | ||||||||||||||||||||||||||||||||
| 296 | 82 | my $args; | |||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||
| 298 | # XXX: Hack to allow a reference to an array of plain scalars | ||||||||||||||||||||||||||||||||
| 299 | # XXX: to be taken as a list of values. | ||||||||||||||||||||||||||||||||
| 300 | 82 | ▶ | if(@_ == 1 && ref $_[0] eq 'ARRAY') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ == 1 and ref $_[0] eq "ARRAY"
MC/DC100%2/2
@_ == 1 and ref $_[0] eq "ARRAY"
@_ == 1
ref $_[0] eq "ARRAY"
Truth table100%3/3
A and B
A= @_ == 1B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||
| 301 | { | ||||||||||||||||||||||||||||||||
| 302 | 53 | $args = $_[0]; | |||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||
| 304 | 53 | ▶ | unless(grep { ref $_ } @$args) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 305 | { | ||||||||||||||||||||||||||||||||
| 306 | 44 | $args = [ map { $_ => $_ } @$args ]; | |||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||
| 309 | 29 | else { $args = \@_ } | |||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||
| 311 | 82 | ▶ | while(@$args) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 312 | { | ||||||||||||||||||||||||||||||||
| 313 | 215 | my $arg = shift(@$args); | |||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||
| 315 | 215 | ▶ | if(UNIVERSAL::isa($arg, $class) || UNIVERSAL::isa($arg, $group_class)) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
UNIVERSAL::isa($arg, $class) or UNIVERSAL::isa($arg, $group_class)
MC/DC100%2/2
UNIVERSAL::isa($arg, $class) or UNIVERSAL::isa($arg, $group_class)
UNIVERSAL::isa($arg, $class)
UNIVERSAL::isa($arg, $group_class)
Truth table100%3/3
A or B
A= UNIVERSAL::isa($arg, $class)B= UNIVERSAL::isa($arg, $group_class)
| |||||||||||||||||||||||||||||||||
| 316 | { | ||||||||||||||||||||||||||||||||
| 317 | 17 | push(@$items, $arg); | |||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||
| 319 | elsif(!ref $arg) | ||||||||||||||||||||||||||||||||
| 320 | { | ||||||||||||||||||||||||||||||||
| 321 | 198 | my $item = $class->new(value => $arg); | |||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||
| 323 | 198 | ▶ | if(!ref $args->[0]) | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 324 | { | ||||||||||||||||||||||||||||||||
| 325 | 181 | $item->$label_method(shift(@$args)); | |||||||||||||||||||||||||||||||
| 326 | 181 | push(@$items, $item); | |||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||
| 328 | elsif(ref $args->[0] eq 'HASH') | ||||||||||||||||||||||||||||||||
| 329 | { | ||||||||||||||||||||||||||||||||
| 330 | 14 | my $pairs = shift(@$args); | |||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||
| 332 | 14 | ▶ | while(my($method, $value) = each(%$pairs)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 333 | { | ||||||||||||||||||||||||||||||||
| 334 | 14 | $item->$method($value); | |||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||
| 337 | 14 | push(@$items, $item); | |||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||
| 339 | elsif(ref $args->[0] eq 'ARRAY') | ||||||||||||||||||||||||||||||||
| 340 | { | ||||||||||||||||||||||||||||||||
| 341 | 3 | my $group = $group_class->new(label => $arg, | |||||||||||||||||||||||||||||||
| 342 | items => shift @$args); | ||||||||||||||||||||||||||||||||
| 343 | 3 | push(@$items, $group); | |||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||
| 345 | else | ||||||||||||||||||||||||||||||||
| 346 | { | ||||||||||||||||||||||||||||||||
| 347 | 0 | Carp::croak "Illegal or incorrectly positioned ", $self->_item_name_plural, | |||||||||||||||||||||||||||||||
| 348 | " argument: $args->[0]"; | ||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||
| 352 | else | ||||||||||||||||||||||||||||||||
| 353 | { | ||||||||||||||||||||||||||||||||
| 354 | 0 | Carp::croak "Illegal or incorrectly positioned ", $self->_item_name_plural, | |||||||||||||||||||||||||||||||
| 355 | " argument: $args->[0]"; | ||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||
| 360 | 99 | ▶ | if(keys %labels) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 361 | { | ||||||||||||||||||||||||||||||||
| 362 | 17 | my @items; | |||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||
| 364 | 17 | my $class = $self->_item_class; | |||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||
| 366 | 17 | foreach my $value (@choices) | |||||||||||||||||||||||||||||||
| 367 | { | ||||||||||||||||||||||||||||||||
| 368 | push(@$items, $class->new(value => $value, | ||||||||||||||||||||||||||||||||
| 369 | 35 | $label_method => $labels{$value})); | |||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||
| 373 | 99 | foreach my $item (@$items) | |||||||||||||||||||||||||||||||
| 374 | { | ||||||||||||||||||||||||||||||||
| 375 | # Connect item to group | ||||||||||||||||||||||||||||||||
| 376 | 250 | ▶ | $item->parent_group($self) if($item->can('parent_group')); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||
| 378 | # XXX: This whole approach is a bit too clever and leak-prone. | ||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||
| 380 | # # Speculatively hook up localizer and locale | ||||||||||||||||||||||||||||||||
| 381 | # # XXX: Scalar::Defer 0.11 breaks this (http://rt.cpan.org/Ticket/Display.html?id=31039) | ||||||||||||||||||||||||||||||||
| 382 | # # XXX: Scalar::Defer 0.18 seems to work again. Yay! | ||||||||||||||||||||||||||||||||
| 383 | # Scalar::Util::weaken(my $welf = $self); | ||||||||||||||||||||||||||||||||
| 384 | # $item->localizer(Scalar::Defer::defer { $welf->localizer }); | ||||||||||||||||||||||||||||||||
| 385 | # #$item->localizer(sub { $welf->localizer }); | ||||||||||||||||||||||||||||||||
| 386 | # | ||||||||||||||||||||||||||||||||
| 387 | # # XXX: Use lame workaround instead. | ||||||||||||||||||||||||||||||||
| 388 | # #Scalar::Util::weaken(my $welf = $self); | ||||||||||||||||||||||||||||||||
| 389 | # #$item->localizer(sub { $welf->localizer }); | ||||||||||||||||||||||||||||||||
| 390 | # | ||||||||||||||||||||||||||||||||
| 391 | # if(my $parent = $self->parent_form) | ||||||||||||||||||||||||||||||||
| 392 | # { | ||||||||||||||||||||||||||||||||
| 393 | # # XXX: Scalar::Defer 0.11 breaks this (http://rt.cpan.org/Ticket/Display.html?id=31039) | ||||||||||||||||||||||||||||||||
| 394 | # # XXX: Scalar::Defer 0.18 seems to work again. Yay! | ||||||||||||||||||||||||||||||||
| 395 | # Scalar::Util::weaken(my $warent = $parent); | ||||||||||||||||||||||||||||||||
| 396 | # $item->locale(Scalar::Defer::defer { $warent->locale }); | ||||||||||||||||||||||||||||||||
| 397 | # # XXX: Use lame workaround instead. | ||||||||||||||||||||||||||||||||
| 398 | # #$item->locale(sub { $parent->locale }); | ||||||||||||||||||||||||||||||||
| 399 | # } | ||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||
| 402 | 99 | ▶ | return (wantarray) ? @$items : $items; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||
| 405 | sub parent_field | ||||||||||||||||||||||||||||||||
| 406 | 6149 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
parent_field: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 407 | 6149 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||
| 409 | 6149 | ▶ | if(@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 410 | { | ||||||||||||||||||||||||||||||||
| 411 | 21 | ▶ | if(my $parent = $self->SUPER::parent_field(@_)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 412 | { | ||||||||||||||||||||||||||||||||
| 413 | 21 | foreach my $item ($self->items) | |||||||||||||||||||||||||||||||
| 414 | { | ||||||||||||||||||||||||||||||||
| 415 | 63 | ▶ | $item->parent_field($parent) unless($item->parent_field); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||
| 420 | 6149 | return $self->SUPER::parent_field; | |||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||
| 423 | # XXX: This whole approach is a bit too clever and leak-prone. | ||||||||||||||||||||||||||||||||
| 424 | # sub parent_form | ||||||||||||||||||||||||||||||||
| 425 | # { | ||||||||||||||||||||||||||||||||
| 426 | # my($self) = shift; | ||||||||||||||||||||||||||||||||
| 427 | # | ||||||||||||||||||||||||||||||||
| 428 | # if(@_) | ||||||||||||||||||||||||||||||||
| 429 | # { | ||||||||||||||||||||||||||||||||
| 430 | # if(my $parent = $self->SUPER::parent_form(@_)) | ||||||||||||||||||||||||||||||||
| 431 | # { | ||||||||||||||||||||||||||||||||
| 432 | # foreach my $item ($self->items) | ||||||||||||||||||||||||||||||||
| 433 | # { | ||||||||||||||||||||||||||||||||
| 434 | # # XXX: Scalar::Defer 0.11 breaks this (http://rt.cpan.org/Ticket/Display.html?id=31039) | ||||||||||||||||||||||||||||||||
| 435 | # # XXX: Scalar::Defer 0.18 seems to work again. Yay! | ||||||||||||||||||||||||||||||||
| 436 | # Scalar::Util::weaken(my $warent = $parent); | ||||||||||||||||||||||||||||||||
| 437 | # $item->locale(Scalar::Defer::defer { $warent->locale }); | ||||||||||||||||||||||||||||||||
| 438 | # # XXX: Use lame workaround instead. | ||||||||||||||||||||||||||||||||
| 439 | # #$item->locale(sub { $parent->locale }); | ||||||||||||||||||||||||||||||||
| 440 | # } | ||||||||||||||||||||||||||||||||
| 441 | # } | ||||||||||||||||||||||||||||||||
| 442 | # } | ||||||||||||||||||||||||||||||||
| 443 | # | ||||||||||||||||||||||||||||||||
| 444 | # return $self->SUPER::parent_form; | ||||||||||||||||||||||||||||||||
| 445 | # } | ||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||
| 447 | sub add_items | ||||||||||||||||||||||||||||||||
| 448 | 16 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
add_items: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 449 | 16 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||
| 451 | 16 | push(@{$self->{'items'}}, $self->_args_to_items({ localized => 0 }, @_)); | |||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||
| 453 | 16 | $self->init_items; | |||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||
| 456 | 13 | *add_item = \&add_items; | |||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||
| 458 | sub add_items_localized | ||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
add_items_localized: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 460 | 0 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||
| 462 | 0 | push(@{$self->{'items'}}, $self->_args_to_items({ localized => 1 }, @_)); | |||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||
| 464 | 0 | $self->init_items; | |||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||
| 467 | 13 | *add_item_localized = \&add_items_localized; | |||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||
| 469 | sub label_items | ||||||||||||||||||||||||||||||||
| 470 | 92 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
label_items: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 471 | 92 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||
| 473 | 92 | ▶ | my $labels = $self->{'labels'} || {}; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'labels'} || {}
MC/DC0%0/1
$self->{'labels'} || {}
$self->{'labels'}
Truth table50%1/2
A
A= $self->{'labels'}
| |||||||||||||||||||||||||||||||||
| 474 | 92 | ▶ | my $label_ids = $self->{'label_ids'} || {}; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'label_ids'} || {}
MC/DC100%1/1
$self->{'label_ids'} || {}
$self->{'label_ids'}
Truth table100%2/2
A
A= $self->{'label_ids'}
| |||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||
| 476 | 92 | ▶ | return unless(%$labels || %$label_ids); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
%$labels or %$label_ids
MC/DC100%2/2
%$labels or %$label_ids
%$labels
%$label_ids
Truth table100%3/3
A or B
A= %$labelsB= %$label_ids
| |||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||
| 478 | 12 | foreach my $item ($self->items) | |||||||||||||||||||||||||||||||
| 479 | { | ||||||||||||||||||||||||||||||||
| 480 | 34 | my $value = $item->html_attr('value'); | |||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||
| 482 | 34 | ▶ | next unless(defined $value); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||
| 484 | 34 | ▶ | if(exists $label_ids->{$value}) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 485 | { | ||||||||||||||||||||||||||||||||
| 486 | 10 | $item->label_id($label_ids->{$value}); | |||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||
| 488 | elsif(exists $labels->{$value}) | ||||||||||||||||||||||||||||||||
| 489 | { | ||||||||||||||||||||||||||||||||
| 490 | 15 | $item->label($labels->{$value}); | |||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||
| 495 | sub clear | ||||||||||||||||||||||||||||||||
| 496 | 393 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
clear: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 497 | 393 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||
| 499 | 393 | $self->{'values'} = undef; | |||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||
| 501 | 393 | foreach my $item ($self->items) | |||||||||||||||||||||||||||||||
| 502 | { | ||||||||||||||||||||||||||||||||
| 503 | 1240 | local $item->{'auto_invalidate_parent'} = $self->auto_invalidate_parent; | |||||||||||||||||||||||||||||||
| 504 | 1240 | $item->clear; | |||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||
| 507 | 393 | $self->error(undef); | |||||||||||||||||||||||||||||||
| 508 | 393 | $self->has_partial_value(0); | |||||||||||||||||||||||||||||||
| 509 | 393 | $self->is_cleared(1); | |||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||
| 511 | 393 | $self->init_items; | |||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||
| 514 | sub clear_labels | ||||||||||||||||||||||||||||||||
| 515 | 1 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
clear_labels: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 516 | 1 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||
| 518 | 1 | delete $self->{'labels'}; | |||||||||||||||||||||||||||||||
| 519 | 1 | delete $self->{'label_ids'}; | |||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||
| 521 | 1 | foreach my $item ($self->items) | |||||||||||||||||||||||||||||||
| 522 | { | ||||||||||||||||||||||||||||||||
| 523 | 7 | $item->label_id(undef); | |||||||||||||||||||||||||||||||
| 524 | 7 | $item->label(''); | |||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||
| 527 | 1 | return; | |||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||
| 530 | sub reset_labels | ||||||||||||||||||||||||||||||||
| 531 | 1 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
reset_labels: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 532 | 1 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||
| 534 | 1 | delete $self->{'labels'}; | |||||||||||||||||||||||||||||||
| 535 | 1 | delete $self->{'label_ids'}; | |||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||
| 537 | 1 | foreach my $item ($self->items) | |||||||||||||||||||||||||||||||
| 538 | { | ||||||||||||||||||||||||||||||||
| 539 | 7 | $item->label_id(undef); | |||||||||||||||||||||||||||||||
| 540 | 7 | $item->label($item->value); | |||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||
| 543 | 1 | return; | |||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||
| 546 | sub reset | ||||||||||||||||||||||||||||||||
| 547 | 20 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
reset: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 548 | 20 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||
| 550 | 20 | $self->input_value(undef); | |||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||
| 552 | 20 | foreach my $item ($self->items) | |||||||||||||||||||||||||||||||
| 553 | { | ||||||||||||||||||||||||||||||||
| 554 | 88 | $item->reset; | |||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||
| 557 | 20 | $self->error(undef); | |||||||||||||||||||||||||||||||
| 558 | 20 | $self->has_partial_value(0); | |||||||||||||||||||||||||||||||
| 559 | 20 | $self->is_cleared(0); | |||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||
| 561 | 20 | $self->init_items; | |||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||
| 564 | 9 | ▶ | sub labels { shift->_labels(0, @_) } | ||||||||||||||||||||||||||||||
|
Subroutine
labels: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 565 | 4 | ▶ | sub label_ids { shift->_labels(1, @_) } | ||||||||||||||||||||||||||||||
|
Subroutine
label_ids: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||
| 567 | sub _labels | ||||||||||||||||||||||||||||||||
| 568 | 13 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
_labels: called CC=11 SCAR=24.5
| |||||||||||||||||||||||||||||||||
| 569 | 13 | my($self, $localized) = (shift, shift); | |||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||
| 571 | 13 | ▶ | my $key = $localized ? 'label_ids' : 'labels'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||
| 573 | 13 | ▶ | if(@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 574 | { | ||||||||||||||||||||||||||||||||
| 575 | 9 | my %labels; | |||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||
| 577 | 9 | ▶ | if(@_ == 1 && ref $_[0] eq 'HASH') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ == 1 and ref $_[0] eq "HASH"
MC/DC50%1/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1
ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||
| 578 | { | ||||||||||||||||||||||||||||||||
| 579 | 8 | $self->{$key} = $_[0]; | |||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||
| 581 | else | ||||||||||||||||||||||||||||||||
| 582 | { | ||||||||||||||||||||||||||||||||
| 583 | 1 | ▶ | Carp::croak "Odd number of items found in $key() hash argument" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 584 | unless(@_ % 2 == 0); | ||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||
| 586 | 1 | $self->{$key} = { @_ }; | |||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||
| 589 | 9 | $self->label_items; | |||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||
| 592 | 13 | my $want = wantarray; | |||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||
| 594 | 13 | ▶ | return unless(defined $want); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||
| 596 | 4 | my $group_class = $self->_item_group_class; | |||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||
| 598 | 4 | my %labels; | |||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||
| 600 | # Dumb linear search for now | ||||||||||||||||||||||||||||||||
| 601 | 4 | foreach my $item ($self->items) | |||||||||||||||||||||||||||||||
| 602 | { | ||||||||||||||||||||||||||||||||
| 603 | 12 | ▶ | if($item->isa($group_class)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 604 | { | ||||||||||||||||||||||||||||||||
| 605 | 0 | foreach my $subitem ($item->items) | |||||||||||||||||||||||||||||||
| 606 | { | ||||||||||||||||||||||||||||||||
| 607 | 0 | $labels{$subitem->html_attr('value')} = $subitem->label; | |||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||
| 610 | else | ||||||||||||||||||||||||||||||||
| 611 | { | ||||||||||||||||||||||||||||||||
| 612 | 12 | $labels{$item->html_attr('value')} = $item->label; | |||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||
| 616 | 4 | ▶ | return $want ? %labels : \%labels; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||
| 619 | # sub labels | ||||||||||||||||||||||||||||||||
| 620 | # { | ||||||||||||||||||||||||||||||||
| 621 | # my($self) = shift; | ||||||||||||||||||||||||||||||||
| 622 | # | ||||||||||||||||||||||||||||||||
| 623 | # if(@_) | ||||||||||||||||||||||||||||||||
| 624 | # { | ||||||||||||||||||||||||||||||||
| 625 | # my %labels; | ||||||||||||||||||||||||||||||||
| 626 | # | ||||||||||||||||||||||||||||||||
| 627 | # if(@_ == 1 && ref $_[0] eq 'HASH') | ||||||||||||||||||||||||||||||||
| 628 | # { | ||||||||||||||||||||||||||||||||
| 629 | # $self->{'labels'} = $_[0]; | ||||||||||||||||||||||||||||||||
| 630 | # } | ||||||||||||||||||||||||||||||||
| 631 | # else | ||||||||||||||||||||||||||||||||
| 632 | # { | ||||||||||||||||||||||||||||||||
| 633 | # Carp::croak "Odd number of items found in labels() hash argument" | ||||||||||||||||||||||||||||||||
| 634 | # unless(@_ % 2 == 0); | ||||||||||||||||||||||||||||||||
| 635 | # | ||||||||||||||||||||||||||||||||
| 636 | # $self->{'labels'} = { @_ }; | ||||||||||||||||||||||||||||||||
| 637 | # } | ||||||||||||||||||||||||||||||||
| 638 | # | ||||||||||||||||||||||||||||||||
| 639 | # $self->label_items; | ||||||||||||||||||||||||||||||||
| 640 | # } | ||||||||||||||||||||||||||||||||
| 641 | # | ||||||||||||||||||||||||||||||||
| 642 | # my $want = wantarray; | ||||||||||||||||||||||||||||||||
| 643 | # | ||||||||||||||||||||||||||||||||
| 644 | # return unless(defined $want); | ||||||||||||||||||||||||||||||||
| 645 | # | ||||||||||||||||||||||||||||||||
| 646 | # my $group_class = $self->_item_group_class; | ||||||||||||||||||||||||||||||||
| 647 | # | ||||||||||||||||||||||||||||||||
| 648 | # my %labels; | ||||||||||||||||||||||||||||||||
| 649 | # | ||||||||||||||||||||||||||||||||
| 650 | # # Dumb linear search for now | ||||||||||||||||||||||||||||||||
| 651 | # foreach my $item ($self->items) | ||||||||||||||||||||||||||||||||
| 652 | # { | ||||||||||||||||||||||||||||||||
| 653 | # if($item->isa($group_class)) | ||||||||||||||||||||||||||||||||
| 654 | # { | ||||||||||||||||||||||||||||||||
| 655 | # foreach my $subitem ($item->items) | ||||||||||||||||||||||||||||||||
| 656 | # { | ||||||||||||||||||||||||||||||||
| 657 | # $labels{$subitem->html_attr('value')} = $subitem->label; | ||||||||||||||||||||||||||||||||
| 658 | # } | ||||||||||||||||||||||||||||||||
| 659 | # } | ||||||||||||||||||||||||||||||||
| 660 | # else | ||||||||||||||||||||||||||||||||
| 661 | # { | ||||||||||||||||||||||||||||||||
| 662 | # $labels{$item->html_attr('value')} = $item->label; | ||||||||||||||||||||||||||||||||
| 663 | # } | ||||||||||||||||||||||||||||||||
| 664 | # } | ||||||||||||||||||||||||||||||||
| 665 | # | ||||||||||||||||||||||||||||||||
| 666 | # return $want ? %labels : \%labels; | ||||||||||||||||||||||||||||||||
| 667 | # } | ||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||
| 669 | sub html_field | ||||||||||||||||||||||||||||||||
| 670 | 41 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
html_field: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 671 | 41 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 672 | 41 | ▶ | my $sep = ($self->linebreak) ? $self->html_linebreak : ' '; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 673 | 41 | return join($sep, map { $_->html_field } $self->visible_items); | |||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||
| 676 | 13 | *html_fields = \&html_field; | |||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||
| 678 | sub xhtml_field | ||||||||||||||||||||||||||||||||
| 679 | 25 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
xhtml_field: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 680 | 25 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 681 | 25 | ▶ | my $sep = ($self->linebreak) ? $self->xhtml_linebreak : ' '; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 682 | 25 | return join($sep, map { $_->xhtml_field } $self->visible_items); | |||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||
| 685 | 13 | *xhtml_fields = \&xhtml_field; | |||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||
| 687 | sub escape_html | ||||||||||||||||||||||||||||||||
| 688 | 16 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
escape_html: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 689 | 16 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||
| 691 | 16 | ▶ | if(@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 692 | { | ||||||||||||||||||||||||||||||||
| 693 | 10 | my $val = $self->SUPER::escape_html(@_); | |||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||
| 695 | 10 | foreach my $item ($self->items) | |||||||||||||||||||||||||||||||
| 696 | { | ||||||||||||||||||||||||||||||||
| 697 | 30 | $item->escape_html($val); | |||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||
| 700 | 10 | return $val; | |||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||
| 703 | 6 | return $self->SUPER::escape_html(@_); | |||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||
| 706 | sub hidden_fields | ||||||||||||||||||||||||||||||||
| 707 | 12 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
hidden_fields: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 708 | 12 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||
| 710 | 12 | my @hidden; | |||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||
| 712 | 12 | foreach my $item ($self->items) | |||||||||||||||||||||||||||||||
| 713 | { | ||||||||||||||||||||||||||||||||
| 714 | 66 | ▶ | push(@hidden, $item->hidden_field) if(defined $item->internal_value); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||
| 717 | 12 | ▶ | return (wantarray) ? @hidden : \@hidden; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||
| 720 | # XXX: Could someday use Rose::HTML::Table::* | ||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||
| 722 | sub html_table | ||||||||||||||||||||||||||||||||
| 723 | 8 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
html_table: called CC=22 SCAR=33.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 724 | 8 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||
| 726 | 8 | my $items = $args{'items'}; | |||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||
| 728 | 8 | ▶ | return unless(ref $items && @$items); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $items and @$items
MC/DC0%0/2
ref $items and @$items
ref $items
@$items
Truth table33%1/3
A and B
A= ref $itemsB= @$items
| |||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||
| 730 | 8 | ▶ | my $xhtml = delete $args{'_xhtml'} || 0; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{'_xhtml'} || 0
MC/DC100%1/1
delete $args{'_xhtml'} || 0
delete $args{'_xhtml'}
Truth table100%2/2
A
A= delete $args{'_xhtml'}
| |||||||||||||||||||||||||||||||||
| 731 | 8 | ▶ | my $format_item = $args{'format_item'} || ($xhtml ? \&_xhtml_item : \&_html_item); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{'format_item'} || ($xhtml ? \&Rose::HTML::Form::Field::Group::_xhtml_item : \&Rose::HTML::Form::Field::Group::_html_item)
MC/DC0%0/2
$args{'format_item'} || ($xhtml ? \&Rose::HTML::Form::Field::Group::_xhtml_item : \&Rose::HTML::Form::Field::Group::_html_item)
$args{'format_item'}
($xhtml ? \&Rose::HTML::Form::Field::Group::_xhtml_item : \&Rose::HTML::Form::Field::Group::_html_item)
Truth table33%1/3
A || B
A= $args{'format_item'}B= ($xhtml ? \&Rose::HTML::Form::Field::Group::_xhtml_item : \&Rose::HTML::Form::Field::Group::_html_item)
| |||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||
| 733 | 8 | my $total = @$items; | |||||||||||||||||||||||||||||||
| 734 | 8 | ▶ | my $rows = $args{'rows'} || $self->rows || 1; | ||||||||||||||||||||||||||||||
|
Condition40%2/5
$args{'rows'} || $self->rows || 1
$args{"rows"} or $self->rows
MC/DC0%0/2
$args{'rows'} || $self->rows || 1
$args{"rows"}
$self->rows
Truth table33%1/3
A or B
A= $args{"rows"}B= $self->rows
| |||||||||||||||||||||||||||||||||
| 735 | 8 | ▶ | my $cols = $args{'columns'} || $self->columns || 1; | ||||||||||||||||||||||||||||||
|
Condition80%4/5
$args{'columns'} || $self->columns || 1
$args{"columns"} or $self->columns
MC/DC50%1/2
$args{'columns'} || $self->columns || 1
$args{"columns"}
$self->columns
Truth table66%2/3
A or B
A= $args{"columns"}B= $self->columns
| |||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||
| 737 | 8 | my $per_cell = $total / ($rows * $cols); | |||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||
| 739 | 8 | ▶ | if($total % ($rows * $cols)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 740 | { | ||||||||||||||||||||||||||||||||
| 741 | 2 | $per_cell = int($per_cell + 1); | |||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||
| 744 | 8 | my @table; | |||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||
| 746 | 8 | my $i = 0; | |||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||
| 748 | 8 | ▶ | for(my $x = 0; $x < $cols; $x++) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 749 | { | ||||||||||||||||||||||||||||||||
| 750 | 10 | ▶ | for(my $y = 0; $y < $rows; $y++) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 751 | { | ||||||||||||||||||||||||||||||||
| 752 | 10 | my $end = $i + $per_cell - 1; | |||||||||||||||||||||||||||||||
| 753 | 10 | ▶ | $end = $#$items if($end > $#$items); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 754 | 10 | $table[$y][$x] = [ @$items[$i .. $end] ]; | |||||||||||||||||||||||||||||||
| 755 | 10 | $i += $per_cell; | |||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||
| 757 | } | ||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||
| 759 | 8 | ▶ | my $sep = ($self->linebreak) ? $xhtml ? $self->xhtml_linebreak : $self->html_linebreak : ' '; | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||
| 761 | 8 | my $html = '<table' . Rose::HTML::Util::html_attrs_string($args{'table'}) . ">\n"; | |||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||
| 763 | 0 | ▶ | my @tr_attrs = (ref $args{'tr'} eq 'ARRAY') ? @{$args{'tr'}} : ($args{'tr'}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 764 | 0 | ▶ | my @td_attrs = (ref $args{'td'} eq 'ARRAY') ? @{$args{'td'}} : ($args{'td'}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||
| 766 | 8 | my $tr = 0; | |||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||
| 768 | 8 | foreach my $col (@table) | |||||||||||||||||||||||||||||||
| 769 | { | ||||||||||||||||||||||||||||||||
| 770 | 8 | ▶ | my $tr_attrs = $tr_attrs[$tr] || $tr_attrs[-1]; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$tr_attrs[$tr] || $tr_attrs[-1]
MC/DC0%0/2
$tr_attrs[$tr] || $tr_attrs[-1]
$tr_attrs[$tr]
$tr_attrs[-1]
Truth table33%1/3
A || B
A= $tr_attrs[$tr]B= $tr_attrs[-1]
| |||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||
| 772 | 8 | $html .= '<tr' . Rose::HTML::Util::html_attrs_string($tr_attrs) . ">\n"; | |||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||
| 774 | 8 | my $td = 0; | |||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||
| 776 | 8 | foreach my $row (@$col) | |||||||||||||||||||||||||||||||
| 777 | { | ||||||||||||||||||||||||||||||||
| 778 | 10 | ▶ | my $td_attrs = $td_attrs[$td] || $td_attrs[-1]; | ||||||||||||||||||||||||||||||
|
Condition66%2/3
$td_attrs[$td] || $td_attrs[-1]
MC/DC0%0/2
$td_attrs[$td] || $td_attrs[-1]
$td_attrs[$td]
$td_attrs[-1]
Truth table66%2/3
A || B
A= $td_attrs[$td]B= $td_attrs[-1]
| |||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||
| 780 | $html .= '<td' . Rose::HTML::Util::html_attrs_string($td_attrs) . '>' . | ||||||||||||||||||||||||||||||||
| 781 | 10 | join($sep, map { $self->$format_item($_) } @$row) . | |||||||||||||||||||||||||||||||
| 782 | "</td>\n"; | ||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||
| 784 | 10 | $td++; | |||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||
| 787 | 8 | $html .= "</tr>\n"; | |||||||||||||||||||||||||||||||
| 788 | 8 | $tr++; | |||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||
| 791 | 8 | $html .= "</table>\n"; | |||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||
| 793 | 8 | return $html; | |||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||
| 796 | 13 | *xhtml_table = \&html_table; | |||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||
| 798 | 13 | 1; | |||||||||||||||||||||||||||||||