Handle hostnames with upper-case letters
[webmin.git] / Webmin / Menu.pm
1 package Webmin::Menu;
2 use WebminCore;
3
4 =head2 new Webmin::Menu(&options, [columns])
5 Generates a menu of options, typically using icons.
6 =cut
7 sub new
8 {
9 my ($self, $options, $columns) = @_;
10 if (defined(&Webmin::Theme::Menu::new)) {
11         return new Webmin::Theme::Menu(@_[1..$#_]);
12         }
13 $self = { 'columns' => 4 };
14 bless($self);
15 $self->set_options($options);
16 $self->set_columns($columns) if (defined($columns));
17 return $self;
18 }
19
20 =head2 html()
21 Returns the HTML for the table
22 =cut
23 sub html
24 {
25 my ($self) = @_;
26 my (@links, @titles, @icons, @hrefs);
27 foreach my $o (@{$self->{'options'}}) {
28         push(@links, $o->{'link'});
29         if ($o->{'link2'}) {
30                 push(@titles, "$o->{'title'}</a> <a href='$o->{'link2'}'>$o->{'title2'}");
31                 }
32         else {
33                 push(@titles, $o->{'title'});
34                 }
35         push(@icons, $o->{'icon'});
36         push(@hrefs, $o->{'href'});
37         }
38 my $rv = &capture_function_output(\&icons_table,
39                 \@links, \@titles, \@icons, $self->get_columns(),
40                 \@hrefs);
41 return $rv;
42 }
43
44 =head2 add_option(&option)
45 =cut
46 sub add_option
47 {
48 my ($self, $option) = @_;
49 push(@{$self->{'options'}}, $option);
50 }
51
52 sub set_options
53 {
54 my ($self, $options) = @_;
55 $self->{'options'} = $options;
56 }
57
58 sub get_options
59 {
60 my ($self) = @_;
61 return $self->{'options'};
62 }
63
64 sub set_columns
65 {
66 my ($self, $columns) = @_;
67 $self->{'columns'} = $columns;
68 }
69
70 sub get_columns
71 {
72 my ($self) = @_;
73 return $self->{'columns'};
74 }
75
76 =head2 set_page(Webmin::Page)
77 Called when this menu is added to a page
78 =cut
79 sub set_page
80 {
81 my ($self, $page) = @_;
82 $self->{'page'} = $page;
83 }
84
85 1;
86