Revision 4a12c839
Von Sven Schöling vor etwa 12 Jahren hinzugefügt
SL/Controller/Layout.pm | ||
---|---|---|
1 |
package SL::Controller::Layout; |
|
2 |
|
|
3 |
use strict; |
|
4 |
use parent qw(SL::Controller::Base); |
|
5 |
|
|
6 |
use SL::Menu; |
|
7 |
use SL::Controller::Layout::Classic; |
|
8 |
use SL::Controller::Layout::V3; |
|
9 |
use SL::Controller::Layout::V4; |
|
10 |
use SL::Controller::Layout::Javascript; |
|
11 |
|
|
12 |
my %menu_cache; |
|
13 |
|
|
14 |
sub new { |
|
15 |
my ($class, %params) = @_; |
|
16 |
|
|
17 |
return SL::Controller::Layout::Classic->new if $params{style} eq 'old'; |
|
18 |
return SL::Controller::Layout::V3->new if $params{style} eq 'v3'; |
|
19 |
return SL::Controller::Layout::V4->new if $params{style} eq 'v4'; |
|
20 |
return SL::Controller::Layout::Javascript->new if $params{style} eq 'neu'; |
|
21 |
return SL::Controller::Layout::None->new; |
|
22 |
} |
|
23 |
|
|
24 |
1; |
SL/Controller/Layout/Base.pm | ||
---|---|---|
1 |
package SL::Controller::Layout::Base; |
|
2 |
|
|
3 |
use strict; |
|
4 |
use parent qw(SL::Controller::Base); |
|
5 |
|
|
6 |
use Rose::Object::MakeMethods::Generic ( |
|
7 |
'scalar --get_set_init' => qw(menu), |
|
8 |
); |
|
9 |
|
|
10 |
use SL::Menu; |
|
11 |
|
|
12 |
my %menu_cache; |
|
13 |
|
|
14 |
sub new { |
|
15 |
my ($class, @slurp) = @_; |
|
16 |
|
|
17 |
my $self = $class->SUPER::new(@slurp); |
|
18 |
} |
|
19 |
|
|
20 |
sub init_menu { |
|
21 |
Menu->new('menu.ini'); |
|
22 |
} |
|
23 |
|
|
24 |
sub pre_content { |
|
25 |
} |
|
26 |
|
|
27 |
sub start_content { |
|
28 |
} |
|
29 |
|
|
30 |
sub end_content { |
|
31 |
} |
|
32 |
|
|
33 |
sub post_content { |
|
34 |
} |
|
35 |
|
|
36 |
sub stylesheets { |
|
37 |
} |
|
38 |
|
|
39 |
sub stylesheets_inline { |
|
40 |
} |
|
41 |
|
|
42 |
sub javascript_inline { |
|
43 |
} |
|
44 |
|
|
45 |
1; |
SL/Controller/Layout/Classic.pm | ||
---|---|---|
1 |
package SL::Controller::Layout::Classic; |
|
2 |
|
|
3 |
use strict; |
|
4 |
use parent qw(SL::Controller::Layout::Base); |
|
5 |
|
|
6 |
use SL::Controller::Layout::Top; |
|
7 |
use SL::Controller::Layout::MenuLeft; |
|
8 |
|
|
9 |
sub new { |
|
10 |
my ($class, @slurp) = @_; |
|
11 |
|
|
12 |
my $self = $class->SUPER::new(@slurp); |
|
13 |
|
|
14 |
$self->{top} = SL::Controller::Layout::Top->new; |
|
15 |
$self->{left} = SL::Controller::Layout::MenuLeft->new; |
|
16 |
|
|
17 |
$self; |
|
18 |
} |
|
19 |
|
|
20 |
sub pre_content { |
|
21 |
$_[0]{top}->render . |
|
22 |
$_[0]{left}->render; |
|
23 |
} |
|
24 |
|
|
25 |
sub start_content { |
|
26 |
"<div id='content' class='html-menu'>\n"; |
|
27 |
} |
|
28 |
|
|
29 |
sub end_content { |
|
30 |
"</div>\n"; |
|
31 |
} |
|
32 |
|
|
33 |
sub stylesheets { |
|
34 |
$_[0]{top}->stylesheets, |
|
35 |
$_[0]{left}->stylesheets; |
|
36 |
} |
|
37 |
|
|
38 |
sub javascripts { |
|
39 |
$_[0]{top}->javascripts, |
|
40 |
$_[0]{left}->javascripts; |
|
41 |
} |
|
42 |
|
|
43 |
1; |
SL/Controller/Layout/Css.pm | ||
---|---|---|
1 |
package SL::Controller::Layout::Css; |
|
2 |
|
|
3 |
use List::Util qw(max); |
|
4 |
use Exporter qw(import); |
|
5 |
|
|
6 |
our @EXPORT = qw(clock_line print_menu menuitem_v3); |
|
7 |
|
|
8 |
sub clock_line { |
|
9 |
my ($Sekunden, $Minuten, $Stunden, $Monatstag, $Monat, |
|
10 |
$Jahr, $Wochentag, $Jahrestag, $Sommerzeit) |
|
11 |
= localtime(time); |
|
12 |
$Monat += 1; |
|
13 |
$Jahrestag += 1; |
|
14 |
$Monat = $Monat < 10 ? $Monat = "0" . $Monat : $Monat; |
|
15 |
$Monatstag = $Monatstag < 10 ? $Monatstag = "0" . $Monatstag : $Monatstag; |
|
16 |
$Jahr += 1900; |
|
17 |
my @Wochentage = ("Sonntag", "Montag", "Dienstag", "Mittwoch", |
|
18 |
"Donnerstag", "Freitag", "Samstag"); |
|
19 |
my @Monatsnamen = ("", "Januar", "Februar", "März", |
|
20 |
"April", "Mai", "Juni", "Juli", |
|
21 |
"August", "September", "Oktober", "November", |
|
22 |
"Dezember"); |
|
23 |
return |
|
24 |
$Wochentage[$Wochentag] . ", der " |
|
25 |
. $Monatstag . "." |
|
26 |
. $Monat . "." |
|
27 |
. $Jahr . " - "; |
|
28 |
} |
|
29 |
|
|
30 |
sub print_menu { |
|
31 |
my ($self, $parent, $depth) = @_; |
|
32 |
|
|
33 |
my $html; |
|
34 |
|
|
35 |
die if ($depth * 1 > 5); |
|
36 |
|
|
37 |
my @menuorder; |
|
38 |
my $menu = $self->menu; |
|
39 |
|
|
40 |
@menuorder = $menu->access_control(\%::myconfig, $parent); |
|
41 |
|
|
42 |
$parent .= "--" if ($parent); |
|
43 |
|
|
44 |
foreach my $item (@menuorder) { |
|
45 |
substr($item, 0, length($parent)) = ""; |
|
46 |
next if (($item eq "") || ($item =~ /--/)); |
|
47 |
|
|
48 |
my $menu_item = $menu->{"${parent}${item}"}; |
|
49 |
my $menu_title = $::locale->text($item); |
|
50 |
my $menu_text = $menu_title; |
|
51 |
|
|
52 |
if ($menu_item->{"submenu"} || !defined($menu_item->{"module"}) || |
|
53 |
($menu_item->{"module"} eq "menu.pl")) { |
|
54 |
|
|
55 |
my $h = $self->print_menu("${parent}${item}", $depth * 1 + 1)."\n"; |
|
56 |
if (!$parent) { |
|
57 |
$html .= qq|<ul><li><h2>${menu_text}</h2><ul>${h}</ul></li></ul>\n|; |
|
58 |
} else { |
|
59 |
$html .= qq|<li><div class="x">${menu_text}</div><ul>${h}</ul></li>\n|; |
|
60 |
} |
|
61 |
} else { |
|
62 |
if ($self->{sub_class} && $depth > 1) { |
|
63 |
$html .= qq|<li class='sub'>|; |
|
64 |
} else { |
|
65 |
$html .= qq|<li>|; |
|
66 |
} |
|
67 |
$html .= $self->menuitem_v3("${parent}$item", { "title" => $menu_title }); |
|
68 |
$html .= qq|${menu_text}</a></li>\n|; |
|
69 |
} |
|
70 |
} |
|
71 |
|
|
72 |
return $html; |
|
73 |
} |
|
74 |
|
|
75 |
sub menuitem_v3 { |
|
76 |
$main::lxdebug->enter_sub(); |
|
77 |
|
|
78 |
my ($self, $item, $other) = @_; |
|
79 |
my $menuitem = $self->menu->{$item}; |
|
80 |
|
|
81 |
my $action = "section_menu"; |
|
82 |
my $module; |
|
83 |
|
|
84 |
if ($menuitem->{module}) { |
|
85 |
$module = $menuitem->{module}; |
|
86 |
} |
|
87 |
if ($menuitem->{action}) { |
|
88 |
$action = $menuitem->{action}; |
|
89 |
} |
|
90 |
|
|
91 |
my $level = $::form->escape($item); |
|
92 |
|
|
93 |
my $str = qq|<a href="$module?action=| . $::form->escape($action) . qq|&level=| . $::form->escape($level); |
|
94 |
|
|
95 |
my @vars = qw(module action target href); |
|
96 |
|
|
97 |
if ($menuitem->{href}) { |
|
98 |
$str = qq|<a href=$menuitem->{href}|; |
|
99 |
@vars = qw(module target href); |
|
100 |
} |
|
101 |
|
|
102 |
map { delete $menuitem->{$_} } @vars; |
|
103 |
|
|
104 |
# add other params |
|
105 |
foreach my $key (keys %{ $menuitem }) { |
|
106 |
$str .= "&" . $::form->escape($key, 1) . "="; |
|
107 |
my ($value, $conf) = split(/=/, $menuitem->{$key}, 2); |
|
108 |
$value = $::myconfig{$value} . "/$conf" if ($conf); |
|
109 |
$str .= $::form->escape($value, 1); |
|
110 |
} |
|
111 |
|
|
112 |
$str .= '"'; |
|
113 |
|
|
114 |
if ($other) { |
|
115 |
foreach my $key (keys(%{$other})) { |
|
116 |
$str .= qq| ${key}="| . $::form->quote($other->{$key}) . qq|"|; |
|
117 |
} |
|
118 |
} |
|
119 |
|
|
120 |
$str .= ">"; |
|
121 |
|
|
122 |
$main::lxdebug->leave_sub(); |
|
123 |
|
|
124 |
return $str; |
|
125 |
} |
|
126 |
|
|
127 |
1; |
SL/Controller/Layout/Javascript.pm | ||
---|---|---|
1 |
package SL::Controller::Layout::Javascript; |
|
2 |
|
|
3 |
use strict; |
|
4 |
use parent qw(SL::Controller::Layout::Base); |
|
5 |
|
|
6 |
use List::Util qw(max); |
|
7 |
use URI; |
|
8 |
|
|
9 |
sub pre_content { |
|
10 |
&display |
|
11 |
} |
|
12 |
|
|
13 |
sub start_content { |
|
14 |
"<div id='content'>\n"; |
|
15 |
} |
|
16 |
|
|
17 |
sub end_content { |
|
18 |
"</div>\n"; |
|
19 |
} |
|
20 |
|
|
21 |
sub display { |
|
22 |
my ($self) = @_; |
|
23 |
my $form = $main::form; |
|
24 |
|
|
25 |
my $callback = $form->unescape($form->{callback}); |
|
26 |
$callback = URI->new($callback)->rel($callback) if $callback; |
|
27 |
$callback = "login.pl?action=company_logo" if $callback =~ /^(\.\/)?$/; |
|
28 |
|
|
29 |
$form->parse_html_template("menu/menunew", { |
|
30 |
# $self->render("menu/menunew", { no_menu => 1, no_output => 1 }, # buggy, no idea why |
|
31 |
force_ul_width => 1, |
|
32 |
date => $self->clock_line, |
|
33 |
menu_items => $self->acc_menu, |
|
34 |
callback => $callback, |
|
35 |
}); |
|
36 |
} |
|
37 |
|
|
38 |
sub clock_line { |
|
39 |
my $form = $main::form; |
|
40 |
|
|
41 |
my ($Sekunden, $Minuten, $Stunden, $Monatstag, $Monat, |
|
42 |
$Jahr, $Wochentag, $Jahrestag, $Sommerzeit) |
|
43 |
= localtime(time); |
|
44 |
$Monat += 1; |
|
45 |
$Jahrestag += 1; |
|
46 |
$Monat = $Monat < 10 ? $Monat = "0" . $Monat : $Monat; |
|
47 |
$Monatstag = $Monatstag < 10 ? $Monatstag = "0" . $Monatstag : $Monatstag; |
|
48 |
$Jahr += 1900; |
|
49 |
my @Wochentage = ("Sonntag", "Montag", "Dienstag", "Mittwoch", |
|
50 |
"Donnerstag", "Freitag", "Samstag"); |
|
51 |
my @Monatsnamen = ("", "Januar", "Februar", "März", |
|
52 |
"April", "Mai", "Juni", "Juli", |
|
53 |
"August", "September", "Oktober", "November", |
|
54 |
"Dezember"); |
|
55 |
return |
|
56 |
$Wochentage[$Wochentag] . ", der " |
|
57 |
. $Monatstag . "." |
|
58 |
. $Monat . "." |
|
59 |
. $Jahr . " - "; |
|
60 |
} |
|
61 |
|
|
62 |
sub acc_menu { |
|
63 |
my ($self) = @_; |
|
64 |
|
|
65 |
my $menu = $self->menu; |
|
66 |
|
|
67 |
my $all_items = []; |
|
68 |
$self->create_menu($menu, $all_items); |
|
69 |
|
|
70 |
my $item = { 'subitems' => $all_items }; |
|
71 |
calculate_width($item); |
|
72 |
|
|
73 |
return $all_items; |
|
74 |
} |
|
75 |
|
|
76 |
sub calculate_width { |
|
77 |
my $item = shift; |
|
78 |
|
|
79 |
$item->{max_width} = max map { length $_->{title} } @{ $item->{subitems} }; |
|
80 |
|
|
81 |
foreach my $subitem (@{ $item->{subitems} }) { |
|
82 |
calculate_width($subitem) if ($subitem->{subitems}); |
|
83 |
} |
|
84 |
} |
|
85 |
|
|
86 |
sub create_menu { |
|
87 |
my ($self, $menu, $all_items, $parent, $depth) = @_; |
|
88 |
my $html; |
|
89 |
|
|
90 |
my $form = $main::form; |
|
91 |
my %myconfig = %main::myconfig; |
|
92 |
|
|
93 |
die if ($depth * 1 > 5); |
|
94 |
|
|
95 |
my @menuorder = $menu->access_control(\%myconfig, $parent); |
|
96 |
$parent .= "--" if ($parent); |
|
97 |
|
|
98 |
foreach my $name (@menuorder) { |
|
99 |
substr($name, 0, length($parent), ""); |
|
100 |
next if (($name eq "") || ($name =~ /--/)); |
|
101 |
|
|
102 |
my $menu_item = $menu->{"${parent}${name}"}; |
|
103 |
my $item = { 'title' => $::locale->text($name) }; |
|
104 |
push @{ $all_items }, $item; |
|
105 |
|
|
106 |
if ($menu_item->{submenu} || !defined($menu_item->{module}) || ($menu_item->{module} eq "menu.pl")) { |
|
107 |
$item->{subitems} = []; |
|
108 |
$item->{image} = _icon_path("$name.png"); |
|
109 |
$self->create_menu($menu, $item->{subitems}, "${parent}${name}", $depth * 1 + 1); |
|
110 |
|
|
111 |
} else { |
|
112 |
$item->{image} = _icon_path("${parent}${name}.png"); |
|
113 |
$menu->menuitem_new("${parent}${name}", $item); |
|
114 |
} |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
sub _icon_path { |
|
119 |
my ($label, $size) = @_; |
|
120 |
|
|
121 |
$size ||= 16; |
|
122 |
|
|
123 |
my $img = "image/icons/${size}x${size}/$label"; |
|
124 |
|
|
125 |
return unless -f $img; |
|
126 |
return $img; |
|
127 |
} |
|
128 |
|
|
129 |
1; |
SL/Controller/Layout/MenuLeft.pm | ||
---|---|---|
1 |
package SL::Controller::Layout::MenuLeft; |
|
2 |
|
|
3 |
use strict; |
|
4 |
use parent qw(SL::Controller::Layout::Base); |
|
5 |
|
|
6 |
use URI; |
|
7 |
|
|
8 |
use List::MoreUtils qw(apply); |
|
9 |
|
|
10 |
sub stylesheets { |
|
11 |
qw(css/icons16.css css/icons24.css); |
|
12 |
} |
|
13 |
|
|
14 |
sub render { |
|
15 |
my ($self) = @_; |
|
16 |
my $sections = [ section_menu($self->menu) ]; |
|
17 |
|
|
18 |
$self->SUPER::render('menu/menu', { no_menu => 1, no_output => 1 }, |
|
19 |
sections => $sections, |
|
20 |
); |
|
21 |
} |
|
22 |
|
|
23 |
sub section_menu { |
|
24 |
$::lxdebug->enter_sub(2); |
|
25 |
my ($menu, $level, $id_prefix) = @_; |
|
26 |
my @menuorder = $menu->access_control(\%::myconfig, $level); |
|
27 |
my @items; |
|
28 |
|
|
29 |
my $id = 0; |
|
30 |
|
|
31 |
for my $item (@menuorder) { |
|
32 |
my $menuitem = $menu->{$item}; |
|
33 |
my $olabel = apply { s/.*--// } $item; |
|
34 |
my $ml = apply { s/--.*// } $item; |
|
35 |
my $icon_class = apply { y/ /-/ } $item; |
|
36 |
my $spacer = "s" . (0 + $item =~ s/--/--/g); |
|
37 |
|
|
38 |
next if $level && $item ne "$level--$olabel"; |
|
39 |
|
|
40 |
my $label = $::locale->text($olabel); |
|
41 |
|
|
42 |
$menuitem->{module} ||= $::form->{script}; |
|
43 |
$menuitem->{action} ||= "section_menu"; |
|
44 |
$menuitem->{href} ||= "$menuitem->{module}?action=$menuitem->{action}"; |
|
45 |
|
|
46 |
# add other params |
|
47 |
foreach my $key (keys %$menuitem) { |
|
48 |
next if $key =~ /target|module|action|href/; |
|
49 |
$menuitem->{href} .= "&" . $::form->escape($key, 1) . "="; |
|
50 |
my ($value, $conf) = split(/=/, $menuitem->{$key}, 2); |
|
51 |
$value = $::myconfig{$value} . "/$conf" if ($conf); |
|
52 |
$menuitem->{href} .= $::form->escape($value, 1); |
|
53 |
} |
|
54 |
|
|
55 |
my $anchor = $menuitem->{href}; |
|
56 |
|
|
57 |
my %common_args = ( |
|
58 |
l => $label, |
|
59 |
s => $spacer, |
|
60 |
id => "$id_prefix\_$id", |
|
61 |
); |
|
62 |
|
|
63 |
if (!$level) { # toplevel |
|
64 |
push @items, { %common_args, |
|
65 |
i => "icon24 $icon_class", # make_image(size => 24, label => $item), |
|
66 |
c => 'm', |
|
67 |
}; |
|
68 |
push @items, section_menu($menu, $item, "$id_prefix\_$id"); |
|
69 |
} elsif ($menuitem->{submenu}) { |
|
70 |
push @items, { %common_args, |
|
71 |
i => "icon16 submenu", #make_image(label => 'submenu'), |
|
72 |
c => 'sm', |
|
73 |
}; |
|
74 |
push @items, section_menu($menu, $item, "$id_prefix\_$id"); |
|
75 |
} elsif ($menuitem->{module}) { |
|
76 |
push @items, { %common_args, |
|
77 |
i => "icon16 $icon_class", #make_image(size => 16, label => $item), |
|
78 |
h => $anchor, |
|
79 |
c => 'i', |
|
80 |
}; |
|
81 |
} |
|
82 |
} continue { |
|
83 |
$id++; |
|
84 |
} |
|
85 |
|
|
86 |
$::lxdebug->leave_sub(2); |
|
87 |
return @items; |
|
88 |
} |
|
89 |
|
|
90 |
sub _calc_framesize { |
|
91 |
my $is_lynx_browser = $ENV{HTTP_USER_AGENT} =~ /links/i; |
|
92 |
my $is_mobile_browser = $ENV{HTTP_USER_AGENT} =~ /mobile/i; |
|
93 |
my $is_mobile_style = $::form->{stylesheet} =~ /mobile/i; |
|
94 |
|
|
95 |
return $is_mobile_browser && $is_mobile_style ? 130 |
|
96 |
: $is_lynx_browser ? 240 |
|
97 |
: 200; |
|
98 |
} |
|
99 |
|
|
100 |
sub _show_images { |
|
101 |
# don't show images in links |
|
102 |
_calc_framesize() != 240; |
|
103 |
} |
|
104 |
|
|
105 |
1; |
SL/Controller/Layout/None.pm | ||
---|---|---|
1 |
package SL::Controller::Layout::None; |
|
2 |
|
|
3 |
use strict; |
|
4 |
use parent qw(SL::Controller::Layout::Base); |
|
5 |
|
|
6 |
1; |
SL/Controller/Layout/Top.pm | ||
---|---|---|
1 |
package SL::Controller::Layout::Top; |
|
2 |
|
|
3 |
use strict; |
|
4 |
use parent qw(SL::Controller::Layout::Base); |
|
5 |
|
|
6 |
sub render { |
|
7 |
my ($self) = @_; |
|
8 |
|
|
9 |
$self->SUPER::render('menu/header', { partial => 1, no_output => 1 }, |
|
10 |
now => DateTime->now_local, |
|
11 |
is_fastcgi => scalar($::dispatcher->interface_type =~ /fastcgi/i), |
|
12 |
is_links => scalar($ENV{HTTP_USER_AGENT} =~ /links/i)); |
|
13 |
} |
|
14 |
|
|
15 |
sub stylesheets { |
|
16 |
# 'frame_header/header.css'; |
|
17 |
} |
|
18 |
|
|
19 |
1; |
SL/Controller/Layout/V3.pm | ||
---|---|---|
1 |
package SL::Controller::Layout::V3; |
|
2 |
|
|
3 |
use strict; |
|
4 |
use parent qw(SL::Controller::Layout::Base); |
|
5 |
use SL::Controller::Layout::Css; |
|
6 |
|
|
7 |
use URI; |
|
8 |
|
|
9 |
sub pre_content { |
|
10 |
&render; |
|
11 |
} |
|
12 |
|
|
13 |
sub start_content { |
|
14 |
"<div id='content'>\n"; |
|
15 |
} |
|
16 |
|
|
17 |
sub end_content { |
|
18 |
"</div>\n"; |
|
19 |
} |
|
20 |
|
|
21 |
sub render { |
|
22 |
my ($self) = @_; |
|
23 |
|
|
24 |
my $callback = $::form->unescape($::form->{callback}); |
|
25 |
$callback = URI->new($callback)->rel($callback) if $callback; |
|
26 |
$callback = "login.pl?action=company_logo" if $callback =~ /^(\.\/)?$/; |
|
27 |
|
|
28 |
$self->SUPER::render('menu/menuv3', { no_menu => 1, no_output => 1 }, |
|
29 |
force_ul_width => 1, |
|
30 |
date => $self->clock_line, |
|
31 |
menu => $self->print_menu, |
|
32 |
callback => $callback, |
|
33 |
); |
|
34 |
} |
|
35 |
|
|
36 |
1; |
SL/Controller/Layout/V4.pm | ||
---|---|---|
1 |
package SL::Controller::Layout::V4; |
|
2 |
|
|
3 |
use strict; |
|
4 |
use parent qw(SL::Controller::Layout::Base); |
|
5 |
use SL::Controller::Layout::Css; |
|
6 |
use SL::Controller::Layout::Top; |
|
7 |
|
|
8 |
use URI; |
|
9 |
|
|
10 |
sub new { |
|
11 |
my ($class, @slurp) = @_; |
|
12 |
|
|
13 |
my $self = $class->SUPER::new(@slurp); |
|
14 |
$self->{top} = SL::Controller::Layout::Top->new; |
|
15 |
$self; |
|
16 |
} |
|
17 |
|
|
18 |
sub pre_content { |
|
19 |
$_[0]{top}->render . |
|
20 |
&render; |
|
21 |
} |
|
22 |
|
|
23 |
sub stylesheets { |
|
24 |
$_[0]{top}->stylesheets |
|
25 |
} |
|
26 |
|
|
27 |
sub start_content { |
|
28 |
"<div id='content'>\n"; |
|
29 |
} |
|
30 |
|
|
31 |
sub end_content { |
|
32 |
"</div>\n"; |
|
33 |
} |
|
34 |
|
|
35 |
sub render { |
|
36 |
my ($self) = @_; |
|
37 |
|
|
38 |
$self->{sub_class} = 1; |
|
39 |
|
|
40 |
my $callback = $::form->unescape($::form->{callback}); |
|
41 |
$callback = URI->new($callback)->rel($callback) if $callback; |
|
42 |
$callback = "login.pl?action=company_logo" if $callback =~ /^(\.\/)?$/; |
|
43 |
|
|
44 |
$self->SUPER::render('menu/menuv4', { no_menu => 1, no_output => 1 }, |
|
45 |
force_ul_width => 1, |
|
46 |
date => $self->clock_line, |
|
47 |
menu => $self->print_menu, |
|
48 |
callback => $callback, |
|
49 |
); |
|
50 |
} |
|
51 |
|
|
52 |
1; |
SL/Controller/LoginScreen.pm | ||
---|---|---|
38 | 38 |
$::form->{login} = $::myconfig{login}; |
39 | 39 |
$::locale = Locale->new($::myconfig{countrycode}) if $::myconfig{countrycode}; |
40 | 40 |
my $user = User->new(login => $::myconfig{login}); |
41 |
$::request->{layout} = SL::Controller::Layout->new(style => $user->{menustyle}); |
|
41 | 42 |
|
42 | 43 |
# if we get an error back, bale out |
43 | 44 |
my $result = $user->login($::form); |
SL/Dispatcher.pm | ||
---|---|---|
35 | 35 |
use SL::Helper::DateTime; |
36 | 36 |
use SL::InstanceConfiguration; |
37 | 37 |
use SL::Template::Plugin::HTMLFixes; |
38 |
use SL::Controller::Layout::None; |
|
38 | 39 |
|
39 | 40 |
# Trailing new line is added so that Perl will not add the line |
40 | 41 |
# number 'die' was called in. |
... | ... | |
181 | 182 |
$::locale = Locale->new($::lx_office_conf{system}->{language}); |
182 | 183 |
$::form = Form->new; |
183 | 184 |
$::instance_conf = SL::InstanceConfiguration->new; |
184 |
$::request = { cgi => CGI->new({}) }; |
|
185 |
$::request = { |
|
186 |
cgi => CGI->new({}), |
|
187 |
layout => SL::Controller::Layout::None->new, |
|
188 |
}; |
|
185 | 189 |
|
186 | 190 |
my $session_result = $::auth->restore_session; |
187 | 191 |
$::auth->create_or_refresh_session; |
SL/Dispatcher/AuthHandler.pm | ||
---|---|---|
1 |
package SL::Dispatcher::AuthHandler; |
|
1 |
package SL::Dispatcher::AuthHandler;
|
|
2 | 2 |
|
3 | 3 |
use strict; |
4 | 4 |
|
... | ... | |
14 | 14 |
my ($self, %param) = @_; |
15 | 15 |
|
16 | 16 |
my $auth_level = $self->get_auth_level(%param); |
17 |
|
|
17 | 18 |
my $handler_name = "SL::Dispatcher::AuthHandler::" . ucfirst($auth_level); |
18 | 19 |
$self->{handlers} ||= {}; |
19 | 20 |
$self->{handlers}->{$handler_name} ||= $handler_name->new; |
SL/Dispatcher/AuthHandler/Admin.pm | ||
---|---|---|
1 | 1 |
package SL::Dispatcher::AuthHandler::Admin; |
2 | 2 |
|
3 | 3 |
use strict; |
4 |
|
|
5 | 4 |
use parent qw(Rose::Object); |
6 | 5 |
|
6 |
use SL::Controller::Layout; |
|
7 |
|
|
7 | 8 |
sub handle { |
8 | 9 |
%::myconfig = (); |
9 | 10 |
|
10 | 11 |
return if $::form->{'{AUTH}admin_password'} && ($::auth->authenticate_root($::form->{'{AUTH}admin_password'}) == $::auth->OK()); |
11 | 12 |
return if !$::form->{'{AUTH}admin_password'} && ($::auth->authenticate_root($::auth->get_session_value('admin_password')) == $::auth->OK()); |
12 | 13 |
|
14 |
$::request->{layout} = SL::Controller::Layout->new(style => 'admin'); |
|
15 |
|
|
13 | 16 |
$::auth->punish_wrong_login; |
14 | 17 |
$::auth->delete_session_value('admin_password'); |
15 | 18 |
SL::Dispatcher::show_error('admin/adminlogin', 'password'); |
SL/Dispatcher/AuthHandler/User.pm | ||
---|---|---|
1 | 1 |
package SL::Dispatcher::AuthHandler::User; |
2 | 2 |
|
3 | 3 |
use strict; |
4 |
|
|
5 | 4 |
use parent qw(Rose::Object); |
6 | 5 |
|
6 |
use SL::Controller::Layout; |
|
7 |
|
|
7 | 8 |
sub handle { |
8 | 9 |
my ($self, %param) = @_; |
9 | 10 |
|
... | ... | |
15 | 16 |
$self->_error(%param) unless $::myconfig{login}; |
16 | 17 |
|
17 | 18 |
$::locale = Locale->new($::myconfig{countrycode}); |
19 |
$::request->{layout} = SL::Controller::Layout->new(style => $::myconfig{menustyle}); |
|
18 | 20 |
|
19 | 21 |
my $ok = $::form->{'{AUTH}login'} && (SL::Auth::OK() == $::auth->authenticate($::myconfig{login}, $::form->{'{AUTH}password'})); |
20 | 22 |
$ok ||= !$::form->{'{AUTH}login'} && (SL::Auth::OK() == $::auth->authenticate($::myconfig{login}, undef)); |
SL/Form.pm | ||
---|---|---|
451 | 451 |
my $self = shift; |
452 | 452 |
|
453 | 453 |
$self->{stylesheet} = [ $self->{stylesheet} ] unless ref $self->{stylesheet} eq 'ARRAY'; |
454 |
$self->{stylesheet} = [ grep { -f } |
|
455 |
map { m:^css/: ? $_ : "css/$_" } |
|
456 |
grep { $_ } |
|
457 |
(@{ $self->{stylesheet} }, @_) |
|
458 |
]; |
|
454 |
|
|
455 |
if (@_) { |
|
456 |
$self->{stylesheet} = |
|
457 |
[ grep { -f } |
|
458 |
map { m:^css/: ? $_ : "css/$_" } |
|
459 |
grep { $_ } |
|
460 |
(@{ $self->{stylesheet} }, @_) |
|
461 |
]; |
|
462 |
} |
|
459 | 463 |
|
460 | 464 |
return @{ $self->{stylesheet} }; |
461 | 465 |
} |
... | ... | |
489 | 493 |
|
490 | 494 |
$::lxdebug->leave_sub and return if !$ENV{HTTP_USER_AGENT} || $self->{header}++; |
491 | 495 |
|
492 |
my $layout; |
|
493 |
$layout = $self->layout unless $params{no_menu}; |
|
494 |
|
|
495 | 496 |
my $css_path = $self->get_stylesheet_for_user; |
496 | 497 |
|
497 | 498 |
$self->{favicon} ||= "favicon.ico"; |
498 |
$self->{titlebar} = "$self->{title} - $self->{titlebar}" if $self->{title};
|
|
499 |
$self->{titlebar} = join ' - ', grep $_, $self->{title}, $self->{login}, $::myconfig{dbname}, $self->{version} if $self->{title};
|
|
499 | 500 |
|
500 | 501 |
# build includes |
501 | 502 |
if ($self->{refresh_url} || $self->{refresh_time}) { |
... | ... | |
504 | 505 |
push @header, "<meta http-equiv='refresh' content='$refresh_time;$refresh_url'>"; |
505 | 506 |
} |
506 | 507 |
|
507 |
push @header, map { qq|<link rel="stylesheet" href="$_" type="text/css" title="Stylesheet">| } $self->use_stylesheet; |
|
508 |
push @header, map { qq|<link rel="stylesheet" href="$_" type="text/css" title="Stylesheet">| } $self->use_stylesheet, $::request->{layout}->stylesheets;
|
|
508 | 509 |
|
509 | 510 |
push @header, "<style type='text/css'>\@page { size:landscape; }</style>" if $self->{landscape}; |
510 | 511 |
push @header, "<link rel='shortcut icon' href='$self->{favicon}' type='image/x-icon'>" if -f $self->{favicon}; |
... | ... | |
516 | 517 |
push @header, map { qq|<link rel="stylesheet" type="text/css" href="js/jscalendar/calendar-win2k-1.css">| } |
517 | 518 |
push @header, map { $_->show_javascript } @{ $self->{AJAX} || [] }; |
518 | 519 |
push @header, "<script type='text/javascript'>function fokus(){ document.$self->{fokus}.focus(); }</script>" if $self->{fokus}; |
519 |
push @header, sprintf "<script type='text/javascript'>top.document.title='%s';</script>", |
|
520 |
join ' - ', grep $_, $self->{title}, $self->{login}, $::myconfig{dbname}, $self->{version} if $self->{title}; |
|
521 | 520 |
|
522 | 521 |
my %doctypes = ( |
523 | 522 |
strict => qq|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">|, |
... | ... | |
551 | 550 |
<body> |
552 | 551 |
|
553 | 552 |
EOT |
554 |
print $layout; |
|
555 |
|
|
556 |
print "<div id='content'>\n"; |
|
553 |
print $::request->{layout}->pre_content; |
|
554 |
print $::request->{layout}->start_content; |
|
557 | 555 |
|
558 | 556 |
$::lxdebug->leave_sub; |
559 | 557 |
} |
560 | 558 |
|
559 |
sub footer { |
|
560 |
# TODO: fix abort conditions |
|
561 |
|
|
562 |
print $::request->{layout}->post_content; |
|
563 |
print "<script type='text/javascript' src='$_'></script>\n" for $::request->{layout}->javascripts; |
|
564 |
if (my @inline_scripts = $::request->{layout}->javascript_inline) { |
|
565 |
print "<script type='text/javascript'>$_</script>\n" for @inline_scripts; |
|
566 |
} |
|
567 |
|
|
568 |
print <<EOL |
|
569 |
</body> |
|
570 |
</html> |
|
571 |
EOL |
|
572 |
} |
|
573 |
|
|
561 | 574 |
sub ajax_response_header { |
562 | 575 |
$main::lxdebug->enter_sub(); |
563 | 576 |
|
SL/Menu.pm | ||
---|---|---|
58 | 58 |
return $self; |
59 | 59 |
} |
60 | 60 |
|
61 |
sub menuitem_js { |
|
62 |
my ($self, $myconfig, $form, $item) = @_; |
|
63 |
|
|
64 |
my $module = $form->{script}; |
|
65 |
my $action = "section_menu"; |
|
66 |
|
|
67 |
#if ($self->{$item}{module}) { |
|
68 |
$module = $self->{$item}{module}; |
|
69 |
|
|
70 |
#} |
|
71 |
if ($self->{$item}{action}) { |
|
72 |
$action = $self->{$item}{action}; |
|
73 |
} |
|
74 |
|
|
75 |
my $level = $form->escape($item); |
|
76 |
my $str = qq|$module?action=$action&level=$level|; |
|
77 |
my @vars = qw(module action target href); |
|
78 |
|
|
79 |
if ($self->{$item}{href}) { |
|
80 |
$str = qq|$self->{$item}{href}|; |
|
81 |
@vars = qw(module target href); |
|
82 |
} |
|
83 |
|
|
84 |
map { delete $self->{$item}{$_} } @vars; |
|
85 |
|
|
86 |
# add other params |
|
87 |
foreach my $key (keys %{ $self->{$item} }) { |
|
88 |
$str .= "&" . $form->escape($key, 1) . "="; |
|
89 |
my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2); |
|
90 |
$value = $myconfig->{$value} . "/$conf" if ($conf); |
|
91 |
$str .= $form->escape($value, 1); |
|
92 |
} |
|
93 |
|
|
94 |
$str .= " "; |
|
95 |
|
|
96 |
} |
|
97 |
|
|
98 | 61 |
sub menuitem_new { |
99 | 62 |
$main::lxdebug->enter_sub(); |
100 | 63 |
|
... | ... | |
124 | 87 |
$main::lxdebug->leave_sub(); |
125 | 88 |
} |
126 | 89 |
|
127 |
sub menuitem_v3 { |
|
128 |
$main::lxdebug->enter_sub(); |
|
129 |
|
|
130 |
my ($self, $myconfig, $form, $item, $other) = @_; |
|
131 |
|
|
132 |
my $module = $form->{script}; |
|
133 |
my $action = "section_menu"; |
|
134 |
my $target = ""; |
|
135 |
|
|
136 |
if ($self->{$item}{module}) { |
|
137 |
$module = $self->{$item}{module}; |
|
138 |
} |
|
139 |
if ($self->{$item}{action}) { |
|
140 |
$action = $self->{$item}{action}; |
|
141 |
} |
|
142 |
if ($self->{$item}{target}) { |
|
143 |
$target = $self->{$item}{target}; |
|
144 |
} |
|
145 |
|
|
146 |
my $level = $form->escape($item); |
|
147 |
|
|
148 |
my $str = qq|<a href="$module?action=| . $form->escape($action) . qq|&level=| . $form->escape($level); |
|
149 |
|
|
150 |
my @vars = qw(module action target href); |
|
151 |
|
|
152 |
if ($self->{$item}{href}) { |
|
153 |
$str = qq|<a href=$self->{$item}{href}|; |
|
154 |
@vars = qw(module target href); |
|
155 |
} |
|
156 |
|
|
157 |
map { delete $self->{$item}{$_} } @vars; |
|
158 |
|
|
159 |
# add other params |
|
160 |
foreach my $key (keys %{ $self->{$item} }) { |
|
161 |
$str .= "&" . $form->escape($key, 1) . "="; |
|
162 |
my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2); |
|
163 |
$value = $myconfig->{$value} . "/$conf" if ($conf); |
|
164 |
$str .= $form->escape($value, 1); |
|
165 |
} |
|
166 |
|
|
167 |
$str .= '"'; |
|
168 |
|
|
169 |
if ($target) { |
|
170 |
$str .= qq| target="| . $form->quote($target) . qq|"|; |
|
171 |
} |
|
172 |
|
|
173 |
if ($other) { |
|
174 |
foreach my $key (keys(%{$other})) { |
|
175 |
$str .= qq| ${key}="| . $form->quote($other->{$key}) . qq|"|; |
|
176 |
} |
|
177 |
} |
|
178 |
|
|
179 |
$str .= ">"; |
|
180 |
|
|
181 |
$main::lxdebug->leave_sub(); |
|
182 |
|
|
183 |
return $str; |
|
184 |
} |
|
185 |
|
|
186 |
sub menuitem_XML { |
|
187 |
$main::lxdebug->enter_sub(); |
|
188 |
|
|
189 |
my ($self, $myconfig, $form, $item, $other) = @_; |
|
190 |
|
|
191 |
my $module = $form->{script}; |
|
192 |
my $action = "section_menu"; |
|
193 |
my $target = ""; |
|
194 |
|
|
195 |
if ($self->{$item}{module}) { |
|
196 |
$module = $self->{$item}{module}; |
|
197 |
} |
|
198 |
if ($self->{$item}{action}) { |
|
199 |
$action = $self->{$item}{action}; |
|
200 |
} |
|
201 |
if ($self->{$item}{target}) { |
|
202 |
$target = $self->{$item}{target}; |
|
203 |
} |
|
204 |
|
|
205 |
my $level = $form->escape($item); |
|
206 |
|
|
207 |
my $str = qq| link="$module?action=| . $form->escape($action) . |
|
208 |
qq|&level=| . $form->escape($level); |
|
209 |
|
|
210 |
my @vars = qw(module action target href); |
|
211 |
|
|
212 |
if ($self->{$item}{href}) { |
|
213 |
$str = qq| link=$self->{$item}{href}|; |
|
214 |
@vars = qw(module target href); |
|
215 |
} |
|
216 |
|
|
217 |
map { delete $self->{$item}{$_} } @vars; |
|
218 |
|
|
219 |
# add other params |
|
220 |
foreach my $key (keys %{ $self->{$item} }) { |
|
221 |
$str .= "&" . $form->escape($key, 1) . "="; |
|
222 |
my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2); |
|
223 |
$value = $myconfig->{$value} . "/$conf" if ($conf); |
|
224 |
$str .= $form->escape($value, 1); |
|
225 |
} |
|
226 |
|
|
227 |
$str .= '"'; |
|
228 |
|
|
229 |
|
|
230 |
|
|
231 |
if ($other) { |
|
232 |
foreach my $key (keys(%{$other})) { |
|
233 |
$str .= qq| ${key}="| . $form->quote($other->{$key}) . qq|"|; |
|
234 |
} |
|
235 |
} |
|
236 |
|
|
237 |
|
|
238 |
$main::lxdebug->leave_sub(); |
|
239 |
|
|
240 |
return $str; |
|
241 |
} |
|
242 |
|
|
243 | 90 |
sub access_control { |
244 | 91 |
$main::lxdebug->enter_sub(2); |
245 | 92 |
|
bin/mozilla/menu.pl | ||
---|---|---|
1 |
#===================================================================== |
|
2 |
# LX-Office ERP |
|
3 |
# Copyright (C) 2004 |
|
4 |
# Based on SQL-Ledger Version 2.1.9 |
|
5 |
# Web http://www.lx-office.org |
|
6 |
# |
|
7 |
###################################################################### |
|
8 |
# SQL-Ledger Accounting |
|
9 |
# Copyright (c) 1998-2002 |
|
10 |
# |
|
11 |
# Author: Dieter Simader |
|
12 |
# Email: dsimader@sql-ledger.org |
|
13 |
# Web: http://www.sql-ledger.org |
|
14 |
# |
|
15 |
# Contributors: Christopher Browne |
|
16 |
# |
|
17 |
# This program is free software; you can redistribute it and/or modify |
|
18 |
# it under the terms of the GNU General Public License as published by |
|
19 |
# the Free Software Foundation; either version 2 of the License, or |
|
20 |
# (at your option) any later version. |
|
21 |
# |
|
22 |
# This program is distributed in the hope that it will be useful, |
|
23 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
24 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
25 |
# GNU General Public License for more details. |
|
26 |
# You should have received a copy of the GNU General Public License |
|
27 |
# along with this program; if not, write to the Free Software |
|
28 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
29 |
####################################################################### |
|
30 |
# |
|
31 |
# the frame layout with refractured menu |
|
32 |
# |
|
33 |
# CHANGE LOG: |
|
34 |
# DS. 2002-03-25 Created |
|
35 |
# 2004-12-14 - New Optik - Marco Welter <mawe@linux-studio.de> |
|
36 |
# 2010-08-19 - Icons for sub entries and single click behavior, unlike XUL-Menu |
|
37 |
# JS switchable HTML-menu - Sven Donath <lxo@dexo.de> |
|
38 |
####################################################################### |
|
39 |
|
|
40 |
use strict; |
|
41 |
|
|
42 |
use SL::Menu; |
|
43 |
use URI; |
|
44 |
|
|
45 |
use List::MoreUtils qw(apply); |
|
46 |
|
|
47 |
sub render { |
|
48 |
$::lxdebug->enter_sub; |
|
49 |
|
|
50 |
$::form->use_stylesheet(qw(css/icons16.css css/icons24.css)); |
|
51 |
|
|
52 |
my $menu = Menu->new("menu.ini"); |
|
53 |
|
|
54 |
my $sections = [ section_menu($menu) ]; |
|
55 |
|
|
56 |
$::lxdebug->leave_sub; |
|
57 |
$::form->parse_html_template('menu/menu', { |
|
58 |
sections => $sections, |
|
59 |
inline => 1, |
|
60 |
}); |
|
61 |
} |
|
62 |
|
|
63 |
sub section_menu { |
|
64 |
$::lxdebug->enter_sub(2); |
|
65 |
my ($menu, $level, $id_prefix) = @_; |
|
66 |
my @menuorder = $menu->access_control(\%::myconfig, $level); |
|
67 |
my @items; |
|
68 |
|
|
69 |
my $id = 0; |
|
70 |
|
|
71 |
for my $item (@menuorder) { |
|
72 |
my $menuitem = $menu->{$item}; |
|
73 |
my $olabel = apply { s/.*--// } $item; |
|
74 |
my $ml = apply { s/--.*// } $item; |
|
75 |
my $icon_class = apply { y/ /-/ } $item; |
|
76 |
my $spacer = "s" . (0 + $item =~ s/--/--/g); |
|
77 |
|
|
78 |
next if $level && $item ne "$level--$olabel"; |
|
79 |
|
|
80 |
my $label = $::locale->text($olabel); |
|
81 |
|
|
82 |
$menuitem->{module} ||= $::form->{script}; |
|
83 |
$menuitem->{action} ||= "section_menu"; |
|
84 |
$menuitem->{href} ||= "$menuitem->{module}?action=$menuitem->{action}"; |
|
85 |
|
|
86 |
# add other params |
|
87 |
foreach my $key (keys %$menuitem) { |
|
88 |
next if $key =~ /target|module|action|href/; |
|
89 |
$menuitem->{href} .= "&" . $::form->escape($key, 1) . "="; |
|
90 |
my ($value, $conf) = split(/=/, $menuitem->{$key}, 2); |
|
91 |
$value = $::myconfig{$value} . "/$conf" if ($conf); |
|
92 |
$menuitem->{href} .= $::form->escape($value, 1); |
|
93 |
} |
|
94 |
|
|
95 |
my $anchor = $menuitem->{href}; |
|
96 |
|
|
97 |
my %common_args = ( |
|
98 |
l => $label, |
|
99 |
s => $spacer, |
|
100 |
id => "$id_prefix\_$id", |
|
101 |
); |
|
102 |
|
|
103 |
if (!$level) { # toplevel |
|
104 |
push @items, { %common_args, |
|
105 |
i => "icon24 $icon_class", # make_image(size => 24, label => $item), |
|
106 |
c => 'm', |
|
107 |
}; |
|
108 |
push @items, section_menu($menu, $item, "$id_prefix\_$id"); |
|
109 |
} elsif ($menuitem->{submenu}) { |
|
110 |
push @items, { %common_args, |
|
111 |
i => "icon16 submenu", #make_image(label => 'submenu'), |
|
112 |
c => 'sm', |
|
113 |
}; |
|
114 |
push @items, section_menu($menu, $item, "$id_prefix\_$id"); |
|
115 |
} elsif ($menuitem->{module}) { |
|
116 |
push @items, { %common_args, |
|
117 |
i => "icon16 $icon_class", #make_image(size => 16, label => $item), |
|
118 |
h => $anchor, |
|
119 |
c => 'i', |
|
120 |
}; |
|
121 |
} |
|
122 |
} continue { |
|
123 |
$id++; |
|
124 |
} |
|
125 |
|
|
126 |
$::lxdebug->leave_sub(2); |
|
127 |
return @items; |
|
128 |
} |
|
129 |
|
|
130 |
sub _calc_framesize { |
|
131 |
my $is_lynx_browser = $ENV{HTTP_USER_AGENT} =~ /links/i; |
|
132 |
my $is_mobile_browser = $ENV{HTTP_USER_AGENT} =~ /mobile/i; |
|
133 |
my $is_mobile_style = $::form->{stylesheet} =~ /mobile/i; |
|
134 |
|
|
135 |
return $is_mobile_browser && $is_mobile_style ? 130 |
|
136 |
: $is_lynx_browser ? 240 |
|
137 |
: 200; |
|
138 |
} |
|
139 |
|
|
140 |
sub _show_images { |
|
141 |
# don't show images in links |
|
142 |
_calc_framesize() != 240; |
|
143 |
} |
|
144 |
|
|
145 |
1; |
|
146 |
|
|
147 |
__END__ |
bin/mozilla/menujs.pl | ||
---|---|---|
1 |
#===================================================================== |
|
2 |
# LX-Office ERP |
|
3 |
# Copyright (C) 2004 |
|
4 |
# Based on SQL-Ledger Version 2.1.9 |
|
5 |
# Web http://www.lx-office.org |
|
6 |
# |
|
7 |
###################################################################### |
|
8 |
# SQL-Ledger Accounting |
|
9 |
# Copyright (c) 1998-2002 |
|
10 |
# |
|
11 |
# Author: Dieter Simader |
|
12 |
# Email: dsimader@sql-ledger.org |
|
13 |
# Web: http://www.sql-ledger.org |
|
14 |
# |
|
15 |
# Contributors: Christopher Browne |
|
16 |
# |
|
17 |
# This program is free software; you can redistribute it and/or modify |
|
18 |
# it under the terms of the GNU General Public License as published by |
|
19 |
# the Free Software Foundation; either version 2 of the License, or |
|
20 |
# (at your option) any later version. |
|
21 |
# |
|
22 |
# This program is distributed in the hope that it will be useful, |
|
23 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
24 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
25 |
# GNU General Public License for more details. |
|
26 |
# You should have received a copy of the GNU General Public License |
|
27 |
# along with this program; if not, write to the Free Software |
|
28 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
29 |
####################################################################### |
|
30 |
# |
|
31 |
# thre frame layout with refractured menu |
|
32 |
# |
|
33 |
# CHANGE LOG: |
|
34 |
# DS. 2002-03-25 Created |
|
35 |
# 2004-12-14 - Holger Lindemann |
|
36 |
####################################################################### |
|
37 |
|
|
38 |
use utf8; |
|
39 |
use strict; |
|
40 |
|
|
41 |
use SL::Menu; |
|
42 |
use CGI::Carp qw(fatalsToBrowser); |
|
43 |
|
|
44 |
1; |
|
45 |
|
|
46 |
# end of main |
|
47 |
|
|
48 |
sub display { |
|
49 |
|
|
50 |
my $form = $main::form; |
|
51 |
|
|
52 |
$form->{callback} = $form->unescape($form->{callback}); |
|
53 |
$form->{callback} ||= "login.pl?action=company_logo"; |
|
54 |
|
|
55 |
$form->header; |
|
56 |
|
|
57 |
&clock_line; |
|
58 |
|
|
59 |
&acc_menu; |
|
60 |
|
|
61 |
print qq| |
|
62 |
<iframe id="win1" src="$form->{callback}" width="100%" height="93%" name="main_window" style="position: absolute; border:0px;"> |
|
63 |
<p>Ihr Browser kann leider keine eingebetteten Frames anzeigen. |
|
64 |
</p> |
|
65 |
</iframe> |
|
66 |
</body> |
|
67 |
</html> |
|
68 |
|
|
69 |
|; |
|
70 |
|
|
71 |
} |
|
72 |
|
|
73 |
sub clock_line { |
|
74 |
|
|
75 |
my $form = $main::form; |
|
76 |
|
|
77 |
my $fensterlink="menujs.pl?action=display"; |
|
78 |
my $fenster = "["."<a href=\"$fensterlink\" target=\"_blank\">neues Fenster</a>]"; |
|
79 |
|
|
80 |
my $login = "[Nutzer " |
|
81 |
. $form->{login} |
|
82 |
. " - <a href=\"controller.pl?action=LoginScreen/logout\" target=\"_top\">" |
|
83 |
. $::locale->text('Logout') |
|
84 |
. "</a>] "; |
|
85 |
my ($Sekunden, $Minuten, $Stunden, $Monatstag, $Monat, |
|
86 |
$Jahr, $Wochentag, $Jahrestag, $Sommerzeit) |
|
87 |
= localtime(time); |
|
88 |
my $CTIME_String = localtime(time); |
|
89 |
$Monat += 1; |
|
90 |
$Jahrestag += 1; |
|
91 |
$Monat = $Monat < 10 ? $Monat = "0" . $Monat : $Monat; |
|
92 |
$Monatstag = $Monatstag < 10 ? $Monatstag = "0" . $Monatstag : $Monatstag; |
|
93 |
$Jahr += 1900; |
|
94 |
my @Wochentage = ("Sonntag", "Montag", "Dienstag", "Mittwoch", |
|
95 |
"Donnerstag", "Freitag", "Samstag"); |
|
96 |
my @Monatsnamen = ("", "Januar", "Februar", "März", |
|
97 |
"April", "Mai", "Juni", "Juli", |
|
98 |
"August", "September", "Oktober", "November", |
|
99 |
"Dezember"); |
|
100 |
my $datum = |
|
101 |
$Wochentage[$Wochentag] . ", der " |
|
102 |
. $Monatstag . "." |
|
103 |
. $Monat . "." |
|
104 |
. $Jahr . " - "; |
|
105 |
|
|
106 |
#$zeit="<div id='Uhr'>".$Stunden.":".$Minuten.":".$Sekunden."</div>"; |
|
107 |
my $zeit = "<div id='Uhr'>" . $Stunden . ":" . $Minuten . "</div>"; |
|
108 |
print qq| |
|
109 |
<script type="text/javascript"> |
|
110 |
<!-- |
|
111 |
function clockon() { |
|
112 |
var now = new Date(); |
|
113 |
var h = now.getHours(); |
|
114 |
var m = now.getMinutes(); |
|
115 |
document.getElementById('clock_id').innerHTML = (h<10?'0'+h:h)+":"+(m<10?'0'+m:m); |
|
116 |
var timer=setTimeout("clockon()", 10000); |
|
117 |
} |
|
118 |
window.onload=clockon |
|
119 |
//--> |
|
120 |
</script> |
|
121 |
<table border="0" width="100%" background="image/bg_titel.gif" cellpadding="0" cellspacing="0"> |
|
122 |
<tr> |
|
123 |
<td style="color:white; font-family:verdana,arial,sans-serif; font-size: 12px;"> $fenster [<a href="JavaScript:top.main_window.print()">drucken</a>]</td> |
|
124 |
<td align="right" style="vertical-align:middle; color:white; font-family:verdana,arial,sans-serif; font-size: 12px;" nowrap> |
|
125 |
$login $datum <span id='clock_id' style='position:relative'></span> |
|
126 |
</td> |
|
127 |
</tr> |
|
128 |
</table> |
|
129 |
|; |
|
130 |
} |
|
131 |
|
|
132 |
sub acc_menu { |
|
133 |
|
|
134 |
my $form = $main::form; |
|
135 |
my %myconfig = %main::myconfig; |
|
136 |
|
|
137 |
my $mainlevel = $form->{level}; |
|
138 |
$mainlevel =~ s/$mainlevel--//g; |
|
139 |
my $menu = Menu->new("menu.ini"); |
|
140 |
|
|
141 |
$| = 1; |
|
142 |
|
|
143 |
print qq| |
|
144 |
<style> |
|
145 |
<!-- |
|
146 |
|
|
147 |
.itemBorder { |
|
148 |
border: 1px solid black |
|
149 |
} |
|
150 |
|
|
151 |
.itemText { |
|
152 |
text-decoration: none; |
|
153 |
color: #000000; |
|
154 |
font: 12px Arial, Helvetica |
|
155 |
} |
|
156 |
|
|
157 |
.rootItemText { |
|
158 |
text-decoration: none; |
|
159 |
color: #ffffff; |
|
160 |
font: 12px Arial, Helvetica |
|
161 |
} |
|
162 |
|
|
163 |
.menu { |
|
164 |
color:#ffffff; |
|
165 |
background:url(image/bg_css_menu.png) repeat bottom; |
|
166 |
border:1px solid; |
|
167 |
border-color:#ccc #888 #555 #bbb; |
|
168 |
} |
|
169 |
|
|
170 |
--> |
|
171 |
</style> |
|
172 |
|
|
173 |
<script type="text/javascript"> |
|
174 |
<!-- |
|
175 |
var isDOM = (document.getElementById ? true : false); |
|
176 |
var isIE4 = ((document.all && !isDOM) ? true : false); |
|
177 |
var isNS4 = (document.layers ? true : false); |
|
178 |
//var KO = (navigator.appName=="Konqueror" \|\| navigator.appName=="Opera") ; |
|
179 |
var KO = ((navigator.userAgent.indexOf('Opera',0) != -1) \|\| (navigator.userAgent.indexOf('Konqueror',0) != -1)); |
|
180 |
function getRef(id) { |
|
181 |
if (isDOM) return document.getElementById(id); |
|
182 |
if (isIE4) return document.all[id]; |
|
183 |
if (isNS4) return document.layers[id]; |
|
184 |
} |
|
185 |
function getSty(id) { |
|
186 |
return (isNS4 ? getRef(id) : getRef(id).style); |
|
187 |
} |
|
188 |
var popTimer = 0; |
|
189 |
var litNow = new Array(); |
|
190 |
function popOver(menuNum, itemNum) { |
|
191 |
if (KO) document.getElementById("win1").style.visibility = "hidden"; |
|
192 |
clearTimeout(popTimer); |
|
193 |
hideAllBut(menuNum); |
|
194 |
litNow = getTree(menuNum, itemNum); |
|
195 |
changeCol(litNow, true); |
|
196 |
targetNum = menu[menuNum][itemNum].target; |
|
197 |
if (targetNum > 0) { |
|
198 |
thisX = parseInt(menu[menuNum][0].ref.left) + parseInt(menu[menuNum][itemNum].ref.left); |
|
199 |
thisY = parseInt(menu[menuNum][0].ref.top) + parseInt(menu[menuNum][itemNum].ref.top); |
|
200 |
with (menu[targetNum][0].ref) { |
|
201 |
left = parseInt(thisX + menu[targetNum][0].x); |
|
202 |
top = parseInt(thisY + menu[targetNum][0].y); |
|
203 |
visibility = 'visible'; |
|
204 |
} |
|
205 |
} |
|
206 |
} |
|
207 |
function popOut(menuNum, itemNum) { |
|
208 |
if ((menuNum == 0) && !menu[menuNum][itemNum].target) |
|
209 |
hideAllBut(0) |
|
210 |
if (KO) document.getElementById("win1").style.visibility = "visible"; |
|
211 |
else |
|
212 |
popTimer = setTimeout('hideAllBut(0)', 500); |
|
213 |
} |
|
214 |
function getTree(menuNum, itemNum) { |
|
215 |
itemArray = new Array(menu.length); |
|
216 |
while(1) { |
|
217 |
itemArray[menuNum] = itemNum; |
|
218 |
if (menuNum == 0) return itemArray; |
|
219 |
itemNum = menu[menuNum][0].parentItem; |
|
220 |
menuNum = menu[menuNum][0].parentMenu; |
|
221 |
} |
|
222 |
} |
|
223 |
function changeCol(changeArray, isOver) { |
|
224 |
for (menuCount = 0; menuCount < changeArray.length; menuCount++) { |
|
225 |
if (changeArray[menuCount]) { |
|
226 |
newCol = isOver ? menu[menuCount][0].overCol : menu[menuCount][0].backCol; |
|
227 |
with (menu[menuCount][changeArray[menuCount]].ref) { |
|
228 |
if (isNS4) bgColor = newCol; |
|
229 |
else backgroundColor = newCol; |
|
230 |
} |
|
231 |
} |
|
232 |
} |
|
233 |
} |
|
234 |
function hideAllBut(menuNum) { |
|
235 |
var keepMenus = getTree(menuNum, 1); |
|
236 |
for (count = 0; count < menu.length; count++) |
|
237 |
if (!keepMenus[count]) |
|
238 |
menu[count][0].ref.visibility = 'hidden'; |
|
239 |
changeCol(litNow, false); |
|
240 |
} |
|
241 |
|
|
242 |
function Menu(isVert, popInd, x, y, width, overCol, backCol, borderClass, textClass) { |
|
243 |
this.isVert = isVert; |
|
244 |
this.popInd = popInd |
|
245 |
this.x = x; |
|
246 |
this.y = y; |
|
247 |
this.width = width; |
|
248 |
this.overCol = overCol; |
|
249 |
this.backCol = backCol; |
|
250 |
this.borderClass = borderClass; |
|
251 |
this.textClass = textClass; |
|
252 |
this.parentMenu = null; |
|
253 |
this.parentItem = null; |
|
254 |
this.ref = null; |
|
255 |
} |
|
256 |
function Item(text, href, frame, length, spacing, target) { |
|
257 |
this.text = text; |
|
258 |
this.href = href; |
|
259 |
this.frame = frame; |
|
260 |
this.length = length; |
|
261 |
this.spacing = spacing; |
|
262 |
this.target = target; |
|
263 |
this.ref = null; |
|
264 |
} |
|
265 |
function go(link,frame) { |
|
266 |
tmp=eval("top."+frame); |
|
267 |
tmp.location=link; |
|
268 |
//top.main_window.location=link; |
|
269 |
} |
|
270 |
function writeMenus() { |
|
271 |
if (!isDOM && !isIE4 && !isNS4) return; |
|
272 |
for (currMenu = 0; currMenu < menu.length; currMenu++) with (menu[currMenu][0]) { |
|
273 |
var str = '', itemX = 0, itemY = 0; |
|
274 |
for (currItem = 1; currItem < menu[currMenu].length; currItem++) with (menu[currMenu][currItem]) { |
|
275 |
var itemID = 'menu' + currMenu + 'item' + currItem; |
|
276 |
var w = (isVert ? width : length); |
|
277 |
var h = (isVert ? length : width); |
|
278 |
if (isDOM \|\| isIE4) { |
|
279 |
str += '<div id="' + itemID + '" style="position: absolute; left: ' + itemX + '; top: ' + itemY + '; width: ' + w + '; height: ' + h + '; visibility: inherit; '; |
|
280 |
if (backCol) str += 'background: ' + backCol + '; '; |
|
281 |
str += '" '; |
|
282 |
} |
|
283 |
if (isNS4) { |
|
284 |
str += '<layer id="' + itemID + '" left="' + itemX + '" top="' + itemY + '" width="' + w + '" height="' + h + '" visibility="inherit" '; |
|
285 |
if (backCol) str += 'bgcolor="' + backCol + '" '; |
|
286 |
} |
|
287 |
if (borderClass) str += 'class="' + borderClass + '" "'; |
|
288 |
str += 'onMouseOver="popOver(' + currMenu + ',' + currItem + ')" onMouseOut="popOut(' + currMenu + ',' + currItem + ')">'; |
|
289 |
str += '<table width="' + (w - 8) + '" border="0" cellspacing="0" cellpadding="' + (!isNS4 && borderClass ? 3 : 0) + '">'; |
|
290 |
str +='<tr><td class="' + textClass + '" style="cursor:pointer;" align="left" height="' + (h - 7) + '" onClick=\\'go("' + href + '","' + frame + '")\\'>' + text + '</a></td>'; |
|
291 |
if (target > 0) { |
|
292 |
menu[target][0].parentMenu = currMenu; |
|
293 |
menu[target][0].parentItem = currItem; |
|
294 |
if (popInd) str += '<td class="' + textClass + '" align="right">' + popInd + '</td>'; |
|
295 |
} |
|
296 |
str += '</tr></table>' + (isNS4 ? '</layer>' : '</div>'); |
|
297 |
if (isVert) itemY += length + spacing; |
|
298 |
else itemX += length + spacing; |
|
299 |
} |
|
300 |
if (isDOM) { |
|
301 |
var newDiv = document.createElement('div'); |
|
302 |
document.getElementsByTagName('body').item(0).appendChild(newDiv); |
|
303 |
newDiv.innerHTML = str; |
|
304 |
ref = newDiv.style; |
|
305 |
ref.position = 'absolute'; |
|
306 |
ref.visibility = 'hidden'; |
|
307 |
} |
|
308 |
if (isIE4) { |
|
309 |
document.body.insertAdjacentHTML('beforeEnd', '<div id="menu' + currMenu + 'div" ' + 'style="position: absolute; visibility: hidden">' + str + '</div>'); |
|
310 |
ref = getSty('menu' + currMenu + 'div'); |
|
311 |
} |
|
312 |
if (isNS4) { |
|
313 |
ref = new Layer(0); |
|
314 |
ref.document.write(str); |
|
315 |
ref.document.close(); |
|
316 |
} |
|
317 |
for (currItem = 1; currItem < menu[currMenu].length; currItem++) { |
|
318 |
itemName = 'menu' + currMenu + 'item' + currItem; |
|
319 |
if (isDOM \|\| isIE4) menu[currMenu][currItem].ref = getSty(itemName); |
|
320 |
if (isNS4) menu[currMenu][currItem].ref = ref.document[itemName]; |
|
321 |
} |
|
322 |
} |
|
323 |
with(menu[0][0]) { |
|
324 |
ref.left = x; |
|
325 |
ref.top = y; |
|
326 |
ref.visibility = 'visible'; |
Auch abrufbar als: Unified diff
Layouts eingeführt
bin/mozilla/menu* -> SL/Controller/Layout/*