forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenu.pm
86 lines (76 loc) · 1.48 KB
/
Menu.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package WebminUI::Menu;
use WebminCore;
=head2 new WebminUI::Menu(&options, [columns])
Generates a menu of options, typically using icons.
=cut
sub new
{
my ($self, $options, $columns) = @_;
if (defined(&WebminUI::Theme::Menu::new)) {
return new WebminUI::Theme::Menu(@_[1..$#_]);
}
$self = { 'columns' => 4 };
bless($self);
$self->set_options($options);
$self->set_columns($columns) if (defined($columns));
return $self;
}
=head2 html()
Returns the HTML for the table
=cut
sub html
{
my ($self) = @_;
my (@links, @titles, @icons, @hrefs);
foreach my $o (@{$self->{'options'}}) {
push(@links, $o->{'link'});
if ($o->{'link2'}) {
push(@titles, "$o->{'title'}</a> <a href='$o->{'link2'}'>$o->{'title2'}");
}
else {
push(@titles, $o->{'title'});
}
push(@icons, $o->{'icon'});
push(@hrefs, $o->{'href'});
}
my $rv = &capture_function_output(\&icons_table,
\@links, \@titles, \@icons, $self->get_columns(),
\@hrefs);
return $rv;
}
=head2 add_option(&option)
=cut
sub add_option
{
my ($self, $option) = @_;
push(@{$self->{'options'}}, $option);
}
sub set_options
{
my ($self, $options) = @_;
$self->{'options'} = $options;
}
sub get_options
{
my ($self) = @_;
return $self->{'options'};
}
sub set_columns
{
my ($self, $columns) = @_;
$self->{'columns'} = $columns;
}
sub get_columns
{
my ($self) = @_;
return $self->{'columns'};
}
=head2 set_page(WebminUI::Page)
Called when this menu is added to a page
=cut
sub set_page
{
my ($self, $page) = @_;
$self->{'page'} = $page;
}
1;