From f1b0785501f46f6204ae46cdc9b9ef257b5a216b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 28 Aug 2012 10:34:57 +0200 Subject: [PATCH] kleine Weiterentwicklung --- SL/Menu.pm | 12 ++++++++++++ SL/MenuItem.pm | 30 +++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/SL/Menu.pm b/SL/Menu.pm index 8b2a201c0..debceae88 100644 --- a/SL/Menu.pm +++ b/SL/Menu.pm @@ -58,6 +58,18 @@ sub new { return $self; } +sub menuitems { + my ($self) = @_; + + map { + SL::MenuItem->new( + name => $_, + menu => $self, + item => $self->{$_} + ); + } $self->access_control; +} + sub menuitem { $main::lxdebug->enter_sub(); diff --git a/SL/MenuItem.pm b/SL/MenuItem.pm index 7accaf975..dbdaf800b 100644 --- a/SL/MenuItem.pm +++ b/SL/MenuItem.pm @@ -1,18 +1,19 @@ package SL::MenuItem; +use strict; + sub new { - my ($class, %values) = @_; + my ($class, %params) = @_; my $obj = bless {}, $class; - $obj->{ACCESS} = delete $values{ACCESS}; - $obj->{module} = delete $values{module} || die 'menuitem - need module'; - $obj->{action} = delete $values{action} || die 'menuitem - need action'; - - $obj->{params} = \%values; -} + $obj->{fullname} = $params{name}; + my $values = $params{item}; -sub access { + $obj->{ACCESS} = delete $values->{ACCESS}; + $obj->{module} = delete $values->{module} || die 'menuitem - need module'; + $obj->{action} = delete $values->{action} || die 'menuitem - need action'; + $obj->{params} = $values; } sub ACCESS { $_[0]{ACCESS} } @@ -20,7 +21,18 @@ sub action { $_[0]{action} } sub module { $_[0]{module} } sub params { $_[0]{params} } -sub +sub name { $_[0]{name} ||= $_[0]->_init_name } +sub _init_name { my $name = $_[0]{fullname}; $name =~ s/.*--//; $name } +sub path { @{ $_[0]{path} ||= [ $_[0]->_init_path ] } } +sub _init_path { my $name = $_[0]{fullname}; split /--/, $name } + +sub children { } +sub siblings {} +sub parent {} + + +###### internal stuff ####### + 1; -- 2.20.1