| 1 | package Tags::HTML::SendMessage; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Class::Utils qw(set_params); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Error::Pure qw(err); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Readonly; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | # Constants. | ||||||||||||||||||||||||||||
| 11 | 2 | Readonly::Hash my %LANG => ( | |||||||||||||||||||||||||||
| 12 | 'title' => 'Leave us a message', | ||||||||||||||||||||||||||||
| 13 | 'name-and-surname' => 'Name and surname', | ||||||||||||||||||||||||||||
| 14 | 'email' => 'Email', | ||||||||||||||||||||||||||||
| 15 | 'subject' => 'Subject of you question', | ||||||||||||||||||||||||||||
| 16 | 'your-message' => 'Your message', | ||||||||||||||||||||||||||||
| 17 | 'send' => 'Send question', | ||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 2 | our $VERSION = 0.09; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # Constructor. | ||||||||||||||||||||||||||||
| 23 | sub new { | ||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my ($class, @params) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | # Create object. | ||||||||||||||||||||||||||||
| 27 | 0 | my $self = bless {}, $class; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # 'CSS::Struct' object. | ||||||||||||||||||||||||||||
| 30 | 0 | $self->{'css'} = undef; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | # Languages. | ||||||||||||||||||||||||||||
| 33 | 0 | $self->{'lang'} = \%LANG; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | # 'Tags' object. | ||||||||||||||||||||||||||||
| 36 | 0 | $self->{'tags'} = undef; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | # Process params. | ||||||||||||||||||||||||||||
| 39 | 0 | set_params($self, @params); | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | # Check to 'Tags' object. | ||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if (! $self->{'tags'} || ! $self->{'tags'}->isa('Tags::Output')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"tags"} and $self->{"tags"}->isa("Tags::Output")
MC/DC0%0/2
$self->{"tags"} and $self->{"tags"}->isa("Tags::Output")
$self->{"tags"}
$self->{"tags"}->isa("Tags::Output")
Truth table0%0/3
A and B
A= $self->{"tags"}B= $self->{"tags"}->isa("Tags::Output")
| |||||||||||||||||||||||||||||
| 43 | 0 | err "Parameter 'tags' must be a 'Tags::Output::*' class."; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # Check to 'CSS::Struct' object. | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if ($self->{'css'} && ! $self->{'css'}->isa('CSS::Struct::Output')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"css"} and not $self->{"css"}->isa("CSS::Struct::Output")
MC/DC0%0/2
$self->{"css"} and not $self->{"css"}->isa("CSS::Struct::Output")
$self->{"css"}
not $self->{"css"}->isa("CSS::Struct::Output")
Truth table0%0/3
A and not(B)
A= $self->{"css"}B= not $self->{"css"}->isa("CSS::Struct::Output")
| |||||||||||||||||||||||||||||
| 48 | 0 | err "Parameter 'css' must be a 'CSS::Struct::Output::*' class."; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | # Object. | ||||||||||||||||||||||||||||
| 52 | 0 | return $self; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | # Process 'Tags'. | ||||||||||||||||||||||||||||
| 56 | sub process { | ||||||||||||||||||||||||||||
| 57 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
process: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | # Begin of page. | ||||||||||||||||||||||||||||
| 60 | $self->{'tags'}->put( | ||||||||||||||||||||||||||||
| 61 | ['b', 'div'], | ||||||||||||||||||||||||||||
| 62 | ['a', 'id', 'send-message'], | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | ['b', 'form'], | ||||||||||||||||||||||||||||
| 65 | ['a', 'action', ''], | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | ['b', 'fieldset'], | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | ['b', 'legend'], | ||||||||||||||||||||||||||||
| 70 | 0 | ['d', $self->{'lang'}->{'title'}], | |||||||||||||||||||||||||||
| 71 | ['e', 'legend'], | ||||||||||||||||||||||||||||
| 72 | ); | ||||||||||||||||||||||||||||
| 73 | 0 | $self->_tags_form_input('name-and-surname', 1, { 'size' => 30 }); | |||||||||||||||||||||||||||
| 74 | 0 | $self->_tags_form_input('email', 1, { 'size' => 30 }); | |||||||||||||||||||||||||||
| 75 | 0 | $self->_tags_form_input('subject', 1, { 'size' => 72 }); | |||||||||||||||||||||||||||
| 76 | 0 | $self->_tags_form_textarea('your-message', 1, { 'cols' => 75, 'rows' => 10 }); | |||||||||||||||||||||||||||
| 77 | $self->{'tags'}->put( | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | ['b', 'input'], | ||||||||||||||||||||||||||||
| 80 | ['a', 'type', 'submit'], | ||||||||||||||||||||||||||||
| 81 | 0 | ['a', 'value', $self->{'lang'}->{'send'}], | |||||||||||||||||||||||||||
| 82 | ['e', 'input'], | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | ['e', 'fieldset'], | ||||||||||||||||||||||||||||
| 85 | ['e', 'form'], | ||||||||||||||||||||||||||||
| 86 | ['e', 'div'], | ||||||||||||||||||||||||||||
| 87 | ); | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | return; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | sub _tags_form_input { | ||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my ($self, $id, $br, $input_opts_hr) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_tags_form_input: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | $self->{'tags'}->put( | ||||||||||||||||||||||||||||
| 96 | ['b', 'label'], | ||||||||||||||||||||||||||||
| 97 | ['a', 'for', $id], | ||||||||||||||||||||||||||||
| 98 | ['d', $self->{'lang'}->{$id}.':'], | ||||||||||||||||||||||||||||
| 99 | ['e', 'label'], | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | ['b', 'br'], | ||||||||||||||||||||||||||||
| 102 | ['e', 'br'], | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | ['b', 'input'], | ||||||||||||||||||||||||||||
| 105 | ['a', 'id', $id], | ||||||||||||||||||||||||||||
| 106 | ['a', 'name', $id], | ||||||||||||||||||||||||||||
| 107 | exists $input_opts_hr->{'size'} ? ( | ||||||||||||||||||||||||||||
| 108 | 0 | ▶ | ['a', 'size', $input_opts_hr->{'size'}], | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | ) : (), | ||||||||||||||||||||||||||||
| 110 | ['e', 'input'], | ||||||||||||||||||||||||||||
| 111 | ); | ||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if ($br) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | 0 | $self->{'tags'}->put( | |||||||||||||||||||||||||||
| 114 | ['b', 'br'], | ||||||||||||||||||||||||||||
| 115 | ['e', 'br'], | ||||||||||||||||||||||||||||
| 116 | ); | ||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | return; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | sub _tags_form_textarea { | ||||||||||||||||||||||||||||
| 123 | 0 | ▶ | my ($self, $id, $br, $textarea_opts_hr) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_tags_form_textarea: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | $self->{'tags'}->put( | ||||||||||||||||||||||||||||
| 126 | ['b', 'label'], | ||||||||||||||||||||||||||||
| 127 | ['a', 'for', $id], | ||||||||||||||||||||||||||||
| 128 | ['d', $self->{'lang'}->{$id}.':'], | ||||||||||||||||||||||||||||
| 129 | ['e', 'label'], | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | ['b', 'br'], | ||||||||||||||||||||||||||||
| 132 | ['e', 'br'], | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | ['b', 'textarea'], | ||||||||||||||||||||||||||||
| 135 | ['a', 'id', $id], | ||||||||||||||||||||||||||||
| 136 | ['a', 'name', $id], | ||||||||||||||||||||||||||||
| 137 | exists $textarea_opts_hr->{'cols'} ? ( | ||||||||||||||||||||||||||||
| 138 | ['a', 'cols', $textarea_opts_hr->{'cols'}], | ||||||||||||||||||||||||||||
| 139 | ) : (), | ||||||||||||||||||||||||||||
| 140 | exists $textarea_opts_hr->{'rows'} ? ( | ||||||||||||||||||||||||||||
| 141 | 0 | ▶ | ['a', 'rows', $textarea_opts_hr->{'rows'}], | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 142 | ) : (), | ||||||||||||||||||||||||||||
| 143 | ['e', 'textarea'], | ||||||||||||||||||||||||||||
| 144 | ); | ||||||||||||||||||||||||||||
| 145 | 0 | ▶ | if ($br) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 0 | $self->{'tags'}->put( | |||||||||||||||||||||||||||
| 147 | ['b', 'br'], | ||||||||||||||||||||||||||||
| 148 | ['e', 'br'], | ||||||||||||||||||||||||||||
| 149 | ); | ||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 0 | return; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 2 | 1; | |||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | __END__ | ||||||||||||||||||||||||||||