forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton.pm
61 lines (54 loc) · 1.16 KB
/
Button.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package WebminUI::Button;
use WebminUI::Input;
use WebminCore;
@ISA = ( "WebminUI::Input" );
=head2 new WebminUI::Button(cgi, label, [name])
Creates a button that when clicked will link to some other page
=cut
sub new
{
if (defined(&WebminUI::Theme::Button::new) &&
caller() !~ /WebminUI::Theme::Button/) {
return new WebminUI::Theme::Button(@_[1..$#_]);
}
my ($self, $cgi, $value, $name) = @_;
$self = { };
bless($self);
$self->set_cgi($cgi);
$self->set_value($value);
$self->set_name($name) if ($name);
return $self;
}
=head2 html()
Returns HTML for this button
=cut
sub html
{
my ($self) = @_;
my $rv = "<form action=".$self->get_cgi().">";
foreach my $h (@{$self->{'hiddens'}}) {
$rv .= &ui_hidden($h->[0], $h->[1])."\n";
}
$rv .= &ui_submit($self->get_value(), $self->get_name(),
$self->get_disabled())."</form>";
return $rv;
}
sub set_cgi
{
my ($self, $cgi) = @_;
$self->{'cgi'} = $cgi;
}
sub get_cgi
{
my ($self) = @_;
return $self->{'cgi'};
}
=head2 add_hidden(name, value)
Adds some hidden input to this button, for passing to the CGI
=cut
sub add_hidden
{
my ($self, $name, $value) = @_;
push(@{$self->{'hiddens'}}, [ $name, $value ]);
}
1;