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
86
87
88
|
package local::menu;
require Exporter;
use CGI qw(:standard);
use strict;
use base "Exporter";
use local::user;
use config;
my %menus =
(
'download'=> [10 , 'Downloads','aktive','fertige','meine'],
# 'list?only_me=1'=>[20 , 'Meine Downloads'],
# 'list'=> [30,'Alle Downloads'],
'log'=> [50,'Protokoll'],
'search'=> [5, 'Suche', 'nzbindex.nl','NZB Datei hochladen'],
);
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->{REQUEST_URI};
$active =~ s'.*/'';
$active =~ s'\?.*'';
my $active_sub;
($active,$active_sub)= split /_/,$active;
$active_sub+=2;
my $html= CGI::start_html(-style=>{'src'=>'/style.css'},-title=>$title);
my $user = new local::user(%ENV);
$html.= table({class=>'nohigh'},Tr({class=>'nohigh'},td({style=>'font-weight: bold'},[$config::config{page_name} ]),td({class=>'login',align=>'right'},['<nobr>'.b('Angemeldet als: ').$user->get_name.'</nobr>'])));
$html.= CGI::start_div({class=>'bodydiv'});
my @elements;
foreach my $url (sort {$menus{$a}->[0] <=> $menus{$b}->[0] } keys %menus)
{
next if not $menus{$url}->[1];
if ($url eq $active)
{
push @elements,th({class=>'active'},[$menus{$url}->[1]]);
} else {
push @elements,th([a({href=>$url},$menus{$url}->[1])]);
}
}
$html.= table({class=>'menu'},
Tr({class=>'menu'},join '',@elements
),
);
my @submens;
if ($#{$menus{$active}}>1)
{
foreach my $i (2..$#{$menus{$active}})
{
if ($i == $active_sub)
{
push @submens,th({class=>'active'},[$menus{$active}->[$i]]);
} else {
if ($i > 2)
{
push @submens,th([a({href=>"${active}_".($i-2)},$menus{$active}->[$i])]);
} else {
push @submens,th([a({href=>"${active}"},$menus{$active}->[$i])]);
}
}
}
}
$html.= table({class=>'submenu'},
Tr({class=>'submenu'},join '',@submens
),
);
return $html;
}
sub end_html
{
my $self=shift;
my $html= CGI::end_div();
$html.= CGI::end_html;
return $html;
}
|