line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# BW::XML::HTML.pm |
2
|
|
|
|
|
|
|
# Simple X/HTML output |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# by Bill Weinman - http://bw.org/ |
5
|
|
|
|
|
|
|
# Copyright (c) 1995-2010 The BearHeart Group, LLC |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# See POD for History |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package BW::XML::HTML; |
11
|
1
|
|
|
1
|
|
899
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
12
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
5
|
use BW::Constants; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
78
|
|
15
|
1
|
|
|
1
|
|
8
|
use base qw( BW::XML::Out ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
799
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = "1.5.1"; |
18
|
0
|
|
|
0
|
0
|
|
sub version { $VERSION } |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub select |
21
|
|
|
|
|
|
|
{ |
22
|
0
|
|
|
0
|
1
|
|
my ( $self, $name, $content, $attribs ) = @_; |
23
|
0
|
|
|
|
|
|
my $sn = 'select'; |
24
|
0
|
|
|
|
|
|
my $select_options = "\n"; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
foreach my $h (@$content) { |
27
|
0
|
|
|
|
|
|
my $xparms = { indentLevel => 1, attribs => [] }; |
28
|
0
|
|
0
|
|
|
|
my $text = $h->{text} || $h->{value} || ''; |
29
|
0
|
|
0
|
|
|
|
my $value = $h->{value} || ''; |
30
|
0
|
|
|
|
|
|
push( @{ $xparms->{attribs} }, { value => $value } ); |
|
0
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
push( @{ $xparms->{attribs} }, { selected => 'selected' } ) if $h->{selected}; |
|
0
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
$select_options .= $self->element( 'option', $text, $xparms ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
|
$attribs = [] unless $attribs; |
36
|
0
|
|
|
|
|
|
push @$attribs, { name => $name }; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
return $self->element( |
39
|
|
|
|
|
|
|
'select', |
40
|
|
|
|
|
|
|
$select_options, |
41
|
|
|
|
|
|
|
{ |
42
|
|
|
|
|
|
|
xmlContent => TRUE, |
43
|
|
|
|
|
|
|
attribs => $attribs |
44
|
|
|
|
|
|
|
} ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub link |
48
|
|
|
|
|
|
|
{ |
49
|
0
|
|
|
0
|
1
|
|
my ( $self, $uri, $text, $attribs ) = @_; |
50
|
0
|
|
|
|
|
|
my $sn = 'link'; |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
$text = '' unless $text; |
53
|
0
|
0
|
|
|
|
|
$attribs = [] unless $attribs; |
54
|
0
|
|
|
|
|
|
push @$attribs, { href => $uri }; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return $self->element( 'a', $text, { attribs => $attribs, noNewline => TRUE, xmlContent => TRUE, } ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub input |
60
|
|
|
|
|
|
|
{ |
61
|
0
|
|
|
0
|
1
|
|
my ( $self, $type, $name, $value, $attribs ) = @_; |
62
|
0
|
|
|
|
|
|
my $sn = 'input'; |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
$type = 'text' unless $type; |
65
|
0
|
0
|
|
|
|
|
$name = '' unless $name; |
66
|
0
|
0
|
|
|
|
|
$value = '' unless $value; |
67
|
0
|
0
|
|
|
|
|
$attribs = [] unless $attribs; |
68
|
0
|
|
|
|
|
|
push @$attribs, { type => $type }; |
69
|
0
|
|
|
|
|
|
push @$attribs, { name => $name }; |
70
|
0
|
|
|
|
|
|
push @$attribs, { value => $value }; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return $self->element( 'input', undef, { attribs => $attribs, noNewline => TRUE, emptyTag => TRUE } ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub hidden |
76
|
|
|
|
|
|
|
{ |
77
|
0
|
|
|
0
|
1
|
|
my ( $self, $name, $value, $attribs ) = @_; |
78
|
0
|
|
|
|
|
|
my $sn = 'hidden'; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
return $self->input( 'hidden', $name, $value, $attribs ); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub submit |
84
|
|
|
|
|
|
|
{ |
85
|
0
|
|
|
0
|
1
|
|
my ( $self, $name, $value, $attribs ) = @_; |
86
|
0
|
|
|
|
|
|
my $sn = 'submit'; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
return $self->input( 'submit', $name, $value, $attribs ); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |