summaryrefslogtreecommitdiff
path: root/local/menu.pm
blob: 3d8d73cd445a920254ad523ed081214fd8fc32b0 (plain) (blame)
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
package local::menu;
require Exporter;
use CGI qw(:standard);
use strict;
use base "Exporter";

my %menus =
(
      '/cgi-bin/nzbget/groups.pl'=>'Aktive Downloads',
      '/cgi-bin/nzbget/mydl.pl?only_me=1'=>'My Downloads',
      '/cgi-bin/nzbget/mydl.pl'=>'All Downloads',
      '/cgi-bin/nzbget/log.pl'=>'Log',
      '/cgi-bin/nzbget/search.pl'=>'Suche',
  
);

sub new
{
  my $invocant = shift;
  my $class = ref($invocant) || $invocant;
  # my $self  = $class->SUPER::new(@_);
  my $self=bless {@_}, $class;
  return $self;
}

sub start_html
{
  my $self=shift;
  my ($title)=@_;
  my $active = $self->{SCRIPT_NAME};
  my $html= CGI::start_html(-style=>{'src'=>'/style.css'},-title=>$title);
  my @elements;
  foreach my $url (keys %menus)
  {
    if ($url eq $active)
    {
      push @elements,td([$menus{$url}]);
    } else {
      push @elements,th([a({href=>$url},$menus{$url})]);
    }
  }
  $html.= table(
    Tr(join '',@elements
        ),
  );

  return $html;
}

sub end_html
{
  my $self=shift;
  my $html= CGI::end_html;
  return $html;
}