Revision c7ad671d
Von Sven Schöling vor etwa 12 Jahren hinzugefügt
SL/MenuItem.pm | ||
---|---|---|
1 |
package SL::MenuItem; |
|
2 |
|
|
3 |
sub new { |
|
4 |
my ($class, %values) = @_; |
|
5 |
|
|
6 |
my $obj = bless {}, $class; |
|
7 |
$obj->{ACCESS} = delete $values{ACCESS}; |
|
8 |
$obj->{module} = delete $values{module} || die 'menuitem - need module'; |
|
9 |
$obj->{action} = delete $values{action} || die 'menuitem - need action'; |
|
10 |
|
|
11 |
$obj->{params} = \%values; |
|
12 |
} |
|
13 |
|
|
14 |
sub access { |
|
15 |
|
|
16 |
} |
|
17 |
|
|
18 |
sub ACCESS { $_[0]{ACCESS} } |
|
19 |
sub action { $_[0]{action} } |
|
20 |
sub module { $_[0]{module} } |
|
21 |
sub params { $_[0]{params} } |
|
22 |
|
|
23 |
sub |
|
24 |
|
|
25 |
|
|
26 |
1; |
|
27 |
|
|
28 |
__END__ |
|
29 |
|
|
30 |
=encoding utf-8 |
|
31 |
|
|
32 |
=head1 NAME |
|
33 |
|
|
34 |
SL::MenuItem - wrapper class for menu items |
|
35 |
|
|
36 |
=head1 SYNOPSIS |
|
37 |
|
|
38 |
use SL::Menu; |
|
39 |
|
|
40 |
for my item (Menu->new->menuitems) { |
|
41 |
next unless $item->access; |
|
42 |
|
|
43 |
make_your_own_menuentry_from( |
|
44 |
module => $item->module, |
|
45 |
action => $iten->action, |
|
46 |
params => $item->params, |
|
47 |
name => $item->name, |
|
48 |
path => $item->path, |
|
49 |
children => $item->children, |
|
50 |
parent => $item->parent, |
|
51 |
); |
|
52 |
} |
|
53 |
|
|
54 |
=head1 DESCRIPTION |
|
55 |
|
|
56 |
This provides some wrapper methods around the raw entries in menu.ini. It sorts through expected information like module and action, wraps access calls for you and gives you tree access to siblings, children and parent elements in the menu structure. |
|
57 |
|
|
58 |
=head1 METHODS |
|
59 |
|
|
60 |
=over 4 |
|
61 |
|
|
62 |
=item new |
|
63 |
|
|
64 |
=item access |
|
65 |
|
|
66 |
=item module |
|
67 |
|
|
68 |
=item params |
|
69 |
|
|
70 |
=item name |
|
71 |
|
|
72 |
=item path |
|
73 |
|
|
74 |
=item children |
|
75 |
|
|
76 |
=item parent |
|
77 |
|
|
78 |
=item siblings |
|
79 |
|
|
80 |
=back |
|
81 |
|
|
82 |
=head1 BUGS |
|
83 |
|
|
84 |
=head1 AUTHOR |
|
85 |
|
|
86 |
Sven Schoeling E<lt>s.schoeling@linet-services.deE<gt> |
|
87 |
|
|
88 |
=cut |
Auch abrufbar als: Unified diff
MenuItem Skelett