| 1 | package Rose::HTML::Object; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 44 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | 44 | ▶ | use base 'Rose::HTML::Object::Localized'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 43 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 43 | ▶ | use Scalar::Util(); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 43 | ▶ | use List::Util qw(uniq); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | 43 | ▶ | use Rose::HTML::Util(); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | 43 | ▶ | use Rose::HTML::Object::Message::Localizer; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | 43 | our $VERSION = '0.626'; | |||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | 43 | our $Debug = undef; | |||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | # | ||||||||||||||||||||||||||||||||
| 19 | # Class data | ||||||||||||||||||||||||||||||||
| 20 | # | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | use Rose::Class::MakeMethods::Generic | ||||||||||||||||||||||||||||||||
| 23 | 43 | ▶ | ( | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 24 | 43 | inherited_hash => | |||||||||||||||||||||||||||||||
| 25 | [ | ||||||||||||||||||||||||||||||||
| 26 | 'object_type_class' => { plural_name => 'object_type_classes' }, | ||||||||||||||||||||||||||||||||
| 27 | ], | ||||||||||||||||||||||||||||||||
| 28 | 43 | ); | |||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 43 | __PACKAGE__->default_localizer(Rose::HTML::Object::Message::Localizer->new); | |||||||||||||||||||||||||||||||
| 31 | 43 | __PACKAGE__->default_locale('en'); | |||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | 43 | __PACKAGE__->autoload_html_attr_methods(1); | |||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | 43 | __PACKAGE__->add_valid_html_attrs | |||||||||||||||||||||||||||||||
| 36 | ( | ||||||||||||||||||||||||||||||||
| 37 | 'id', | ||||||||||||||||||||||||||||||||
| 38 | 'class', | ||||||||||||||||||||||||||||||||
| 39 | 'style', | ||||||||||||||||||||||||||||||||
| 40 | 'title', | ||||||||||||||||||||||||||||||||
| 41 | 'lang', | ||||||||||||||||||||||||||||||||
| 42 | 'xml:lang', | ||||||||||||||||||||||||||||||||
| 43 | 'dir', | ||||||||||||||||||||||||||||||||
| 44 | 'onclick', | ||||||||||||||||||||||||||||||||
| 45 | 'ondblclick', | ||||||||||||||||||||||||||||||||
| 46 | 'onmousedown', | ||||||||||||||||||||||||||||||||
| 47 | 'onmouseup', | ||||||||||||||||||||||||||||||||
| 48 | 'onmouseover', | ||||||||||||||||||||||||||||||||
| 49 | 'onmousemove', | ||||||||||||||||||||||||||||||||
| 50 | 'onmouseout', | ||||||||||||||||||||||||||||||||
| 51 | 'onkeypress', | ||||||||||||||||||||||||||||||||
| 52 | 'onkeydown', | ||||||||||||||||||||||||||||||||
| 53 | 'onkeyup' | ||||||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | 43 | __PACKAGE__->object_type_classes | |||||||||||||||||||||||||||||||
| 57 | ( | ||||||||||||||||||||||||||||||||
| 58 | 'anchor' => 'Rose::HTML::Anchor', | ||||||||||||||||||||||||||||||||
| 59 | 'image' => 'Rose::HTML::Image', | ||||||||||||||||||||||||||||||||
| 60 | 'label' => 'Rose::HTML::Label', | ||||||||||||||||||||||||||||||||
| 61 | 'link' => 'Rose::HTML::Link', | ||||||||||||||||||||||||||||||||
| 62 | 'script' => 'Rose::HTML::Script', | ||||||||||||||||||||||||||||||||
| 63 | 'literal text' => 'Rose::HTML::Text', | ||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | 'form' => 'Rose::HTML::Form', | ||||||||||||||||||||||||||||||||
| 66 | 'repeatable form' => 'Rose::HTML::Form::Repeatable', | ||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | 'text' => 'Rose::HTML::Form::Field::Text', | ||||||||||||||||||||||||||||||||
| 69 | 'scalar' => 'Rose::HTML::Form::Field::Text', | ||||||||||||||||||||||||||||||||
| 70 | 'char' => 'Rose::HTML::Form::Field::Text', | ||||||||||||||||||||||||||||||||
| 71 | 'character' => 'Rose::HTML::Form::Field::Text', | ||||||||||||||||||||||||||||||||
| 72 | 'varchar' => 'Rose::HTML::Form::Field::Text', | ||||||||||||||||||||||||||||||||
| 73 | 'string' => 'Rose::HTML::Form::Field::Text', | ||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | 'text area' => 'Rose::HTML::Form::Field::TextArea', | ||||||||||||||||||||||||||||||||
| 76 | 'textarea' => 'Rose::HTML::Form::Field::TextArea', | ||||||||||||||||||||||||||||||||
| 77 | 'blob' => 'Rose::HTML::Form::Field::TextArea', | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | 'option' => 'Rose::HTML::Form::Field::Option', | ||||||||||||||||||||||||||||||||
| 80 | 'option group' => 'Rose::HTML::Form::Field::OptionGroup', | ||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | 'checkbox' => 'Rose::HTML::Form::Field::Checkbox', | ||||||||||||||||||||||||||||||||
| 83 | 'check' => 'Rose::HTML::Form::Field::Checkbox', | ||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||
| 85 | 'radio button' => 'Rose::HTML::Form::Field::RadioButton', | ||||||||||||||||||||||||||||||||
| 86 | 'radio' => 'Rose::HTML::Form::Field::RadioButton', | ||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||
| 88 | 'checkboxes' => 'Rose::HTML::Form::Field::CheckboxGroup', | ||||||||||||||||||||||||||||||||
| 89 | 'checks' => 'Rose::HTML::Form::Field::CheckboxGroup', | ||||||||||||||||||||||||||||||||
| 90 | 'checkbox group' => 'Rose::HTML::Form::Field::CheckboxGroup', | ||||||||||||||||||||||||||||||||
| 91 | 'check group' => 'Rose::HTML::Form::Field::CheckboxGroup', | ||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||
| 93 | 'radio buttons' => 'Rose::HTML::Form::Field::RadioButtonGroup', | ||||||||||||||||||||||||||||||||
| 94 | 'radios' => 'Rose::HTML::Form::Field::RadioButtonGroup', | ||||||||||||||||||||||||||||||||
| 95 | 'radio button group' => 'Rose::HTML::Form::Field::RadioButtonGroup', | ||||||||||||||||||||||||||||||||
| 96 | 'radio group' => 'Rose::HTML::Form::Field::RadioButtonGroup', | ||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||
| 98 | 'pop-up menu' => 'Rose::HTML::Form::Field::PopUpMenu', | ||||||||||||||||||||||||||||||||
| 99 | 'popup menu' => 'Rose::HTML::Form::Field::PopUpMenu', | ||||||||||||||||||||||||||||||||
| 100 | 'menu' => 'Rose::HTML::Form::Field::PopUpMenu', | ||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||
| 102 | 'select box' => 'Rose::HTML::Form::Field::SelectBox', | ||||||||||||||||||||||||||||||||
| 103 | 'selectbox' => 'Rose::HTML::Form::Field::SelectBox', | ||||||||||||||||||||||||||||||||
| 104 | 'select' => 'Rose::HTML::Form::Field::SelectBox', | ||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | 'submit' => 'Rose::HTML::Form::Field::Submit', | ||||||||||||||||||||||||||||||||
| 107 | 'submit button' => 'Rose::HTML::Form::Field::Submit', | ||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | 'reset' => 'Rose::HTML::Form::Field::Reset', | ||||||||||||||||||||||||||||||||
| 110 | 'reset button' => 'Rose::HTML::Form::Field::Reset', | ||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||
| 112 | 'file' => 'Rose::HTML::Form::Field::File', | ||||||||||||||||||||||||||||||||
| 113 | 'upload' => 'Rose::HTML::Form::Field::File', | ||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||
| 115 | 'password' => 'Rose::HTML::Form::Field::Password', | ||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||
| 117 | 'hidden' => 'Rose::HTML::Form::Field::Hidden', | ||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||
| 119 | 'num' => 'Rose::HTML::Form::Field::Numeric', | ||||||||||||||||||||||||||||||||
| 120 | 'number' => 'Rose::HTML::Form::Field::Numeric', | ||||||||||||||||||||||||||||||||
| 121 | 'numeric' => 'Rose::HTML::Form::Field::Numeric', | ||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||
| 123 | 'int' => 'Rose::HTML::Form::Field::Integer', | ||||||||||||||||||||||||||||||||
| 124 | 'integer' => 'Rose::HTML::Form::Field::Integer', | ||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||
| 126 | 'email' => 'Rose::HTML::Form::Field::Email', | ||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||
| 128 | 'phone' => 'Rose::HTML::Form::Field::PhoneNumber::US', | ||||||||||||||||||||||||||||||||
| 129 | 'phone us' => 'Rose::HTML::Form::Field::PhoneNumber::US', | ||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||
| 131 | 'phone us split' => 'Rose::HTML::Form::Field::PhoneNumber::US::Split', | ||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||
| 133 | 'set' => 'Rose::HTML::Form::Field::Set', | ||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | 'time' => 'Rose::HTML::Form::Field::Time', | ||||||||||||||||||||||||||||||||
| 136 | 'time split hms' => 'Rose::HTML::Form::Field::Time::Split::HourMinuteSecond', | ||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||
| 138 | 'time hours' => 'Rose::HTML::Form::Field::Time::Hours', | ||||||||||||||||||||||||||||||||
| 139 | 'time minutes' => 'Rose::HTML::Form::Field::Time::Minutes', | ||||||||||||||||||||||||||||||||
| 140 | 'time seconds' => 'Rose::HTML::Form::Field::Time::Seconds', | ||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | 'date' => 'Rose::HTML::Form::Field::Date', | ||||||||||||||||||||||||||||||||
| 143 | 'datetime' => 'Rose::HTML::Form::Field::DateTime', | ||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||
| 145 | 'datetime range' => 'Rose::HTML::Form::Field::DateTime::Range', | ||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||
| 147 | 'datetime start' => 'Rose::HTML::Form::Field::DateTime::StartDate', | ||||||||||||||||||||||||||||||||
| 148 | 'datetime end' => 'Rose::HTML::Form::Field::DateTime::EndDate', | ||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||
| 150 | 'datetime split mdy' => 'Rose::HTML::Form::Field::DateTime::Split::MonthDayYear', | ||||||||||||||||||||||||||||||||
| 151 | 'datetime split mdyhms' => 'Rose::HTML::Form::Field::DateTime::Split::MDYHMS', | ||||||||||||||||||||||||||||||||
| 152 | ); | ||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||
| 154 | # | ||||||||||||||||||||||||||||||||
| 155 | # Object data | ||||||||||||||||||||||||||||||||
| 156 | # | ||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||
| 158 | use Rose::Object::MakeMethods::Generic | ||||||||||||||||||||||||||||||||
| 159 | 43 | ▶ | ( | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 160 | 43 | scalar => | |||||||||||||||||||||||||||||||
| 161 | [ | ||||||||||||||||||||||||||||||||
| 162 | 'html_element', # may be read-only in subclasses | ||||||||||||||||||||||||||||||||
| 163 | 'xhtml_element', # may be read-only in subclasses | ||||||||||||||||||||||||||||||||
| 164 | ], | ||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||
| 166 | boolean => | ||||||||||||||||||||||||||||||||
| 167 | [ | ||||||||||||||||||||||||||||||||
| 168 | 'escape_html' => { default => 1 }, | ||||||||||||||||||||||||||||||||
| 169 | 'validate_html_attrs' => { default => 1 }, | ||||||||||||||||||||||||||||||||
| 170 | 'is_self_closing' => { default => 0 }, | ||||||||||||||||||||||||||||||||
| 171 | ], | ||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||
| 173 | 'scalar --get_set_init' => | ||||||||||||||||||||||||||||||||
| 174 | [ | ||||||||||||||||||||||||||||||||
| 175 | 'html_error_formatter', | ||||||||||||||||||||||||||||||||
| 176 | 'xhtml_error_formatter', | ||||||||||||||||||||||||||||||||
| 177 | ], | ||||||||||||||||||||||||||||||||
| 178 | 43 | ); | |||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||
| 180 | use Rose::Class::MakeMethods::Generic | ||||||||||||||||||||||||||||||||
| 181 | 43 | ▶ | ( | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 182 | 43 | inheritable_scalar => | |||||||||||||||||||||||||||||||
| 183 | [ | ||||||||||||||||||||||||||||||||
| 184 | 'autoload_html_attr_methods', | ||||||||||||||||||||||||||||||||
| 185 | 'force_utf8', | ||||||||||||||||||||||||||||||||
| 186 | ], | ||||||||||||||||||||||||||||||||
| 187 | 43 | ); | |||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||
| 189 | use Rose::Class::MakeMethods::Set | ||||||||||||||||||||||||||||||||
| 190 | 43 | ▶ | ( | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 191 | 43 | inheritable_set => | |||||||||||||||||||||||||||||||
| 192 | [ | ||||||||||||||||||||||||||||||||
| 193 | required_html_attr => | ||||||||||||||||||||||||||||||||
| 194 | { | ||||||||||||||||||||||||||||||||
| 195 | add_implies => 'add_valid_html_attr', | ||||||||||||||||||||||||||||||||
| 196 | test_method => 'html_attr_is_required', | ||||||||||||||||||||||||||||||||
| 197 | }, | ||||||||||||||||||||||||||||||||
| 198 | ], | ||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||
| 200 | inherited_set => | ||||||||||||||||||||||||||||||||
| 201 | [ | ||||||||||||||||||||||||||||||||
| 202 | valid_html_attr => | ||||||||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||||||
| 204 | test_method => '_html_attr_is_valid', | ||||||||||||||||||||||||||||||||
| 205 | delete_implies => [ 'delete_boolean_html_attr', 'delete_required_html_attr' ], | ||||||||||||||||||||||||||||||||
| 206 | inherit_implies => 'inherit_boolean_html_attr', | ||||||||||||||||||||||||||||||||
| 207 | }, | ||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||
| 209 | boolean_html_attr => | ||||||||||||||||||||||||||||||||
| 210 | { | ||||||||||||||||||||||||||||||||
| 211 | add_implies => 'add_valid_html_attr', | ||||||||||||||||||||||||||||||||
| 212 | test_method => 'html_attr_is_boolean', | ||||||||||||||||||||||||||||||||
| 213 | }, | ||||||||||||||||||||||||||||||||
| 214 | ] | ||||||||||||||||||||||||||||||||
| 215 | 43 | ); | |||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||
| 217 | use Rose::HTML::Object::MakeMethods::Generic | ||||||||||||||||||||||||||||||||
| 218 | 43 | ▶ | ( | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 219 | 43 | array => | |||||||||||||||||||||||||||||||
| 220 | [ | ||||||||||||||||||||||||||||||||
| 221 | 'children' => { interface => 'get_set_inited' }, | ||||||||||||||||||||||||||||||||
| 222 | 'child' => { interface => 'get_item', hash_key => 'children' }, | ||||||||||||||||||||||||||||||||
| 223 | 'push_children' => { interface => 'push', hash_key => 'children' }, | ||||||||||||||||||||||||||||||||
| 224 | 'pop_children' => { interface => 'pop', hash_key => 'children' }, | ||||||||||||||||||||||||||||||||
| 225 | 'shift_children' => { interface => 'shift', hash_key => 'children' }, | ||||||||||||||||||||||||||||||||
| 226 | 'unshift_children' => { interface => 'unshift', hash_key => 'children' }, | ||||||||||||||||||||||||||||||||
| 227 | 'delete_children' => { interface => 'clear', hash_key => 'children' }, | ||||||||||||||||||||||||||||||||
| 228 | 'delete_child_at_index' => { interface => 'delete_item', hash_key => 'children' }, | ||||||||||||||||||||||||||||||||
| 229 | ], | ||||||||||||||||||||||||||||||||
| 230 | 43 | ); | |||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||
| 232 | # | ||||||||||||||||||||||||||||||||
| 233 | # Class methods | ||||||||||||||||||||||||||||||||
| 234 | # | ||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||
| 236 | 1632 | ▶ | sub generic_object_class { __PACKAGE__ } | ||||||||||||||||||||||||||||||
|
Subroutine
generic_object_class: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||
| 238 | 43 | *object_type_names = \&object_type_class_keys; | |||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||
| 240 | # | ||||||||||||||||||||||||||||||||
| 241 | # Constructor | ||||||||||||||||||||||||||||||||
| 242 | # | ||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||
| 244 | sub new | ||||||||||||||||||||||||||||||||
| 245 | 1634 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 246 | 1634 | my($class) = shift; | |||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||
| 248 | 1634 | ▶ | my $self = | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 249 | { | ||||||||||||||||||||||||||||||||
| 250 | html_attrs => {}, | ||||||||||||||||||||||||||||||||
| 251 | escape_html => 1, | ||||||||||||||||||||||||||||||||
| 252 | error => undef, | ||||||||||||||||||||||||||||||||
| 253 | validate_html_attrs => $class eq $class->generic_object_class ? 0 : 1, | ||||||||||||||||||||||||||||||||
| 254 | }; | ||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||
| 256 | 1634 | bless $self, $class; | |||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||
| 258 | 1634 | $self->init(@_); | |||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||
| 260 | 1634 | return $self; | |||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||
| 263 | # | ||||||||||||||||||||||||||||||||
| 264 | # Object methods | ||||||||||||||||||||||||||||||||
| 265 | # | ||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||
| 267 | sub init | ||||||||||||||||||||||||||||||||
| 268 | 1725 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 269 | 1725 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||
| 271 | 1725 | ▶ | @_ = (element => @_) if(@_ % 2); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||
| 273 | 1725 | my $class = ref $self; | |||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||
| 275 | 43 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 276 | 1725 | ▶ | while(my($k, $v) = each %{$class->required_html_attrs_hash}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 277 | { | ||||||||||||||||||||||||||||||||
| 278 | 2739 | $self->{'html_attrs'}{$k} = $v; | |||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||
| 281 | 1725 | $self->SUPER::init(@_); | |||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||
| 284 | 2 | ▶ | sub add_children { shift->push_children(@_) } | ||||||||||||||||||||||||||||||
|
Subroutine
add_children: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 285 | 2 | ▶ | sub add_child { shift->push_children(@_) } | ||||||||||||||||||||||||||||||
|
Subroutine
add_child: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 286 | 6 | ▶ | sub push_child { shift->push_children(@_) } | ||||||||||||||||||||||||||||||
|
Subroutine
push_child: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 287 | 4 | ▶ | sub pop_child { shift->pop_children(@_) } | ||||||||||||||||||||||||||||||
|
Subroutine
pop_child: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 288 | 2 | ▶ | sub shift_child { shift->shift_children(@_) } | ||||||||||||||||||||||||||||||
|
Subroutine
shift_child: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 289 | 3 | ▶ | sub unshift_child { shift->unshift_children(@_) } | ||||||||||||||||||||||||||||||
|
Subroutine
unshift_child: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||
| 291 | sub has_children | ||||||||||||||||||||||||||||||||
| 292 | 1866 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
has_children: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 293 | 1866 | my $children = shift->children; | |||||||||||||||||||||||||||||||
| 294 | 1866 | ▶ | return $children && @$children ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$children and @$children
MC/DC50%1/2
$children and @$children
$children
@$children
Truth table66%2/3
A and B
A= $childrenB= @$children
| |||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | sub has_parent { shift->parent ? 1 : 0 } | ||||||||||||||||||||||||||||||
|
Subroutine
has_parent: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||
| 299 | sub parent | ||||||||||||||||||||||||||||||||
| 300 | 977 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
parent: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 301 | 977 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||
| 303 | 977 | ▶ | if(@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 304 | { | ||||||||||||||||||||||||||||||||
| 305 | 464 | my $old_parent = $self->parent; | |||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||
| 307 | 464 | Scalar::Util::weaken($self->{'parent'} = shift); | |||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||
| 309 | 464 | my $new_parent = $self->{'parent'}; | |||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||
| 311 | 464 | ▶ | if($old_parent && Scalar::Util::refaddr($old_parent) != Scalar::Util::refaddr($new_parent)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$old_parent and builtin::refaddr($old_parent) != builtin::refaddr($new_parent)
MC/DC100%2/2
$old_parent and builtin::refaddr($old_parent) != builtin::refaddr($new_parent)
$old_parent
builtin::refaddr($old_parent) != builtin::refaddr($new_parent)
Truth table100%3/3
A and B
A= $old_parentB= builtin::refaddr($old_parent) != builtin::refaddr($new_parent)
| |||||||||||||||||||||||||||||||||
| 312 | { | ||||||||||||||||||||||||||||||||
| 313 | 1 | $old_parent->delete_child($self); | |||||||||||||||||||||||||||||||
| 314 | 1 | ▶ | $new_parent->push_child($self) unless($new_parent->has_child($self)); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||
| 318 | 977 | return $self->{'parent'}; | |||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||
| 321 | 5 | ▶ | sub descendants { map { $_, $_->descendants } shift->children } | ||||||||||||||||||||||||||||||
|
Subroutine
descendants: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||
| 323 | sub delete_child | ||||||||||||||||||||||||||||||||
| 324 | 3 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
delete_child: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 325 | 3 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||
| 327 | 3 | ▶ | if($_[0] =~ /^[+-]?\d+$/) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 328 | { | ||||||||||||||||||||||||||||||||
| 329 | 2 | return $self->delete_child_at_index(@_); | |||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||
| 332 | 1 | my $refaddr = Scalar::Util::refaddr($_[0]); | |||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||
| 334 | 1 | my $i = 0; | |||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||
| 336 | 1 | foreach my $child ($self->children) | |||||||||||||||||||||||||||||||
| 337 | { | ||||||||||||||||||||||||||||||||
| 338 | 1 | ▶ | if(Scalar::Util::refaddr($child) == $refaddr) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 339 | { | ||||||||||||||||||||||||||||||||
| 340 | 1 | return $self->delete_child_at_index($i); | |||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||
| 343 | 0 | $i++; | |||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||
| 346 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||
| 349 | sub has_child | ||||||||||||||||||||||||||||||||
| 350 | 1 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
has_child: called CC=3 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 351 | 1 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||
| 353 | 1 | my $refaddr = Scalar::Util::refaddr($_[0]); | |||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||
| 355 | 1 | foreach my $child ($self->children) | |||||||||||||||||||||||||||||||
| 356 | { | ||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | if(Scalar::Util::refaddr($child) == $refaddr) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 358 | { | ||||||||||||||||||||||||||||||||
| 359 | 0 | return 1; | |||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||
| 363 | 1 | return 0; | |||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||
| 366 | 43 | my %Loaded; # Lame, but trying to be fast here | |||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||
| 368 | sub object_type_class_loaded | ||||||||||||||||||||||||||||||||
| 369 | 1369 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
object_type_class_loaded: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 370 | 1369 | my($class) = shift; | |||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||
| 372 | 1369 | my $type_class = $class->object_type_class(@_); | |||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||
| 374 | 1369 | ▶ | unless($Loaded{$type_class}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 375 | { | ||||||||||||||||||||||||||||||||
| 376 | 43 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 377 | 64 | ▶ | unless(@{$type_class . '::ISA'}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 378 | { | ||||||||||||||||||||||||||||||||
| 379 | 10 | my $error; | |||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||
| 381 | TRY: | ||||||||||||||||||||||||||||||||
| 382 | { | ||||||||||||||||||||||||||||||||
| 383 | 10 | local $@; | |||||||||||||||||||||||||||||||
| 384 | 10 | ▶ | eval "use $type_class"; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 385 | 10 | $error = $@; | |||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||
| 388 | 10 | ▶ | Carp::croak "Could not load class '$type_class' - $error" if($error); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||
| 391 | 64 | $Loaded{$type_class}++; | |||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||
| 394 | 1369 | return $type_class; | |||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||
| 397 | sub message_for_error_id | ||||||||||||||||||||||||||||||||
| 398 | 6 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
message_for_error_id: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 399 | 6 | my($self, %args) = @_; | |||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||
| 401 | 6 | my $error_id = $args{'error_id'}; | |||||||||||||||||||||||||||||||
| 402 | 6 | ▶ | my $msg_class = $args{'msg_class'} || $self->localizer->message_class; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$args{'msg_class'} || $self->localizer->message_class
MC/DC0%0/2
$args{'msg_class'} || $self->localizer->message_class
$args{'msg_class'}
$self->localizer->message_class
Truth table33%1/3
A || B
A= $args{'msg_class'}B= $self->localizer->message_class
| |||||||||||||||||||||||||||||||||
| 403 | 6 | ▶ | my $args = $args{'args'} || []; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{'args'} || []
MC/DC100%1/1
$args{'args'} || []
$args{'args'}
Truth table100%2/2
A
A= $args{'args'}
| |||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||
| 405 | 6 | return $msg_class->new(id => $error_id, args => $args); | |||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||
| 409 | 132 | ▶ | sub init_html_error_formatter { } | ||||||||||||||||||||||||||||||
|
Subroutine
init_html_error_formatter: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | sub init_xhtml_error_formatter { } | ||||||||||||||||||||||||||||||
|
Subroutine
init_xhtml_error_formatter: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||
| 412 | sub element | ||||||||||||||||||||||||||||||||
| 413 | 13 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
element: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 414 | 13 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||
| 416 | 13 | ▶ | return $self->html_element unless(@_); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||
| 418 | 13 | $self->xhtml_element(@_); | |||||||||||||||||||||||||||||||
| 419 | 13 | return $self->html_element(@_); | |||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||
| 422 | sub html_attr_exists | ||||||||||||||||||||||||||||||||
| 423 | 427 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
html_attr_exists: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 424 | 427 | my($self, $attr) = @_; | |||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||
| 426 | 427 | ▶ | if(@_ == 2) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 427 | { | ||||||||||||||||||||||||||||||||
| 428 | 427 | ▶ | return (exists $self->{'html_attrs'}{$attr}) ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||
| 431 | 0 | croak 'Missing attribute name'; | |||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||
| 434 | sub delete_html_attrs | ||||||||||||||||||||||||||||||||
| 435 | 44 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
delete_html_attrs: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 436 | 44 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||
| 438 | 44 | ▶ | if(@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 439 | { | ||||||||||||||||||||||||||||||||
| 440 | 44 | local $_; | |||||||||||||||||||||||||||||||
| 441 | 44 | delete $self->{'html_attrs'}{$_} for(@_); | |||||||||||||||||||||||||||||||
| 442 | 44 | return scalar @_; | |||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||
| 445 | 0 | croak 'Missing attribute name'; | |||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||
| 448 | 41 | ▶ | sub delete_html_attr { shift->delete_html_attrs(@_) } | ||||||||||||||||||||||||||||||
|
Subroutine
delete_html_attr: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||
| 450 | 1 | ▶ | sub delete_all_html_attrs { $_[0]->delete_html_attrs($_[0]->html_attr_names) } | ||||||||||||||||||||||||||||||
|
Subroutine
delete_all_html_attrs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||
| 452 | sub clear_html_attrs | ||||||||||||||||||||||||||||||||
| 453 | 2 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
clear_html_attrs: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 454 | 2 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||
| 456 | 2 | ▶ | if(@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 457 | { | ||||||||||||||||||||||||||||||||
| 458 | 2 | local $_; | |||||||||||||||||||||||||||||||
| 459 | 2 | $self->{'html_attrs'}{$_} = undef for(@_); | |||||||||||||||||||||||||||||||
| 460 | 2 | return scalar @_; | |||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||
| 463 | 0 | croak 'Missing attribute name'; | |||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||
| 466 | 1 | ▶ | sub clear_html_attr { shift->clear_html_attrs(@_) } | ||||||||||||||||||||||||||||||
|
Subroutine
clear_html_attr: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||
| 468 | 1 | ▶ | sub clear_all_html_attrs { $_[0]->clear_html_attrs($_[0]->html_attr_names) } | ||||||||||||||||||||||||||||||
|
Subroutine
clear_all_html_attrs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||
| 470 | sub html_attr | ||||||||||||||||||||||||||||||||
| 471 | 26589 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
html_attr: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 472 | 26589 | my($self, $attr, $value) = @_; | |||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||
| 474 | 26589 | ▶ | croak "Invalid attribute: '$attr'" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $self->validate_html_attrs or $self->html_attr_is_valid($attr)
MC/DC100%2/2
not $self->validate_html_attrs or $self->html_attr_is_valid($attr)
not $self->validate_html_attrs
$self->html_attr_is_valid($attr)
Truth table100%3/3
not(A) or B
A= not $self->validate_html_attrsB= $self->html_attr_is_valid($attr)
| |||||||||||||||||||||||||||||||||
| 475 | unless(!$self->validate_html_attrs || | ||||||||||||||||||||||||||||||||
| 476 | $self->html_attr_is_valid($attr)); | ||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||
| 478 | 26584 | my $hook = $self->html_attr_hook($attr); | |||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||
| 480 | 26584 | ▶ | if(@_ == 3) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 481 | { | ||||||||||||||||||||||||||||||||
| 482 | 11949 | ▶ | if($hook) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 483 | { | ||||||||||||||||||||||||||||||||
| 484 | 1 | local $_ = $value; | |||||||||||||||||||||||||||||||
| 485 | 1 | $value = $self->$hook($value); | |||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||
| 488 | 11949 | return $self->{'html_attrs'}{$attr} = $value; | |||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||
| 490 | elsif(@_ == 2) | ||||||||||||||||||||||||||||||||
| 491 | { | ||||||||||||||||||||||||||||||||
| 492 | 14635 | ▶ | if(exists $self->{'html_attrs'}{$attr}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 493 | { | ||||||||||||||||||||||||||||||||
| 494 | 13453 | $value = $self->{'html_attrs'}{$attr}; | |||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||
| 496 | 13453 | ▶ | if($hook) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 497 | { | ||||||||||||||||||||||||||||||||
| 498 | 1 | local $_ = $value; | |||||||||||||||||||||||||||||||
| 499 | 1 | $value = $self->$hook(); | |||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||
| 502 | 13453 | return $value; | |||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||
| 505 | 1182 | return undef; | |||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||
| 508 | 0 | croak 'Missing attribute name'; | |||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||
| 511 | sub html_attr_is_valid | ||||||||||||||||||||||||||||||||
| 512 | 55029 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
html_attr_is_valid: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 513 | 55029 | my ($self, $attr) = @_; | |||||||||||||||||||||||||||||||
| 514 | 55029 | ▶ | return 1 if($attr =~ /^data-\w/); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 515 | 55028 | return $self->_html_attr_is_valid($attr); | |||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||
| 518 | sub html_attr_names | ||||||||||||||||||||||||||||||||
| 519 | 5 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
html_attr_names: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 520 | 4 | wantarray ? sort keys %{$_[0]->{'html_attrs'}} : | |||||||||||||||||||||||||||||||
| 521 | 5 | ▶ | [ sort keys %{$_[0]->{'html_attrs'}} ]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||
| 524 | sub html_attrs | ||||||||||||||||||||||||||||||||
| 525 | 2 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
html_attrs: called CC=7 SCAR=20.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 526 | 2 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||
| 528 | 2 | ▶ | if(@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 529 | { | ||||||||||||||||||||||||||||||||
| 530 | 2 | my $attrs; | |||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||
| 532 | 2 | ▶ | 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"
| |||||||||||||||||||||||||||||||||
| 533 | { | ||||||||||||||||||||||||||||||||
| 534 | 1 | $attrs = shift; | |||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||
| 536 | else | ||||||||||||||||||||||||||||||||
| 537 | { | ||||||||||||||||||||||||||||||||
| 538 | 1 | ▶ | croak 'Odd number of arguments' if(@_ % 2); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 539 | 1 | $attrs = { @_ }; | |||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||
| 542 | 2 | ▶ | while(my($attr, $value) = each(%$attrs)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 543 | { | ||||||||||||||||||||||||||||||||
| 544 | 5 | $self->html_attr($attr => $value); | |||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | return (wantarray) ? %{$self->{'html_attrs'}} : $self->{'html_attrs'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||
| 551 | sub html_attr_hook | ||||||||||||||||||||||||||||||||
| 552 | 26586 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
html_attr_hook: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 553 | 26586 | my($self, $attr) = (shift, shift); | |||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||
| 555 | 26586 | ▶ | croak "Invalid attribute: '$attr'" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $self->validate_html_attrs or $self->html_attr_is_valid($attr)
MC/DC0%0/2
not $self->validate_html_attrs or $self->html_attr_is_valid($attr)
not $self->validate_html_attrs
$self->html_attr_is_valid($attr)
Truth table66%2/3
not(A) or B
A= not $self->validate_html_attrsB= $self->html_attr_is_valid($attr)
| |||||||||||||||||||||||||||||||||
| 556 | unless(!$self->validate_html_attrs || | ||||||||||||||||||||||||||||||||
| 557 | $self->html_attr_is_valid($attr)); | ||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||
| 559 | 26586 | ▶ | if(@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 560 | { | ||||||||||||||||||||||||||||||||
| 561 | # XXX: possibly check that it's a code reference | ||||||||||||||||||||||||||||||||
| 562 | 2 | return $self->{'html_attr_hook'}{$attr} = shift; | |||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||
| 565 | 26584 | ▶ | if(exists $self->{'html_attr_hook'}{$attr}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 566 | { | ||||||||||||||||||||||||||||||||
| 567 | 4 | return $self->{'html_attr_hook'}{$attr}; | |||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||
| 570 | 26580 | return undef; | |||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||
| 573 | 1 | ▶ | sub delete_html_attr_hook { shift->html_attr_hook($_[0] => undef) } | ||||||||||||||||||||||||||||||
|
Subroutine
delete_html_attr_hook: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||
| 575 | 2 | ▶ | sub set_error { shift->error('') } | ||||||||||||||||||||||||||||||
|
Subroutine
set_error: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 576 | 1 | ▶ | sub unset_error { shift->error(undef) } | ||||||||||||||||||||||||||||||
|
Subroutine
unset_error: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||
| 578 | sub html_error | ||||||||||||||||||||||||||||||||
| 579 | 90 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
html_error: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 580 | 90 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||
| 582 | 90 | ▶ | if(my $code = $self->html_error_formatter) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 583 | { | ||||||||||||||||||||||||||||||||
| 584 | 0 | return $code->($self); | |||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||
| 587 | 90 | my $error = $self->error; | |||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||
| 589 | 90 | ▶ | if($error && length "$error") | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$error and length "$error"
MC/DC100%2/2
$error and length "$error"
$error
length "$error"
Truth table100%3/3
A and B
A= $errorB= length "$error"
| |||||||||||||||||||||||||||||||||
| 590 | { | ||||||||||||||||||||||||||||||||
| 591 | 17 | ▶ | return qq(<span class="error">) . | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 592 | ($self->escape_html ? Rose::HTML::Util::escape_html($error) : $error) . | ||||||||||||||||||||||||||||||||
| 593 | '</span>'; | ||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||
| 596 | 73 | return ''; | |||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||
| 599 | sub xhtml_error | ||||||||||||||||||||||||||||||||
| 600 | 36 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
xhtml_error: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||
| 601 | 36 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||
| 603 | 36 | ▶ | if(my $code = $self->html_error_formatter) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 604 | { | ||||||||||||||||||||||||||||||||
| 605 | 0 | return $code->($self); | |||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||
| 608 | 36 | return $self->html_error; | |||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||
| 611 | sub html_errors | ||||||||||||||||||||||||||||||||
| 612 | 4 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
html_errors: called CC=4 SCAR=15.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 613 | 4 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||
| 615 | 4 | ▶ | if(my $code = $self->html_error_formatter) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 616 | { | ||||||||||||||||||||||||||||||||
| 617 | 0 | return $code->($self); | |||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||
| 620 | 4 | my $error = join(', ', grep { /\S/ } $self->errors); | |||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||
| 622 | 4 | ▶ | if($error) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 623 | { | ||||||||||||||||||||||||||||||||
| 624 | 4 | ▶ | return qq(<span class="error">) . | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 625 | ($self->escape_html ? Rose::HTML::Util::escape_html($error) : $error) . | ||||||||||||||||||||||||||||||||
| 626 | '</span>'; | ||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||
| 629 | 0 | return ''; | |||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||
| 632 | sub xhtml_errors | ||||||||||||||||||||||||||||||||
| 633 | 2 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
xhtml_errors: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 634 | 2 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||
| 636 | 2 | ▶ | if(my $code = $self->html_error_formatter) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 637 | { | ||||||||||||||||||||||||||||||||
| 638 | 0 | return $code->($self); | |||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||
| 641 | 2 | return $self->html_errors; | |||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||
| 644 | sub html_attrs_string | ||||||||||||||||||||||||||||||||
| 645 | 1497 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
html_attrs_string: called CC=14 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 646 | 1497 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||
| 648 | 1497 | my @html; | |||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||
| 650 | 1497 | local $_; | |||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||
| 652 | 1497 | my $required_attrs = $self->required_html_attrs_hash; | |||||||||||||||||||||||||||||||
| 653 | 1497 | my %boolean_attrs = map { $_ => 1 } $self->boolean_html_attrs; | |||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||
| 655 | local $self->{'html_attrs'}{'required'} = $self->required | ||||||||||||||||||||||||||||||||
| 656 | 1497 | ▶ | if ($boolean_attrs{'required'}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||
| 658 | 1497 | foreach my $attr (sort(uniq(keys(%{$self->{'html_attrs'}}), keys(%$required_attrs)))) | |||||||||||||||||||||||||||||||
| 659 | { | ||||||||||||||||||||||||||||||||
| 660 | 4578 | my $value; | |||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||
| 662 | 4578 | ▶ | if(exists $self->{'html_attrs'}{$attr}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 663 | { | ||||||||||||||||||||||||||||||||
| 664 | 4560 | $value = $self->{'html_attrs'}{$attr}; | |||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||
| 667 | 4578 | ▶ | if(defined($value) || exists $boolean_attrs{$attr}) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
defined $value or exists $boolean_attrs{$attr}
MC/DC100%2/2
defined $value or exists $boolean_attrs{$attr}
defined $value
exists $boolean_attrs{$attr}
Truth table100%3/3
A or B
A= defined $valueB= exists $boolean_attrs{$attr}
| |||||||||||||||||||||||||||||||||
| 668 | { | ||||||||||||||||||||||||||||||||
| 669 | 4335 | ▶ | if($boolean_attrs{$attr}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 670 | { | ||||||||||||||||||||||||||||||||
| 671 | 1658 | ▶ | push(@html, $attr) if($value); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 672 | 1658 | next; | |||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||
| 675 | 2677 | ▶ | $value = '' unless(defined $value); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 676 | 2677 | ▶ | push(@html, $attr . q(=") . | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 677 | ($value =~ /\W/ ? Rose::HTML::Util::escape_html($value) : $value) . q(")); | ||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||
| 679 | elsif(exists $required_attrs->{$attr}) | ||||||||||||||||||||||||||||||||
| 680 | { | ||||||||||||||||||||||||||||||||
| 681 | 59 | $value = $required_attrs->{$attr}; | |||||||||||||||||||||||||||||||
| 682 | 59 | ▶ | $value = '' unless(defined $value); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 683 | 59 | ▶ | push(@html, $attr . q(=") . | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 684 | ($value =~ /\W/ ? Rose::HTML::Util::escape_html($value) : $value) . q(")); | ||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||
| 688 | 1497 | ▶ | return '' unless(@html); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||
| 690 | 1112 | return ' ' . join(' ', @html); | |||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||
| 693 | 43 | our (%Boolean_Attrs, %Required_Attrs); | |||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||
| 695 | sub xhtml_attrs_string | ||||||||||||||||||||||||||||||||
| 696 | 549 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
xhtml_attrs_string: called CC=15 SCAR=27.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 697 | 549 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||
| 699 | 549 | my $class = ref($self); | |||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||
| 701 | 549 | my @html; | |||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||
| 703 | 549 | local $_; | |||||||||||||||||||||||||||||||
| 704 | 549 | my $required_attrs = $self->required_html_attrs_hash; | |||||||||||||||||||||||||||||||
| 705 | 549 | my %boolean_attrs = map { $_ => 1 } $self->boolean_html_attrs; | |||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||
| 707 | local $self->{'html_attrs'}{'required'} = $self->required | ||||||||||||||||||||||||||||||||
| 708 | 549 | ▶ | if ($boolean_attrs{'required'}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||
| 710 | 549 | foreach my $attr (sort(uniq(keys(%{$self->{'html_attrs'}}), keys(%$required_attrs)))) | |||||||||||||||||||||||||||||||
| 711 | { | ||||||||||||||||||||||||||||||||
| 712 | 2371 | my $value; | |||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||
| 714 | 2371 | ▶ | if(exists $self->{'html_attrs'}{$attr}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 715 | { | ||||||||||||||||||||||||||||||||
| 716 | 2361 | $value = $self->{'html_attrs'}{$attr}; | |||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||
| 719 | 2371 | ▶ | if(defined($value) || exists $boolean_attrs{$attr}) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
defined $value or exists $boolean_attrs{$attr}
MC/DC100%2/2
defined $value or exists $boolean_attrs{$attr}
defined $value
exists $boolean_attrs{$attr}
Truth table100%3/3
A or B
A= defined $valueB= exists $boolean_attrs{$attr}
| |||||||||||||||||||||||||||||||||
| 720 | { | ||||||||||||||||||||||||||||||||
| 721 | 2262 | ▶ | if($boolean_attrs{$attr}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 722 | { | ||||||||||||||||||||||||||||||||
| 723 | 750 | ▶ | push(@html, $attr . q(=") . ($attr =~ /\W/ ? Rose::HTML::Util::escape_html($attr) : $attr) . q(")) if($value); | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 724 | 750 | next; | |||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||
| 727 | 1512 | ▶ | $value = '' unless(defined $value); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 728 | 1512 | ▶ | push(@html, $attr . q(=") . | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 729 | ($value =~ /\W/ ? Rose::HTML::Util::escape_html($value) : $value) . q(")); | ||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||
| 731 | elsif(exists $required_attrs->{$attr}) | ||||||||||||||||||||||||||||||||
| 732 | { | ||||||||||||||||||||||||||||||||
| 733 | 42 | $value = $required_attrs->{$attr}; | |||||||||||||||||||||||||||||||
| 734 | 42 | ▶ | $value = '' unless(defined $value); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 735 | 42 | ▶ | push(@html, $attr . q(=") . | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 736 | ($value =~ /\W/ ? Rose::HTML::Util::escape_html($value) : $value) . q(")); | ||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||
| 740 | 549 | ▶ | return '' unless(@html); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||
| 742 | 528 | return ' ' . join(' ', @html); | |||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||
| 745 | 21 | ▶ | sub html { shift->html_tag(@_) } | ||||||||||||||||||||||||||||||
|
Subroutine
html: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 746 | 29 | ▶ | sub xhtml { shift->xhtml_tag(@_) } | ||||||||||||||||||||||||||||||
|
Subroutine
xhtml: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||
| 748 | sub html_tag | ||||||||||||||||||||||||||||||||
| 749 | 1364 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
html_tag: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 750 | 1364 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||
| 752 | 43 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||
| 754 | 1364 | ▶ | if($self->has_children || !$self->is_self_closing) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->has_children or not $self->is_self_closing
MC/DC100%2/2
$self->has_children or not $self->is_self_closing
$self->has_children
not $self->is_self_closing
Truth table100%3/3
A or not(B)
A= $self->has_childrenB= not $self->is_self_closing
| |||||||||||||||||||||||||||||||||
| 755 | { | ||||||||||||||||||||||||||||||||
| 756 | return '<' . $self->html_element . $self->html_attrs_string . '>' . | ||||||||||||||||||||||||||||||||
| 757 | 870 | join('', map { $_->html_tag } $self->children) . | |||||||||||||||||||||||||||||||
| 758 | '</' . $self->html_element . '>'; | ||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||
| 761 | 494 | return '<' . $self->html_element . $self->html_attrs_string . '>'; | |||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||
| 764 | sub xhtml_tag | ||||||||||||||||||||||||||||||||
| 765 | 500 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
xhtml_tag: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 766 | 500 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||
| 768 | 43 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||
| 770 | 500 | ▶ | if($self->has_children || !$self->is_self_closing) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->has_children or not $self->is_self_closing
MC/DC100%2/2
$self->has_children or not $self->is_self_closing
$self->has_children
not $self->is_self_closing
Truth table100%3/3
A or not(B)
A= $self->has_childrenB= not $self->is_self_closing
| |||||||||||||||||||||||||||||||||
| 771 | { | ||||||||||||||||||||||||||||||||
| 772 | return '<' . $self->xhtml_element . $self->xhtml_attrs_string . '>' . | ||||||||||||||||||||||||||||||||
| 773 | 196 | join('', map { $_->xhtml_tag } $self->children) . | |||||||||||||||||||||||||||||||
| 774 | '</' . $self->xhtml_element . '>'; | ||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||
| 777 | 304 | return '<' . $self->xhtml_element . $self->xhtml_attrs_string . ' />'; | |||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||
| 780 | sub add_class | ||||||||||||||||||||||||||||||||
| 781 | 31 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
add_class: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 782 | 31 | my ($self, $new_class) = @_; | |||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||
| 784 | 31 | my $class = $self->html_attr('class'); | |||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||
| 786 | 43 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 787 | 31 | ▶ | unless($class =~ /(?:^| )$new_class(?: |$)/) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 788 | { | ||||||||||||||||||||||||||||||||
| 789 | 14 | ▶ | $self->html_attr(class => $class ? "$class $new_class" : $new_class); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||
| 793 | sub add_classes | ||||||||||||||||||||||||||||||||
| 794 | 2 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
add_classes: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 795 | 2 | my ($self) = shift; | |||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||
| 797 | 43 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 798 | 2 | ▶ | foreach my $class ((ref $_[0] eq ref []) ? @{$_[0]} : @_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 799 | { | ||||||||||||||||||||||||||||||||
| 800 | 6 | $self->add_class($class); | |||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||
| 804 | sub delete_class | ||||||||||||||||||||||||||||||||
| 805 | 812 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
delete_class: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 806 | 812 | my ($self, $delete_class) = @_; | |||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||
| 808 | 812 | my $class = $self->html_attr('class'); | |||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||
| 810 | 43 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 811 | 812 | ▶ | if($class =~ s/(^| |\G)\Q$delete_class\E( |$)/$1$2/g) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 812 | { | ||||||||||||||||||||||||||||||||
| 813 | 16 | for($class) | |||||||||||||||||||||||||||||||
| 814 | { | ||||||||||||||||||||||||||||||||
| 815 | 16 | s/^ +//; | |||||||||||||||||||||||||||||||
| 816 | 16 | s/ +$//; | |||||||||||||||||||||||||||||||
| 817 | 16 | s/ +/ /g; | |||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||
| 820 | 16 | $self->html_attr(class => $class); | |||||||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||||||
| 822 | } | ||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||
| 824 | sub delete_classes | ||||||||||||||||||||||||||||||||
| 825 | 3 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
delete_classes: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 826 | 3 | my ($self) = shift; | |||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||
| 828 | 43 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 829 | 3 | ▶ | foreach my $class ((ref $_[0] eq ref []) ? @{$_[0]} : @_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 830 | { | ||||||||||||||||||||||||||||||||
| 831 | 8 | $self->delete_class($class); | |||||||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||||||
| 833 | } | ||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||
| 835 | # | ||||||||||||||||||||||||||||||||
| 836 | # Lame start/end HTML fall-backs for lazy derived classes | ||||||||||||||||||||||||||||||||
| 837 | # | ||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||
| 839 | sub start_html | ||||||||||||||||||||||||||||||||
| 840 | 106 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
start_html: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 841 | 106 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||
| 843 | 106 | return '<' . $self->html_element . $self->html_attrs_string . '>'; | |||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||
| 845 | #my $html = $self->html; | ||||||||||||||||||||||||||||||||
| 846 | #$html =~ s{</\w+>\z}{}; | ||||||||||||||||||||||||||||||||
| 847 | #return $html; | ||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||
| 850 | sub end_html | ||||||||||||||||||||||||||||||||
| 851 | 106 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
end_html: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 852 | 106 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||
| 854 | 106 | return '</' . $self->html_element . '>'; | |||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||
| 856 | #my $html = $self->html; | ||||||||||||||||||||||||||||||||
| 857 | #$html =~ m{</\w+>\z}; | ||||||||||||||||||||||||||||||||
| 858 | #return $1 || ''; | ||||||||||||||||||||||||||||||||
| 859 | } | ||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||
| 861 | sub start_xhtml | ||||||||||||||||||||||||||||||||
| 862 | 44 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
start_xhtml: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 863 | 44 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||
| 865 | 44 | return '<' . $self->xhtml_element . $self->xhtml_attrs_string . '>'; | |||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||
| 867 | #my $xhtml = $self->xhtml; | ||||||||||||||||||||||||||||||||
| 868 | #$xhtml =~ s{</\w+>\z}{}; | ||||||||||||||||||||||||||||||||
| 869 | #return $xhtml; | ||||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||
| 872 | sub end_xhtml | ||||||||||||||||||||||||||||||||
| 873 | 44 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
end_xhtml: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 874 | 44 | my($self) = shift; | |||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||
| 876 | 44 | return '</' . $self->xhtml_element . '>'; | |||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||
| 878 | #my $xhtml = $self->xhtml; | ||||||||||||||||||||||||||||||||
| 879 | #$xhtml =~ m{</\w+>\z}; | ||||||||||||||||||||||||||||||||
| 880 | #return $1 || ''; | ||||||||||||||||||||||||||||||||
| 881 | } | ||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||
| 883 | sub default_html_attr_value | ||||||||||||||||||||||||||||||||
| 884 | 9 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
default_html_attr_value: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 885 | 9 | my($class) = shift; | |||||||||||||||||||||||||||||||
| 886 | 9 | my($attr) = shift; | |||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||
| 888 | 9 | ▶ | if(@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 889 | { | ||||||||||||||||||||||||||||||||
| 890 | 9 | $class->add_required_html_attr({ $attr => $_[0] }); | |||||||||||||||||||||||||||||||
| 891 | 9 | return $_[0]; | |||||||||||||||||||||||||||||||
| 892 | } | ||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||
| 894 | 0 | return $class->required_html_attr_value($attr); | |||||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||
| 897 | sub load_all_messages | ||||||||||||||||||||||||||||||||
| 898 | 1 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
load_all_messages: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||
| 899 | 1 | my($self_or_class) = shift; | |||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||
| 901 | 1 | ▶ | my $class = ref($self_or_class) || $self_or_class; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self_or_class || $self_or_class
MC/DC0%0/2
ref $self_or_class || $self_or_class
ref $self_or_class
$self_or_class
Truth table33%1/3
A || B
A= ref $self_or_classB= $self_or_class
| |||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||
| 903 | 1 | $class->localizer->load_all_messages(from_class => $class); | |||||||||||||||||||||||||||||||
| 904 | } | ||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||
| 906 | 43 | our $AUTOLOAD; | |||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||
| 908 | # We "can" do what will eventually be AUTOLOADed HTML attribute methods | ||||||||||||||||||||||||||||||||
| 909 | sub can | ||||||||||||||||||||||||||||||||
| 910 | 9899 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
can: called CC=5 SCAR=21.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 911 | 9899 | my($self, $name) = @_; | |||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||
| 913 | 9899 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table66%2/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||
| 915 | 9899 | my $code = $self->SUPER::can($name); | |||||||||||||||||||||||||||||||
| 916 | 9899 | ▶ | return $code if($code); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||
| 918 | 1749 | ▶ | return unless($self->html_attr_is_valid($name) && $class->autoload_html_attr_methods); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->html_attr_is_valid($name) and $class->autoload_html_attr_methods
MC/DC0%0/2
$self->html_attr_is_valid($name) and $class->autoload_html_attr_methods
$self->html_attr_is_valid($name)
$class->autoload_html_attr_methods
Truth table33%1/3
A and B
A= $self->html_attr_is_valid($name)B= $class->autoload_html_attr_methods
| |||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||
| 920 | # can() expects a code ref that will actually work... | ||||||||||||||||||||||||||||||||
| 921 | return sub | ||||||||||||||||||||||||||||||||
| 922 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 923 | 0 | my $self = $_[0]; | |||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||
| 925 | 0 | my $code = $self->SUPER::can($name); # exists already? | |||||||||||||||||||||||||||||||
| 926 | 0 | ▶ | goto &$code if($code); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||
| 928 | 0 | $AUTOLOAD = $class; | |||||||||||||||||||||||||||||||
| 929 | 0 | goto &AUTOLOAD | |||||||||||||||||||||||||||||||
| 930 | 0 | }; | |||||||||||||||||||||||||||||||
| 931 | } | ||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||
| 933 | sub __method_was_autoloaded | ||||||||||||||||||||||||||||||||
| 934 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
__method_was_autoloaded: not called CC=2 SCAR=11.6
| |||||||||||||||||||||||||||||||||
| 935 | 0 | ▶ | my($class) = ref($_[0]) || $_[0]; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||||||
| 936 | 43 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 937 | 0 | exists ${$class . '::__AUTOLOADED'}{$_[1]}; | |||||||||||||||||||||||||||||||
| 938 | } | ||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||
| 940 | sub create_html_attr_methods | ||||||||||||||||||||||||||||||||
| 941 | 1 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
create_html_attr_methods: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 942 | 1 | my($class) = shift; | |||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||
| 944 | 1 | my $count = 0; | |||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||
| 946 | 1 | ▶ | foreach my $attr (@_ ? @_ : $class->valid_html_attrs) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 947 | { | ||||||||||||||||||||||||||||||||
| 948 | 43 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 949 | 2 | my $method = $class . '::' . $attr; | |||||||||||||||||||||||||||||||
| 950 | 2 | ▶ | next if(defined &$method); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 951 | 0 | ▶ | *$method = sub { shift->html_attr($attr, @_) }; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||
| 952 | 2 | $count++; | |||||||||||||||||||||||||||||||
| 953 | } | ||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||
| 955 | 1 | return $count; | |||||||||||||||||||||||||||||||
| 956 | } | ||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||
| 958 | sub import | ||||||||||||||||||||||||||||||||
| 959 | 275 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||
| 960 | 275 | my($class) = shift; | |||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||
| 962 | 275 | foreach my $arg (@_) | |||||||||||||||||||||||||||||||
| 963 | { | ||||||||||||||||||||||||||||||||
| 964 | 3 | ▶ | if($arg eq ':customize') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 965 | { | ||||||||||||||||||||||||||||||||
| 966 | 3 | $class->import_methods( | |||||||||||||||||||||||||||||||
| 967 | { target_class => (caller)[0] }, | ||||||||||||||||||||||||||||||||
| 968 | qw(object_type_class_exists object_type_class_keys | ||||||||||||||||||||||||||||||||
| 969 | delete_object_type_class object_type_classes | ||||||||||||||||||||||||||||||||
| 970 | clear_object_type_classes object_type_class | ||||||||||||||||||||||||||||||||
| 971 | inherit_object_type_classes object_type_classes_cache | ||||||||||||||||||||||||||||||||
| 972 | inherit_object_type_class add_object_type_classes | ||||||||||||||||||||||||||||||||
| 973 | delete_object_type_classes add_object_type_class | ||||||||||||||||||||||||||||||||
| 974 | localizer locale default_localizer default_locale)); | ||||||||||||||||||||||||||||||||
| 975 | } | ||||||||||||||||||||||||||||||||
| 976 | else | ||||||||||||||||||||||||||||||||
| 977 | { | ||||||||||||||||||||||||||||||||
| 978 | 0 | carp "$class: Unknown import argument '$arg'"; | |||||||||||||||||||||||||||||||
| 979 | } | ||||||||||||||||||||||||||||||||
| 980 | } | ||||||||||||||||||||||||||||||||
| 981 | } | ||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||
| 983 | # XXX: This is undocumented for now... | ||||||||||||||||||||||||||||||||
| 984 | # | ||||||||||||||||||||||||||||||||
| 985 | # =item B<import_methods NAME1 [, NAME2, ...]> | ||||||||||||||||||||||||||||||||
| 986 | # | ||||||||||||||||||||||||||||||||
| 987 | # Import methods from the named class (the invocant) into the current class. | ||||||||||||||||||||||||||||||||
| 988 | # This works by searching the class hierarchy, starting from the invocant class, | ||||||||||||||||||||||||||||||||
| 989 | # and using a breadth-first search. When an existing method with the requested | ||||||||||||||||||||||||||||||||
| 990 | # NAME is found, it is aliased into the current (calling) package. If a method | ||||||||||||||||||||||||||||||||
| 991 | # of the desired name is not found, a fatal error is thrown. | ||||||||||||||||||||||||||||||||
| 992 | # | ||||||||||||||||||||||||||||||||
| 993 | # This is a somewhat evil hack that i used internally to get around some | ||||||||||||||||||||||||||||||||
| 994 | # inconvenient consequences of multiple inheritence and its interaction with | ||||||||||||||||||||||||||||||||
| 995 | # Perl's default left-most depth-first method dispatch. | ||||||||||||||||||||||||||||||||
| 996 | # | ||||||||||||||||||||||||||||||||
| 997 | # This method is an implementation detail and is not part of the public "user" | ||||||||||||||||||||||||||||||||
| 998 | # API. It is described here for the benefit of those who are subclassing | ||||||||||||||||||||||||||||||||
| 999 | # L<Rose::HTML::Object> and who also may find themselves in a bit of a multiple | ||||||||||||||||||||||||||||||||
| 1000 | # inheritence bind. | ||||||||||||||||||||||||||||||||
| 1001 | # | ||||||||||||||||||||||||||||||||
| 1002 | # Example: | ||||||||||||||||||||||||||||||||
| 1003 | # | ||||||||||||||||||||||||||||||||
| 1004 | # package MyTag; | ||||||||||||||||||||||||||||||||
| 1005 | # | ||||||||||||||||||||||||||||||||
| 1006 | # use base 'SomeTag'; | ||||||||||||||||||||||||||||||||
| 1007 | # | ||||||||||||||||||||||||||||||||
| 1008 | # use MyOtherTag; | ||||||||||||||||||||||||||||||||
| 1009 | # | ||||||||||||||||||||||||||||||||
| 1010 | # # Do a bredth-first search, starting in the class MyOtherTag, | ||||||||||||||||||||||||||||||||
| 1011 | # # for methods named 'foo' and 'bar', and alias them into | ||||||||||||||||||||||||||||||||
| 1012 | # # this package (MyTag) | ||||||||||||||||||||||||||||||||
| 1013 | # MyOtherTag->import_methods('foo', 'bar'); | ||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||
| 1015 | # If method dispatch was breadth-first, I probably wouldn't need this... | ||||||||||||||||||||||||||||||||
| 1016 | sub import_methods | ||||||||||||||||||||||||||||||||
| 1017 | 46 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
import_methods: called CC=12 SCAR=25.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 1018 | 46 | my($this_class) = shift; | |||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||
| 1020 | 46 | ▶ | my $options = ref $_[0] && ref $_[0] eq 'HASH' ? shift : {}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $_[0] and ref $_[0] eq "HASH"
MC/DC50%1/2
ref $_[0] and ref $_[0] eq "HASH"
ref $_[0]
ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= ref $_[0]B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||
| 1022 | 46 | ▶ | my $target_class = $options->{'target_class'} || (caller)[0]; | ||||||||||||||||||||||||||||||
|
Condition66%2/3
$options->{'target_class'} || (caller)[0]
MC/DC0%0/2
$options->{'target_class'} || (caller)[0]
$options->{'target_class'}
(caller)[0]
Truth table66%2/3
A || B
A= $options->{'target_class'}B= (caller)[0]
| |||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||
| 1024 | 46 | my(@search_classes, @parents); | |||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||
| 1026 | 46 | @parents = ($this_class); | |||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||
| 1028 | 46 | ▶ | while(my $class = shift(@parents)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1029 | { | ||||||||||||||||||||||||||||||||
| 1030 | 285 | push(@search_classes, $class); | |||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||
| 1032 | 43 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 1033 | 285 | foreach my $subclass (@{$class . '::ISA'}) | |||||||||||||||||||||||||||||||
| 1034 | { | ||||||||||||||||||||||||||||||||
| 1035 | 239 | push(@parents, $subclass); | |||||||||||||||||||||||||||||||
| 1036 | } | ||||||||||||||||||||||||||||||||
| 1037 | } | ||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||
| 1039 | 46 | my %methods; | |||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||
| 1041 | 46 | foreach my $arg (@_) | |||||||||||||||||||||||||||||||
| 1042 | { | ||||||||||||||||||||||||||||||||
| 1043 | 210 | ▶ | if(ref $arg eq 'HASH') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1044 | { | ||||||||||||||||||||||||||||||||
| 1045 | 0 | $methods{$_} = $arg->{$_} for(keys %$arg); | |||||||||||||||||||||||||||||||
| 1046 | } | ||||||||||||||||||||||||||||||||
| 1047 | else | ||||||||||||||||||||||||||||||||
| 1048 | { | ||||||||||||||||||||||||||||||||
| 1049 | 210 | $methods{$arg} = $arg; | |||||||||||||||||||||||||||||||
| 1050 | } | ||||||||||||||||||||||||||||||||
| 1051 | } | ||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||
| 1053 | 46 | ▶ | METHOD: while(my($method, $import_as) = each(%methods)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1054 | { | ||||||||||||||||||||||||||||||||
| 1055 | 43 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 1056 | 210 | foreach my $class (@search_classes) | |||||||||||||||||||||||||||||||
| 1057 | { | ||||||||||||||||||||||||||||||||
| 1058 | 222 | ▶ | if(defined &{$class . '::' . $method}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1059 | { | ||||||||||||||||||||||||||||||||
| 1060 | #print STDERR "${target_class}::$import_as = ${class}::$method\n"; | ||||||||||||||||||||||||||||||||
| 1061 | 210 | *{$target_class . '::' . $import_as} = \&{$class . '::' . $method}; | |||||||||||||||||||||||||||||||
| 1062 | 210 | next METHOD; | |||||||||||||||||||||||||||||||
| 1063 | } | ||||||||||||||||||||||||||||||||
| 1064 | } | ||||||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||||||
| 1066 | 0 | Carp::croak "Could not find method '$method' in any subclass of $this_class"; | |||||||||||||||||||||||||||||||
| 1067 | } | ||||||||||||||||||||||||||||||||
| 1068 | } | ||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||
| 1070 | 0 | ▶ | sub DESTROY { } | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||
| 1072 | sub AUTOLOAD | ||||||||||||||||||||||||||||||||
| 1073 | 138 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||
| 1074 | 138 | my($self) = $_[0]; | |||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||
| 1076 | 138 | ▶ | if(my $class = ref($self)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1077 | { | ||||||||||||||||||||||||||||||||
| 1078 | 138 | my $name = $AUTOLOAD; | |||||||||||||||||||||||||||||||
| 1079 | 138 | $name =~ s/.*://; | |||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||
| 1081 | 138 | ▶ | if($class->html_attr_is_valid($name) && $class->autoload_html_attr_methods) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$class->html_attr_is_valid($name) and $class->autoload_html_attr_methods
MC/DC100%2/2
$class->html_attr_is_valid($name) and $class->autoload_html_attr_methods
$class->html_attr_is_valid($name)
$class->autoload_html_attr_methods
Truth table100%3/3
A and B
A= $class->html_attr_is_valid($name)B= $class->autoload_html_attr_methods
| |||||||||||||||||||||||||||||||||
| 1082 | { | ||||||||||||||||||||||||||||||||
| 1083 | 43 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 1084 | 135 | ▶ | *$AUTOLOAD = sub { shift->html_attr($name, @_) }; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 1085 | 135 | ${$class . '::__AUTOLOADED'}{$name} = 1; | |||||||||||||||||||||||||||||||
| 1086 | 135 | goto &$AUTOLOAD; | |||||||||||||||||||||||||||||||
| 1087 | } | ||||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||
| 1089 | confess | ||||||||||||||||||||||||||||||||
| 1090 | 3 | ▶ | qq(Can't locate object method "$name" via package "$class" - ) . | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1091 | ($class->html_attr_is_valid($name) ? | ||||||||||||||||||||||||||||||||
| 1092 | "did not auto-create method because $class->autoload_html_attr_methods is not set" : | ||||||||||||||||||||||||||||||||
| 1093 | "no such method, and none auto-created because it is not a valid HTML attribute for this class"); | ||||||||||||||||||||||||||||||||
| 1094 | } | ||||||||||||||||||||||||||||||||
| 1095 | else | ||||||||||||||||||||||||||||||||
| 1096 | { | ||||||||||||||||||||||||||||||||
| 1097 | 0 | my $name = $AUTOLOAD; | |||||||||||||||||||||||||||||||
| 1098 | 0 | $name =~ s/.*://; | |||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||
| 1100 | 0 | confess qq(Can't locate class method "$name" via package "$self"); | |||||||||||||||||||||||||||||||
| 1101 | } | ||||||||||||||||||||||||||||||||
| 1102 | } | ||||||||||||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||||||||||||
| 1104 | 43 | 1; | |||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||
| 1106 | __END__ | ||||||||||||||||||||||||||||||||