Revision 2a5e8973
Von Moritz Bunkus vor fast 12 Jahren hinzugefügt
SL/Layout/Css.pm | ||
---|---|---|
1 |
package SL::Layout::Css; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use List::Util qw(max); |
|
6 |
use Exporter qw(import); |
|
7 |
|
|
8 |
our @EXPORT = qw(clock_line print_menu menuitem_v3); |
|
9 |
|
|
10 |
sub clock_line { |
|
11 |
my ($Sekunden, $Minuten, $Stunden, $Monatstag, $Monat, |
|
12 |
$Jahr, $Wochentag, $Jahrestag, $Sommerzeit) |
|
13 |
= localtime(time); |
|
14 |
$Monat += 1; |
|
15 |
$Jahrestag += 1; |
|
16 |
$Monat = $Monat < 10 ? $Monat = "0" . $Monat : $Monat; |
|
17 |
$Monatstag = $Monatstag < 10 ? $Monatstag = "0" . $Monatstag : $Monatstag; |
|
18 |
$Jahr += 1900; |
|
19 |
my @Wochentage = ("Sonntag", "Montag", "Dienstag", "Mittwoch", |
|
20 |
"Donnerstag", "Freitag", "Samstag"); |
|
21 |
my @Monatsnamen = ("", "Januar", "Februar", "März", |
|
22 |
"April", "Mai", "Juni", "Juli", |
|
23 |
"August", "September", "Oktober", "November", |
|
24 |
"Dezember"); |
|
25 |
return |
|
26 |
$Wochentage[$Wochentag] . ", der " |
|
27 |
. $Monatstag . "." |
|
28 |
. $Monat . "." |
|
29 |
. $Jahr . " - "; |
|
30 |
} |
|
31 |
|
|
32 |
sub print_menu { |
|
33 |
my ($self, $parent, $depth) = @_; |
|
34 |
|
|
35 |
my $html; |
|
36 |
|
|
37 |
die if ($depth * 1 > 5); |
|
38 |
|
|
39 |
my @menuorder; |
|
40 |
my $menu = $self->menu; |
|
41 |
|
|
42 |
@menuorder = $menu->access_control(\%::myconfig, $parent); |
|
43 |
|
|
44 |
$parent .= "--" if ($parent); |
|
45 |
|
|
46 |
foreach my $item (@menuorder) { |
|
47 |
substr($item, 0, length($parent)) = ""; |
|
48 |
next if (($item eq "") || ($item =~ /--/)); |
|
49 |
|
|
50 |
my $menu_item = $menu->{"${parent}${item}"}; |
|
51 |
my $menu_title = $::locale->text($item); |
|
52 |
my $menu_text = $menu_title; |
|
53 |
|
|
54 |
if ($menu_item->{"submenu"} || !defined($menu_item->{"module"}) && !defined($menu_item->{href})) { |
|
55 |
|
|
56 |
my $h = $self->print_menu("${parent}${item}", $depth * 1 + 1)."\n"; |
|
57 |
if (!$parent) { |
|
58 |
$html .= qq|<ul><li><h2>${menu_text}</h2><ul>${h}</ul></li></ul>\n|; |
|
59 |
} else { |
|
60 |
$html .= qq|<li><div class="x">${menu_text}</div><ul>${h}</ul></li>\n|; |
|
61 |
} |
|
62 |
} else { |
|
63 |
if ($self->{sub_class} && $depth > 1) { |
|
64 |
$html .= qq|<li class='sub'>|; |
|
65 |
} else { |
|
66 |
$html .= qq|<li>|; |
|
67 |
} |
|
68 |
$html .= $self->menuitem_v3("${parent}$item", { "title" => $menu_title }); |
|
69 |
$html .= qq|${menu_text}</a></li>\n|; |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
return $html; |
|
74 |
} |
|
75 |
|
|
76 |
sub menuitem_v3 { |
|
77 |
$main::lxdebug->enter_sub(); |
|
78 |
|
|
79 |
my ($self, $item, $other) = @_; |
|
80 |
my $menuitem = $self->menu->{$item}; |
|
81 |
|
|
82 |
my $action = "section_menu"; |
|
83 |
my $module; |
|
84 |
|
|
85 |
if ($menuitem->{module}) { |
|
86 |
$module = $menuitem->{module}; |
|
87 |
} |
|
88 |
if ($menuitem->{action}) { |
|
89 |
$action = $menuitem->{action}; |
|
90 |
} |
|
91 |
|
|
92 |
my $level = $::form->escape($item); |
|
93 |
|
|
94 |
my $str = qq|<a href="$module?action=| . $::form->escape($action) . qq|&level=| . $::form->escape($level); |
|
95 |
|
|
96 |
my @vars = qw(module action target href); |
|
97 |
|
|
98 |
if ($menuitem->{href}) { |
|
99 |
$str = qq|<a href="$menuitem->{href}|; |
|
100 |
@vars = qw(module target href); |
|
101 |
} |
|
102 |
|
|
103 |
map { delete $menuitem->{$_} } @vars; |
|
104 |
|
|
105 |
# add other params |
|
106 |
foreach my $key (keys %{ $menuitem }) { |
|
107 |
$str .= "&" . $::form->escape($key, 1) . "="; |
|
108 |
my ($value, $conf) = split(/=/, $menuitem->{$key}, 2); |
|
109 |
$value = $::myconfig{$value} . "/$conf" if ($conf); |
|
110 |
$str .= $::form->escape($value, 1); |
|
111 |
} |
|
112 |
|
|
113 |
$str .= '"'; |
|
114 |
|
|
115 |
if ($other) { |
|
116 |
foreach my $key (keys(%{$other})) { |
|
117 |
$str .= qq| ${key}="| . $::form->quote($other->{$key}) . qq|"|; |
|
118 |
} |
|
119 |
} |
|
120 |
|
|
121 |
$str .= ">"; |
|
122 |
|
|
123 |
$main::lxdebug->leave_sub(); |
|
124 |
|
|
125 |
return $str; |
|
126 |
} |
|
127 |
|
|
128 |
1; |
SL/Layout/V3.pm | ||
---|---|---|
2 | 2 |
|
3 | 3 |
use strict; |
4 | 4 |
use parent qw(SL::Layout::Base); |
5 |
use SL::Layout::Css; |
|
6 | 5 |
|
7 | 6 |
use URI; |
8 | 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"}) && !defined($menu_item->{href})) { |
|
53 |
|
|
54 |
my $h = $self->print_menu("${parent}${item}", $depth * 1 + 1)."\n"; |
|
55 |
if (!$parent) { |
|
56 |
$html .= qq|<ul><li><h2>${menu_text}</h2><ul>${h}</ul></li></ul>\n|; |
|
57 |
} else { |
|
58 |
$html .= qq|<li><div class="x">${menu_text}</div><ul>${h}</ul></li>\n|; |
|
59 |
} |
|
60 |
} else { |
|
61 |
if ($self->{sub_class} && $depth > 1) { |
|
62 |
$html .= qq|<li class='sub'>|; |
|
63 |
} else { |
|
64 |
$html .= qq|<li>|; |
|
65 |
} |
|
66 |
$html .= $self->menuitem_v3("${parent}$item", { "title" => $menu_title }); |
|
67 |
$html .= qq|${menu_text}</a></li>\n|; |
|
68 |
} |
|
69 |
} |
|
70 |
|
|
71 |
return $html; |
|
72 |
} |
|
73 |
|
|
74 |
sub menuitem_v3 { |
|
75 |
$main::lxdebug->enter_sub(); |
|
76 |
|
|
77 |
my ($self, $item, $other) = @_; |
|
78 |
my $menuitem = $self->menu->{$item}; |
|
79 |
|
|
80 |
my $action = "section_menu"; |
|
81 |
my $module; |
|
82 |
|
|
83 |
if ($menuitem->{module}) { |
|
84 |
$module = $menuitem->{module}; |
|
85 |
} |
|
86 |
if ($menuitem->{action}) { |
|
87 |
$action = $menuitem->{action}; |
|
88 |
} |
|
89 |
|
|
90 |
my $level = $::form->escape($item); |
|
91 |
|
|
92 |
my $str = qq|<a href="$module?action=| . $::form->escape($action) . qq|&level=| . $::form->escape($level); |
|
93 |
|
|
94 |
my @vars = qw(module action target href); |
|
95 |
|
|
96 |
if ($menuitem->{href}) { |
|
97 |
$str = qq|<a href="$menuitem->{href}|; |
|
98 |
@vars = qw(module target href); |
|
99 |
} |
|
100 |
|
|
101 |
map { delete $menuitem->{$_} } @vars; |
|
102 |
|
|
103 |
# add other params |
|
104 |
foreach my $key (keys %{ $menuitem }) { |
|
105 |
$str .= "&" . $::form->escape($key, 1) . "="; |
|
106 |
my ($value, $conf) = split(/=/, $menuitem->{$key}, 2); |
|
107 |
$value = $::myconfig{$value} . "/$conf" if ($conf); |
|
108 |
$str .= $::form->escape($value, 1); |
|
109 |
} |
|
110 |
|
|
111 |
$str .= '"'; |
|
112 |
|
|
113 |
if ($other) { |
|
114 |
foreach my $key (keys(%{$other})) { |
|
115 |
$str .= qq| ${key}="| . $::form->quote($other->{$key}) . qq|"|; |
|
116 |
} |
|
117 |
} |
|
118 |
|
|
119 |
$str .= ">"; |
|
120 |
|
|
121 |
$main::lxdebug->leave_sub(); |
|
122 |
|
|
123 |
return $str; |
|
124 |
} |
|
125 |
|
|
9 | 126 |
sub init_sub_layouts { |
10 | 127 |
[ SL::Layout::None->new ] |
11 | 128 |
} |
Auch abrufbar als: Unified diff
Menu-V3-Code: Css.pm nach V3.pm gemerget
Css.pm war noch nötigt, als es gemeinsamen Code für V3.pm und V4.pm
enthielt. Letzteres gibt es inzwischen nicht mehr.