From 9a27954c4c16bdee874490deabaf34b8eaff5edf Mon Sep 17 00:00:00 2001 From: einhverfr Date: Sat, 1 Sep 2007 01:37:57 +0000 Subject: Menu cross sections, used for example in handhelds, now work from an API point of view git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1477 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/DBObject/Menu.pm | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'LedgerSMB/DBObject') diff --git a/LedgerSMB/DBObject/Menu.pm b/LedgerSMB/DBObject/Menu.pm index 733d8f91..f92c02cb 100644 --- a/LedgerSMB/DBObject/Menu.pm +++ b/LedgerSMB/DBObject/Menu.pm @@ -40,11 +40,39 @@ th result set, This function does not return an entry for the top-level menu. sub generate { my ($self) = shift @_; - my @args; @{$self->{menu_items}} = $self->exec_method(funcname => 'menu_generate'); + $self->__generate; + + return @{$self->{menu_items}}; +} + +=over + +=item Menu::generate_secton($object) + +This class acts like Menu::Generate except it returns only a cross-section of +the menu. Basically it returns all nodes which are direct children below +$object->{parent_id}. + +=cut + +sub generate_section { + my ($self) = shift @_; + + @{$self->{menu_items}} = $self->exec_method(funcname => 'menu_children'); + $self->__generate; + + return @{$self->{menu_items}}; +} + +# Private method which contains logic common to the full menu and section logic + +sub __generate { + my ($self) = @_; $self->debug({file => '/tmp/menu'}); + my @args; shift @{$self->{menu_items}}; @@ -61,6 +89,3 @@ sub generate { } } } - return @{$self->{menu_items}}; -} - -- cgit v1.2.3